Hi
I'm new to maven-bundle-plugin, hello to all, and here goes.
Environment:
Maven 3.0.4
OSX Lion
Java 6_29
Background:
An IBM consulentant was involved with a custom extension/plugin to a product
running on Websphere.
The plugin is packaged as a OSGi bundle.
My part was to write and package all the business logic in a separate jar (as
this also is used elsewhere, e.g. wars).
The plugin then uses classes from "my" jar file, which is assembled with all
dependencies included and inlined.
What I want to achieve:
Problem is, the IBM guy used Eclipse to package the bundle, and handed it over
to me on a usb-stick, after deploying it to the OSGi container. No Maven, no
SCM.
Being a java developer well familiarized with Maven, Git etc, I now want to add
his code to github and use maven to build future refactorings to this plugin.
What I did:
I unzipped the plugin he had already packaged.
The structur was:
./build.properties
./META-INF/MANIFEST.MF
./no/company/plugin/.. (this is where the plugin code goes.)
./plugin.xml
./verticalsite-tfim-jar-with-dependencies.jar ("my" custom jar)
The content of the Eclipse exported manifest file is:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Version: 1.0.0
Require-Bundle: com.tivoli.am.fim.common,com.tivoli.am.fim.sts
Bundle-SymbolicName: no.tine.fim.plugin.vs;singleton:=true
Bundle-Name: Map Plug-in
Bundle-Localization: plugin
Bundle-Vendor: TIVOLI
Bundle-ClassPath: .,verticalsite-tfim-jar-with-dependencies.jar
Now I want to recreate the structure and manifest using Maven.
After reading up on maven-bundle-plugin, and experimenting a lot, this is how
my pom looks like.
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>no.company.tfim.plugin</groupId>
<artifactId>groupsynch</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
<properties>
<tfim.version>6.2.1</tfim.version>
<verticalsite.version>3.2-jar-with-dependencies</verticalsite.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
<instructions>
<Embed-Dependency>*;scope=compile;inline=false</Embed-Dependency>
<Include-Resource>{maven-resources}</Include-Resource>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId};singleton:=true</Bundle-SymbolicName>
<Bundle-Vendor>Company</Bundle-Vendor>
<Bundle-Name>Groupsynch Plug-in</Bundle-Name>
<Bundle-Localization>plugin</Bundle-Localization>
<Require-Bundle>com.tivoli.am.fim.common,com.tivoli.am.fim.sts</Require-Bundle>
<Export-Package>no.company.fim.plugin.vs.*</Export-Package>
<!--<_exportcontents></_exportcontents>-->
<Import-Package>!*</Import-Package>
<!--<Private-Package>*</Private-Package>-->
<Bundle-ClassPath>.,{maven-dependencies}</Bundle-ClassPath>
</instructions>
<supportedProjectTypes>
<supportedProjectType>jar</supportedProjectType>
</supportedProjectTypes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>no.company</groupId>
<artifactId>verticalsite</artifactId>
<version>${verticalsite.version}</version>
<scope>compile</scope>
</dependency>
rest of my deps goes here..
</dependencies>
</project>
The structur of my project is:
./pom.xml
./src/main/java (plugin code goes here)
./src/main/resources/plugin.xml
Problem 1)
Reading the docs, I should use packaging "bundle". This does not work, and
throws the following error
Unknown packaging: bundle @ line 12, column 16
I just switched to "jar", and it seems to work ok just the same, manifest.mf is
created with bundle props etc.
Problem 2)
When running the build with this pom, a get a lot of errors similiar to this:
[ERROR] Bundle no.company.tfim.plugin:groupsynch:jar:1.0.0 : Class in different
directory than declared. Path from class name is
no/company/verticalsite/VerticalSiteConfig.class but the path in the jar is
target/classes/no/company/verticalsite/VerticalSiteConfig.class from
'Jar:verticalsite-3.2-jar-with-dependencies.jar'
So, I want to include the jar file, and set the Bundle-Classpath.
<Embed-Dependency>*;scope=compile;inline=false</Embed-Dependency> tells the
bundle-plugin to include all deps with scope "compile", and inline is set to
false.
However I tweak the import/export packages, include-resource,embed-dependency
instructions, I get the same errors
When removing the Embed-Dependency instruction, the build is successfull, but
the jar is not included.
So I'm a bit stuck at the moment
I have tried Google, and came across
https://issues.apache.org/jira/browse/FELIX-660
which indicates that the bug is fixed, but I get the same errors, so I'm a bit
confused.