I have a gradle script (editor's cut):
apply plugin:'osgi' apply plugin:'eclipse' apply plugin:'groovy' .... dependencies { .... compile 'org.codehaus.groovy:groovy-all:2.4.4' compile 'com.gmongo:gmongo:1.5' } jar { manifest { .... instruction 'Embed-Dependency', '*;scope=compile|runtime' instruction 'Embed-Transitive', 'true' instruction 'Bundle-ClassPath', '.,gmongo-1.5.jar' } from { configurations.compile.findAll{ !it.directory && it.name.startsWith( 'gmongo' ) } } } As soon as gmongo doesn't provide a proper bundle-manifest I must include it as a dependency.
The resulting jar structure is:
/ |..com/ |..META-INF/ |..gmongo-1.5.jar MANIFEST.INF:
Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bnd-LastModified: 1461227335334 Bundle-ActivationPolicy: lazy Embed-Dependency: *;scope=compile|runtime Import-Package: com.gmongo,com.mongodb;version="[3.2,4)",groovy.lang;v ersion="[2.4,3)",....." Tool: Bnd-2.1.0.20130426-122213 Export-Package: com.mozaiq.echo;version="1.0.0";uses:="com.gmongo,groo vy.lang,javax.servlet,javax.servlet.http,org.osgi.framework" Bundle-ClassPath: .,gmongo-1.5.jar Embed-Transitive: true Created-By: 1.8.0_72 (Oracle Corporation) upon installing I'm getting
0 ERROR > Error occurred while trying to resolve bundle groovyecho.jar.20160426-110910406.jar!
org.osgi.framework.BundleException: Can't resolve groovyecho : package com.gmongo
What am I doing wrong?
UPDATE:
even if I unpack the gmongo.jar's classes:
jar { .... from { zipTree configurations.compile.find{ !it.directory && it.name.startsWith( 'gmongo' ) } } } I'm getting the same error.
SUMMARY:
instruction 'Import-Package', '!com.gmongo,*' worked well for un-jared class files.
To make it work on original jar file, I had to add also
instruction 'Bundle-ClassPath', '.,gmongo-1.5.jar'