We have the following scenario using OSGi bundles:
BundleA imports package "com.mypackage".
BundleB exports package "com.mypackage", but that package is from a nested JAR file added to the BundleB classpath.
In order to compile the OSGi bundles and resolve their dependencies automatically I'm using ANT + IVY.
I configured an ivy:buildobr task and it correctly builds the OBR file (checked manually).
Next I configured the actual build task.
- call ivy:resolve. I can clearly see that IVY correctly resolves package "com.mypackage".
- call ivy:cachepath that creates the compile class path.
- call javac with classpathref="compile.classpath"
javac throws error because it doesn't know about package "com.mypackage". It only knows about the classpath indicating the JAR files, and doesn't know how to interpret the MANIFEST.MF with it's own classpath.
The problem is with the constructed class path. It has no idea about the exported "com.mypackage" from the nested JAR in BundleB.
How do you solve this kind of issue?
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: BundleA
Bundle-SymbolicName: BundleA
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.mypackage,
org.osgi.framework;version="1.3.0"
Bundle-ClassPath: .
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: BundleB
Bundle-SymbolicName: BundleB
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.osgi.framework;version="1.3.0"
Export-Package: com.mypackage
Bundle-ClassPath: .,
nestedJarContainingComMypackage.jar
Thanks