Hi, [This is my second attempt to send this mail. My first attempt seems to be stuck in moderation, probably because I sent it from a non-authoritative smtp server for my domain (gmail). Sorry of this comes through twice.]
I'm having some trouble getting the Maven bundle plugin to do what I want. I'm new to this OSGi stuff so maybe the problem is what I think I want, not what the bundle doesn't do. Feel free to enlighten me. I'm assembling an application consisting of a small number (<5) of bundles, all of which I own. My bundles are coarse-grained and depend on a bunch of supporting library files (plain jars, not bundles) in addition to some of the other bundles.
From what I understand, what we want the plugin to do is to analyze my
source code for real dependencies (e.g. concrete imports in the Java files) and then for each dependency: o figure out the jar declared in the POM that provides the dependency; o if that jar file is a bundle, add a proper Import-Package or Require-Bundle to the OSGi manifest, o else if that jar file is just a plain ole jar (and not declared with scope "provided"), embed it in the bundle and add the jar to Bundle-Classpath. Am I completely off here? This seems to be the intuitive and integrated way to work with Maven and OSGi in harmony. Is there any way to get this behavior? All our attempts end up with way too much Import-Packages, few embedded jars and a whole bunch of unresolved dependency exceptions at runtime. To clarify, here are some snippets from a bundle with one class (an Activator) that uses one external class (a commons logger) from one supporting library (commons-logging-1.1.jar): --- >8 --- Activator.java --- >8 --- package com.organisation.somebundle; ... import org.apache.commons.logging.Log; ... public class Activator implements BundleActivator { ... public void start(BundleContext context) throws Exception { logger.debug( "Starting somebundle" ); // logger is a commons Log } ... --- >8 --- end Activator --- >8 --- --- >8 --- pom.xml --- >8 --- <project> ... <dependencies> <dependency> <groupId>org.osgi</groupId> <artifactId>osgi_R4_core</artifactId> <version>1.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1</version> <type>jar</type> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <version>0.8.0-SNAPSHOT</version> <configuration> <instructions> <Export-Package>com.organisation.somebundle</Export-Package> </instructions> </configuration> </plugin> </plugins> </build> </project> --- >8 --- end pom --- >8 --- --- >8 --- Bundle manifest --- >8 --- Manifest-Version: 1 Bundle-Name: Unnamed - com.organisation.somebundle:my-app:bundle:0.1 Created-By: Bnd-0.0.105 Import-Package: com.organisation.somebundle, org.apache.commons.loggin g, org.osgi.framework Bundle-ManifestVersion: 2 Bundle-SymbolicName: com.organisation.somebundle.my-app Include-Resource: src/main/resources/ Export-Package: com.organisation.somebundle;uses:="org.osgi.framework, org.apache.commons.logging" Bundle-Version: 0.1 --- >8 --- end manifest --- >8 --- --- >8 --- Failing the runtime dependency check --- >8 --- framework> install -s file:jars/my-app-0.1.jar Installed: Unnamed - com.organisation.somebundle:my-app:bundle:0.1 (#10) Couldn't install/start bundle: file:jars/my-app-0.1.jar (due to: org.osgi.framework.BundleException: Failed, missing package(s) or can not resolve all of the them: org.apache.commons.logging) org.osgi.framework.BundleException: Failed, missing package(s) or can not resolve all of the them: org.apache.commons.logging at org.knopflerfish.framework.BundleImpl.start(BundleImpl.java:313) at org.knopflerfish.bundle.frameworkcommands.FrameworkCommandGroup.cmdInstall(FrameworkCommandGroup.java:844) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.knopflerfish.service.console.CommandGroupAdapter.execute(CommandGroupAdapter.java:244) at org.knopflerfish.bundle.console.Command$2.run(Command.java:233) at java.security.AccessController.doPrivileged(Native Method) at org.knopflerfish.bundle.console.Command.run(Command.java:220) at java.lang.Thread.run(Thread.java:595) --- >8 --- end runtime behavior --- >8 --- TIA, -EE