bndtools & maven

281 views
Skip to first unread message

Gadi Eichhorn

unread,
Jan 1, 2017, 12:59:02 PM1/1/17
to bndtools-users
Hi all,

is it possible to set bnd to use a maven project structure?
I would like to run with bndtools from eclipse but also from maven (cmd).

I found this example at the end of the page. http://bnd.bndtools.org/chapters/123-tour-workspace.html that maps the bnd floders to maven folder.

a good working example will be great!
thanks.

Timothy Ward

unread,
Jan 3, 2017, 5:04:32 AM1/3/17
to bndtool...@googlegroups.com
Hi Gadi,

You can absolutely tell bnd to use a maven project structure, but it sounds as though that’s not really what you want. If you want to use maven to build your projects then you shouldn’t be using a bnd workspace, but instead be using Bndtools in “standalone” mode. Specifically you should write all of your projects as normal maven projects, but make use of the various bnd maven plugins in it.

There are some maven examples using the bnd plugins here: https://github.com/paremus/hello-examples/tree/master with a detailed guide here: https://docs.paremus.com/pages/viewpage.action?pageId=8060997

There has also been a lot of work to improve the maven experience for bndtools users going in to 3.4. If you’re interested you could always try the latest bndtools development snapshot.

Regards,

Tim


--
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/d/optout.

Gadi Eichhorn

unread,
Jan 3, 2017, 5:41:24 AM1/3/17
to bndtools-users
Thanks Tim, 

That is very true. I want to benefit from both worlds :-) , bndtools for dynamic development/testing and maven to do some code-generation (JOOQ/Verx) and ultimately automate the release process.

I will try the tutorial you suggested, thanks.

Gadi

Milen Dyankov

unread,
Jan 3, 2017, 11:11:41 AM1/3/17
to bndtool...@googlegroups.com
Hi Gadi,

the tutorial works OK (at least it did last time I tried it) and will show you the basics. However depends on how you are used to use Maven you will encounter some "weirdnesses" when you start to mix and match maven and bndtools. One thing to pay attention to is to always use "mvn install" even when you would normally use "mvn package". It seams if you don't "install" the repo/resolver will not see your changes. Another thing to pay attention to is bnd's cache. I can't figure out a way to reproduce the issue constantly (thus it's not officially reported) but often it seams resolver caches something which can lead to resolving things it shouldn't or not resolving ones that should resolve OK. If you happen to encounter any of those, try cleaning "generated" folder and remove "cached.xml" form target folder.

Best,
Milen
 

To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Gadi Eichhorn

unread,
Jan 3, 2017, 12:27:35 PM1/3/17
to bndtools-users
Hi Tim,

I wonder if there is a way not to use paremus framework in this setup?
standalone with felix only. on the maven front it works fine but from bnd/eclipse I cannot get the *.bndrun file to work.

Thanks,
Gadi.

On Tuesday, January 3, 2017 at 12:04:32 PM UTC+2, Tim Ward wrote:

Gadi Eichhorn

unread,
Jan 3, 2017, 12:30:02 PM1/3/17
to bndtools-users
Thanks Milen,

is there a way to use a clean felix without Paremus?
I dont need the servlet implementation.

Regards,
Gadi.

Neil Bartlett

unread,
Jan 3, 2017, 12:31:06 PM1/3/17
to bndtool...@googlegroups.com
Gadi,

These examples don’t depend on the Paremus Framework (because there is no such thing…). They work on standalone Felix, or Equinox, or Knopflerfish.

If you are experiencing difficulties, please give details so we can help.

Neil

Greg Amerson

unread,
Jan 3, 2017, 12:33:58 PM1/3/17
to bndtool...@googlegroups.com
Here is an example workspace I've been using recently to testdrive bndtools support for 'maven + bnd standalone workspace' 


Just install the latest Bndtools dev build (including the Bndtools m2e feature) and then import the above workspace as "File > Import as Maven projects".  Once you get done you can right-click the 'bndrun' file in the 'example-run' project and do "Run as > Bnd OSGi "



To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Greg Amerson
Liferay Developer Tools
Liferay, Inc. www.liferay.com
Message has been deleted

Gadi Eichhorn

unread,
Jan 4, 2017, 3:19:29 AM1/4/17
to bndtools-users
Thanks Neil,

I was struggling with the standalone repos, I realised I need the paremus maven plugin to make it work.

I made some progress and things start to work, however, when I make changes to bundles they are not automatically (re)deployed when running from the bndrun. is there a way to make it work like the standard bndtool process?
I am using the official release 3.3

Another question is related to release process, I want the executable jar (with a framework) to be "installed" with maven, standard release is from the bndrun file -> export -> ... is there a way to automate this from maven?

lastly, where can I find the repo for equinox? I looked on the paremus release repo and found only felix.
 
Thanks in advance.

Regards,
Gadi.

Christian Schneider

unread,
Jan 4, 2017, 3:58:48 AM1/4/17
to bndtool...@googlegroups.com
I have an example that uses bnd 3.3.0 to build the bundles as well as assemble a runnable jar completely with a single maven build.

See https://github.com/cschneider/osgi-chat/tree/master/packaging/all

I am using the bnd-indexer-plugin to create the obr index. In 3.3.0 the new pom based indexes did not work reliably for me. I also use the indexer plugin in a special way that only creates a locally usable index which works very well for me.

The project can also be run and debugged from eclipse using bndtools 3.3.0. Automatic updates do not fully work and the source code of external dependencies can not be attached
automatically.  Apart from this it works quite nicely.

Christian
-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

Timothy Ward

unread,
Jan 4, 2017, 5:09:43 AM1/4/17
to bndtool...@googlegroups.com
Hi Gadi,

I made some progress and things start to work, however, when I make changes to bundles they are not automatically (re)deployed when running from the bndrun. is there a way to make it work like the standard bndtool process?
I am using the official release 3.3

Unfortunately what you’re experiencing with 3.3 represents the best it has to offer (which is already much improved over 3.2). We have been working in 3.4 to improve this, and better support (live update in the bndrun) is now available in the latest 3.4.0.DEV snapshots - many thanks to Greg Amerson for that!

Another question is related to release process, I want the executable jar (with a framework) to be “installed" with maven, standard release is from the bndrun file -> export -> ... is there a way to automate this from maven?

Yes - you want the bnd-export-maven-plugin - see: https://github.com/bndtools/bnd/tree/master/maven/bnd-export-maven-plugin

lastly, where can I find the repo for equinox? I looked on the paremus release repo and found only felix.

Paremus provide a Felix index as a helpful way to run and test the Paremus examples. We could start to provide an Equinox index if that’s of interest.


Regards,

Tim

Gadi Eichhorn

unread,
Jan 4, 2017, 6:54:09 AM1/4/17
to bndtools-users
Thanks Tim,


The update site gives me errors on eclipse neon. is this the correct url? maybe the 3.4.0.DEV is not published... I removed the 3.3.0 first and add the alternative site and getting erros:

evelopment SnapshotNB: This build tracks the very latest version of the code, and is likely to be unstable or contain experimental features. 
https://bndtools.ci.cloudbees.com/job/bndtools.master/lastSuccessfulBuild/artifact/build/generated/p2/

I did manage to build all the maven plugins from the bnd project so I can use the plugins locally from maven (3.4.0-SNAPSHOT). success here :-)
[INFO] biz.aQute.bnd:bnd-plugin-parent .................... SUCCESS [  2.393 s] [INFO] biz.aQute.bnd:bnd-maven-plugin ..................... SUCCESS [ 27.618 s] [INFO] biz.aQute.bnd:bnd-indexer-maven-plugin ............. SUCCESS [02:05 min] [INFO] biz.aQute.bnd:bnd-baseline-maven-plugin ............ SUCCESS [01:13 min] [INFO] biz.aQute.bnd:bnd-export-maven-plugin .............. SUCCESS [  9.254 s]

I dont need the equinox as such but it is useful to sometimes clear bugs and generalise your code. what I've done so far is to add my dependencies to the index project (fls4j & logback) and this seemed to work fine (I would probably split it to internal index and external one moving forward). will you recommend a different way to handle dependencies?

thanks again,
Gadi.

Gadi Eichhorn

unread,
Jan 4, 2017, 7:01:35 AM1/4/17
to bndtools-users
Thanks Christian,

I had a quick look, it failed build. I will come back to this once the other thread will be exhausted. appreciate your help.

[ERROR] Plugin biz.aQute.bnd:bnd-export-maven-plugin:3.3.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for biz.aQute.bnd:bnd-export-maven-plugin:jar:3.3.0: 4 problems were encountered while building the effective model for
 ::
[ERROR] [ERROR] 'modelVersion' is missing. @ [unknown-group-id]:[unknown-artifact-id]:[unknown-version]
[ERROR] [ERROR] 'groupId' is missing. @ [unknown-group-id]:[unknown-artifact-id]:[unknown-version]
[ERROR] [ERROR] 'artifactId' is missing. @ [unknown-group-id]:[unknown-artifact-id]:[unknown-version]
[ERROR] [ERROR] 'version' is missing. @ [unknown-group-id]:[unknown-artifact-id]:[unknown-version]
[ERROR] -> [Help 1]
[ERROR]

Thanks,
Gadi.

Tim Ward

unread,
Jan 4, 2017, 8:08:39 AM1/4/17
to bndtool...@googlegroups.com
Hi Gadi,

3.4.0.DEV builds are published as output from the Bndtools cloud bees build. Unfortunately that seems to have gone down for maintenance and not come back. The infrastructure owner is on US time, so hopefully will be able to work out how to get it back up soon. 

Tim

Sent from my iPhone

Tim Ward

unread,
Jan 4, 2017, 9:13:47 AM1/4/17
to bndtool...@googlegroups.com
The Bndtools cloud bees should be back up now.

Tim

Sent from my iPhone

Gadi Eichhorn

unread,
Jan 4, 2017, 9:15:10 AM1/4/17
to bndtools-users
Thanks Tim,

I don't get the refresh to work, is there a setup I am missing? 
I used the latest bnd maven plugins 3.4.0-SNAPSHOT (built locally)

Gadi.

David Daniel

unread,
Jan 4, 2017, 10:33:01 AM1/4/17
to bndtools-users
Also mentioned in the dev list a month back was an eclipse plugin for bndtools m2e integration that may help with updating on changes
repost below
---------------------------------------------------
Hey everyone,

So this work now has landed here. Thanks to BJ for all the review help.

This support is now available as a separate installable feature called "Bndtools m2e".  So naturally this requires m2e installed which is available by default from both Java and JavaEE distros of eclipse.  Or you can install m2e here if you are running another distro.

Here is the Bndtools Dev build url if you want to give it a try.  There is nothing you need to do to get this working other than import your Maven projects as usual that have 'bnd-maven-plugin' configured in the pom to execute in default lifecycle (the default setup).  If you already have the projects imported into eclipse, m2e should detect the new mapping after you restart Eclipse.

To confirm if it is properly configured (if you are trying this out) you can right click your maven project in Eclipse and go to "Properties > Maven > Lifecycle Mapping" and you should see that the 'bnd-process' goal is mapped to "extension/configurator".  Then you know this new integration is active.
-----------------------------------------------------------------------

Timothy Ward

unread,
Jan 4, 2017, 10:50:00 AM1/4/17
to bndtool...@googlegroups.com
It should be sufficient to install 3.4.0.DEV. This may need you to uninstall bndtools, restart Eclipse, install bndtools, and restart. p2 can be a bit rubbish :(.

As far as I’m aware it shouldn’t need you to use 3.4.0 plugins. Greg Amerson is the person who can tell you most - this feature has only been available for a few weeks.

Regards,

Tim

Christian Schneider

unread,
Jan 4, 2017, 5:52:00 PM1/4/17
to bndtool...@googlegroups.com
Strange .. I just did a build and it worked fine.

Did you build the project from top level?

Christian

Gadi Eichhorn

unread,
Jan 5, 2017, 9:37:55 AM1/5/17
to bndtools-users
Thanks David,

I have m2e plugin installed
I reloaded the project
I see the maven lifecycle mapping on the project
and I have maven lifecycle-mapping plugin in the root pom.xml 

something is missing... it doesn't fully work yet

I think I am missing the action options to make this work...

            <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>biz.aQute.bnd</groupId>
                                        <artifactId>
                                            bnd-maven-plugin
                                        </artifactId>
                                        <versionRange>
                                            [3.2.0,)
                                        </versionRange>
                                        <goals>
                                            <goal>bnd-process</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <execute></execute>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>

any suggestions?

regards,
Gadi.

Greg Amerson

unread,
Jan 5, 2017, 9:55:32 AM1/5/17
to bndtool...@googlegroups.com
Try removing the maven lifecycle-mapping plugin in the root pom.xml.  You don't need it.  The bndtools m2e plugin has all of the lifecycle-mapping information and the ones in the pom now conflict.  

If you still can't get it to work, do you have a github repo that you can share?  It is very likely that the new m2e integration has some gaps that still need to be filled.

Greg

To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Gadi Eichhorn

unread,
Jan 5, 2017, 10:15:31 AM1/5/17
to bndtools-users
Apologies Christian, it does work.
I had to remove my local maven repo and start from zero. no idea what went wrong but now it will build properly.

Gadi Eichhorn

unread,
Jan 5, 2017, 10:34:39 AM1/5/17
to bndtools-users
Thanks Greg,

That worked great!

To summarize this complex thread ;-)

1. I used the hello world example Tim suggested above ->  https://github.com/paremus/hello-examples/tree/master 
2. I installed the BNDTOOLS plugin 3.4.0.DEV and the m2e plugin included to have a better integration with maven and bndtools
3. I remove the specific maven lifecycle plugin definition from the root pom

Now to start the real work
Thanks to everyone for the great support.

Gadi.
Reply all
Reply to author
Forward
0 new messages