I am using this simple pom.xml
to generate an OSGi-bundle using the maven-bundle-plugin
:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.test.osgi</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
This works as expected (that project contains a single public class that I have verified to be exported in the bundle). Now , if I add the following <configuration>
to the plugin:
<configuration>
<outputDirectory>D:\Test</outputDirectory>
</configuration>
the build fails with the following error:
[INFO] --- maven-bundle-plugin:2.3.7:bundle (default-cli) @ test ---
[WARNING] Bundle de.test.osgi:test:bundle:0.0.1-SNAPSHOT : Classpath is empty. Private-Package and Export-Package can only expand from the classpath when there is one
[WARNING] Bundle de.test.osgi:test:bundle:0.0.1-SNAPSHOT : Instructions in Private-Package, or -testpackages that are never used: .*
Classpath:
[ERROR] Bundle de.test.osgi:test:bundle:0.0.1-SNAPSHOT : The JAR is empty: dot
[ERROR] Error(s) found in bundle configuration
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.891s
[INFO] Finished at: Fri Mar 30 14:49:46 CEST 2012
[INFO] Final Memory: 8M/20M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.felix:maven-bundle-plugin:2.3.7:bundle (default-cli) on project test: Error(s) found in bundle configuration -> [Help 1]
Why is the classpath empty? What does the <outputDirectory>
have to do with it? Is this a bug, or have I misunderstood something?
Edit
Running with debug-output reveals that the classpath is indeed identical with <outputDirectory>
. By default, this is mavens target
directory, so he will find the classes to include in the bundle there. If I change it, it will point to a directory that contains no classes to include. Confusingly, the documentation for the plugin says that <outputDirectory>
is:
The directory for the generated bundles.
Is this a mistake?