[bnd-maven-plugin] Two ways of using the bnd-maven-plugin

738 views
Skip to first unread message

David Bosschaert

unread,
Dec 23, 2013, 12:09:43 PM12/23/13
to bndtool...@googlegroups.com
Hi all,

Just sharing a quick status on the bnd-maven-plugin... I worked a bit
on the code [1] and fixed some issues that were previously identified
(btw thanks to everyone who helped me getting started with this!). The
code is now all on the master branch. The simplest way of using it is
as follows:
1. Generate a bndtools project.
2. Add a pom.xml, with the following content (removed maven xml schema stuff :
<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>org.foo.bar</groupId>
<artifactId>myBundle</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>bnd</packaging>

<build>
<plugins>
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<version>0.2.0-SNAPSHOT</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>

This basically builds the project using Bnd. Setting are taken from
the bnd.bnd file. To get a Maven-style layout, this file could have
content, similar to this:
# These things are edited via bndtools
-buildpath: osgi.core;version=4.0
Private-Package: org.foo.bar
Bundle-Activator: org.foo.bar.TestActivator
Bundle-Version: 1.0.0.SNAPSHOT

# Add these to get a maven-like structure on disk and file names in target
-outputmask = ${@bsn}-${version;===S;${@version}}.jar
target-dir = target
bin = target/classes
src = src/main/java
testsrc = src/test/java
testbin = target/test-classes

It would be nice if the above files could be generated automatically
via bndtools. I created issue 800 for that [2].
You can also include tests that are run via bnd. These tests are run
as part of the integration-test phase in Maven. For example the
ExampleTest that is created via the bndtoold 'Integration Testing'
template just works with this.

In the pom.xml above, the packaging type is 'bnd'. I changed this from
the previous value 'bundle' to not interfere with the
maven-bundle-plugin which uses that value. However, Paul suggested to
simply use 'jar' as the packaging type. This is possible, but requires
quite a lot of configuration in the pom.xml. If we can have the
bnd-maven-plugin automatically configure this, I think we should use
is, but it needs to be investigated a bit more [3].

Finally, BJ and I were talking about doing releases. Typically in
Maven you'd develop using -SNAPSHOT versions (note that the
bnd-maven-plugin transforms x.y.z.SNAPSHOT into x.y.z-SNAPSHOT for
Maven). Then when you're done developing you use the
maven-release-plugin[4] to create the non-snapshot poms, tag/release
them etc. For people using this process, you'd really want the
Bundle-Version in the bnd.bnd file to be updated as part of this as
well. Note that the bnd-maven-plugin fails if there is a mismatch
between the versions in the pom.xml and bnd.bnd. We need to
investigate a little bit more how this can be done, for example by
looking at how Tycho does this.

That's it for the moment. I also updated the README.md with this
info... Feel free to comment/create issues if you have further
ideas...

Merry Christmas,

David

[1] https://github.com/bosschaert/bnd/tree/master/bnd-maven-plugin-parent
[2] https://github.com/bndtools/bndtools/issues/800
[3] https://github.com/bndtools/bnd/issues/449
[4] http://maven.apache.org/maven-release/maven-release-plugin/index.html

Peter Kriens

unread,
Dec 30, 2013, 3:57:00 AM12/30/13
to bndtool...@googlegroups.com
Nice work David!

It might be an idea to add a command to bnd to create a bnd-maven project with the right settings. Or maybe also to maven?

Kind regards,

Peter Kriens
> --
> You received this message because you are subscribed to the Google Groups "bndtools-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

David Bosschaert

unread,
Jan 6, 2014, 5:09:04 AM1/6/14
to bndtool...@googlegroups.com
That sounds like a good idea, Peter.

For Maven, probably the best thing to do would be to create a Maven Archetype...
I added https://github.com/bndtools/bnd/issues/453 for this.

For Bnd, I actually didn't know that Bnd could generate project
templates. Are there any other examples for this yet?

Cheers,

David

Peter Kriens

unread,
Jan 6, 2014, 10:45:43 AM1/6/14
to bndtool...@googlegroups.com
No, but adding a command line option for this is quite easy. Look at aQute.bnd.main.bnd (this is a class name).

Kind regards,

Peter Kriens
Reply all
Reply to author
Forward
0 new messages