Once
- Configure your jar plugin to include an OSGi compatible
MANIFEST.MF
file:org.codehaus.mojo build-helper-maven-plugin 1.9.1 set-osgi-version verify parse-version regex-property verify regex-property hans ${parsedVersion.osgiVersion} SNAPSHOT qualifier false org.apache.maven.plugins maven-jar-plugin 2.3.2 ${parsedVersion.osgiVersion} ${project.description} ${project.version} META-INF/MANIFEST.MF org.apache.maven.plugins maven-source-plugin 2.4 attach-sources verify jar 2 ${project.name} ${project.description} ${project.groupId}.${project.artifactId}.source ${project.organization.name} ${hans} ${project.groupId}.${project.artifactId};version="${hans}";roots:="."
- Commit all your changes.
- Adapt
pom.xml
to match the new version plus-SNAPSHOT
string. - Adapt
MANIFEST.MF
to match the new version omitting-SNAPSHOT
string or.qualifer
string respectively. Example:Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-RequiredExecutionEnvironment: J2SE-1.5 [..] Bundle-Version: 1.0.0 [..]
- Make sure all your exported packages match the new version.
Example:
[..] Bundle-Version: 1.0.0 Export-Package: net.sf.my.tools;version="1.0.0", net.sf.my.tools.async;version="1.0.0", net.sf.my.tools.comparator;version="1.0.0", Import-Package: org.junit;resolution:=optional, org.slf4j
Again no.qualifier
string! - Perform your release as usual:
user@client:~$ mvn clean release-prepare user@client:~$ mvn release-perform
- During the release, Maven will update the artifact version to the next iteration, e.g. 1.0.1-SNAPSHOT.
This is done automatically but affects only the
pom.xml
. You have to adaptMANIFEST.MF
manually to reflect the new version. This time, take over the Maven version string as given (replacing-SNAPSHOT
with.qualifer
). Example:Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-RequiredExecutionEnvironment: J2SE-1.5 [..] Bundle-Version: 1.0.1.qualifier [..]
- Again, make sure all your exported packages match the new version.
Example:
[..] Bundle-Version: 1.0.0 Export-Package: net.sf.my.tools;version="1.0.1.qualifier", net.sf.my.tools.async;version="1.0.1.qualifier", net.sf.my.tools.comparator;version="1.0.1.qualifier", Import-Package: org.junit;resolution:=optional, org.slf4j
This time include the.qualifier
string. - Done!
- When you add this p2-repository to an Eclipse Target Platform, Eclipse will not correctly distinguish between artifact and source artifact.
- It is not very convenient to adapt the OSGi versions manually before and after each release. A shell script or Maven plugin may help here.
1 thought on “release jar’s using maven that can be used as OSGi bundles as well”