Re: Bridging bndtools-m2e

173 views
Skip to first unread message

Greg Amerson

unread,
Dec 9, 2016, 1:53:14 AM12/9/16
to Peter Kriens, bndtoo...@googlegroups.com
First cut at this is done here: https://github.com/bndtools/bndtools/pull/1605  

If we all agree this is the right direction I can finish up this implementation (feature work, add tests, etc)

On Thu, Nov 17, 2016 at 9:21 AM, Peter Kriens <pkr...@gmail.com> wrote:
As we discussed during the wonderful Liferay event a few hints at what we could do with bndtools to make the life of m2e users better.

The bndrun files work very well based on the BndPomRepository. However, the missing piece is debugging with an M2E build. In Bndtools we have automatic updates during debugging but that does not happen in M2E.

In the Sling plugin, they hook into the build cycle and automatically load any bundles in the target framework.

I think we need a similar hook into the m2e build cycle. Slight complication is that m2e does not build a JAR, only the target/classes directory. In the bnd maven plugin we do not create the JAR but I guess we can assume this directory holds a faithful copy.

To make this as effective as possible I think we need to create a m2e workspace repository that is active in a bndrun file when it runs inside Eclipse/M2E.

So when we run a standalone bndrun inside Eclipse we need to inject an extra m2e repository. This m2e repository should listen to the workspace changes and use the repository API to inform bnd of changes. It should also jar the target/classes directory when there are changes.

Hmm, that should be all I think?

Ideas?

Kind regards,

        Peter Kriens



--
Greg Amerson
Liferay Developer Tools
Liferay, Inc. www.liferay.com

Greg Amerson

unread,
Dec 15, 2016, 2:25:15 PM12/15/16
to Peter Kriens, bndtoo...@googlegroups.com
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.

Inline image 1

The upshot of this integration is that during normal Eclipse incremental builder the actual real jars are getting built just like with Bnd workspaces.  So when you run your Bnd launches, any updates to your bundles get updated automatically in the running framework, just like you have come to expect.

If anyone is interested in a similar integration with maven-bundle-plugin let me know, as maven projects that use that plugin wont see this same behavior.  This integration is specifically tied to bnd-maven-plugin.  

Neil Bartlett

unread,
Dec 15, 2016, 2:51:51 PM12/15/16
to bndtoo...@googlegroups.com, Peter Kriens
This is excellent work, thank you Greg (and BJ).

Neil


On 15 Dec 2016, at 19:24, Greg Amerson <gregory...@liferay.com> wrote:

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.

<Screen Shot 2016-12-15 at 1.14.18 PM.png>

The upshot of this integration is that during normal Eclipse incremental builder the actual real jars are getting built just like with Bnd workspaces.  So when you run your Bnd launches, any updates to your bundles get updated automatically in the running framework, just like you have come to expect.

If anyone is interested in a similar integration with maven-bundle-plugin let me know, as maven projects that use that plugin wont see this same behavior.  This integration is specifically tied to bnd-maven-plugin.  

On Fri, Dec 9, 2016 at 12:52 AM, Greg Amerson <gregory...@liferay.com> wrote:
First cut at this is done here: https://github.com/bndtools/bndtools/pull/1605  

If we all agree this is the right direction I can finish up this implementation (feature work, add tests, etc)

On Thu, Nov 17, 2016 at 9:21 AM, Peter Kriens <pkr...@gmail.com> wrote:
As we discussed during the wonderful Liferay event a few hints at what we could do with bndtools to make the life of m2e users better.

The bndrun files work very well based on the BndPomRepository. However, the missing piece is debugging with an M2E build. In Bndtools we have automatic updates during debugging but that does not happen in M2E.

In the Sling plugin, they hook into the build cycle and automatically load any bundles in the target framework.

I think we need a similar hook into the m2e build cycle. Slight complication is that m2e does not build a JAR, only the target/classes directory. In the bnd maven plugin we do not create the JAR but I guess we can assume this directory holds a faithful copy.

To make this as effective as possible I think we need to create a m2e workspace repository that is active in a bndrun file when it runs inside Eclipse/M2E.

So when we run a standalone bndrun inside Eclipse we need to inject an extra m2e repository. This m2e repository should listen to the workspace changes and use the repository API to inform bnd of changes. It should also jar the target/classes directory when there are changes.

Hmm, that should be all I think?

Ideas?

Kind regards,

        Peter Kriens 



-- 
Greg Amerson
Liferay Developer Tools
Liferay, Inc. www.liferay.com



-- 
Greg Amerson
Liferay Developer Tools
Liferay, Inc. www.liferay.com

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

Timothy Ward

unread,
Dec 19, 2016, 5:29:27 AM12/19/16
to bndtoo...@googlegroups.com, Peter Kriens
Hi Greg,

This all sounds really awesome! I do have a question though…

The upshot of this integration is that during normal Eclipse incremental builder the actual real jars are getting built just like with Bnd workspaces.  So when you run your Bnd launches, any updates to your bundles get updated automatically in the running framework, just like you have come to expect.


What exactly do I need to do to get this behaviour? Do I need to set up my bndrun in a particular way? Will it work with the indexer plugin?

Regards,

Tim

Greg Amerson

unread,
Dec 19, 2016, 10:06:14 AM12/19/16
to bndtoo...@googlegroups.com, Peter Kriens
So you don't need to do anything to get this integration except for installing the new top level feature in Eclipse.  This feature only produces meaningful things when "Run" objects are created in bnd.  Right now that is during "Run as > OSGi" launches from bndrun is only turned on when you do a "Run as > OSGi" launch configuration from a bndrun file.  

As far as the bnd indexer plugin, can you point me to a canonical example of this and the workflow so I can run through it myself and I can see if a similar integration that we have with the BndConfigurator makes sense.

On Mon, Dec 19, 2016 at 4:29 AM, Timothy Ward <tim....@paremus.com> wrote:
Hi Greg,

This all sounds really awesome! I do have a question though…

The upshot of this integration is that during normal Eclipse incremental builder the actual real jars are getting built just like with Bnd workspaces.  So when you run your Bnd launches, any updates to your bundles get updated automatically in the running framework, just like you have come to expect.


What exactly do I need to do to get this behaviour? Do I need to set up my bndrun in a particular way? Will it work with the indexer plugin?

Regards,

Tim
On 15 Dec 2016, at 19:51, Neil Bartlett <njbar...@gmail.com> wrote:

This is excellent work, thank you Greg (and BJ).

Neil


On 15 Dec 2016, at 19:24, Greg Amerson <gregory...@liferay.com> wrote:

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.

<Screen Shot 2016-12-15 at 1.14.18 PM.png>

The upshot of this integration is that during normal Eclipse incremental builder the actual real jars are getting built just like with Bnd workspaces.  So when you run your Bnd launches, any updates to your bundles get updated automatically in the running framework, just like you have come to expect.

If anyone is interested in a similar integration with maven-bundle-plugin let me know, as maven projects that use that plugin wont see this same behavior.  This integration is specifically tied to bnd-maven-plugin.  

On Fri, Dec 9, 2016 at 12:52 AM, Greg Amerson <gregory.amerson@liferay.com> wrote:
First cut at this is done here: https://github.com/bndtools/bndtools/pull/1605  

If we all agree this is the right direction I can finish up this implementation (feature work, add tests, etc)

On Thu, Nov 17, 2016 at 9:21 AM, Peter Kriens <pkr...@gmail.com> wrote:
As we discussed during the wonderful Liferay event a few hints at what we could do with bndtools to make the life of m2e users better.

The bndrun files work very well based on the BndPomRepository. However, the missing piece is debugging with an M2E build. In Bndtools we have automatic updates during debugging but that does not happen in M2E.

In the Sling plugin, they hook into the build cycle and automatically load any bundles in the target framework.

I think we need a similar hook into the m2e build cycle. Slight complication is that m2e does not build a JAR, only the target/classes directory. In the bnd maven plugin we do not create the JAR but I guess we can assume this directory holds a faithful copy.

To make this as effective as possible I think we need to create a m2e workspace repository that is active in a bndrun file when it runs inside Eclipse/M2E.

So when we run a standalone bndrun inside Eclipse we need to inject an extra m2e repository. This m2e repository should listen to the workspace changes and use the repository API to inform bnd of changes. It should also jar the target/classes directory when there are changes.

Hmm, that should be all I think?

Ideas?

Kind regards,

        Peter Kriens 



-- 
Greg Amerson
Liferay Developer Tools
Liferay, Inc. www.liferay.com



-- 
Greg Amerson
Liferay Developer Tools
Liferay, Inc. www.liferay.com

-- 
You received this message because you are subscribed to the Google Groups "bndtools-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-dev+unsubscribe@googlegroups.com.

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

--
You received this message because you are subscribed to the Google Groups "bndtools-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-dev+unsubscribe@googlegroups.com.

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

--
You received this message because you are subscribed to the Google Groups "bndtools-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-dev+unsubscribe@googlegroups.com.

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



--

Raymond Auge

unread,
Dec 19, 2016, 10:09:29 AM12/19/16
to bndtools dev, Peter Kriens
Greg, Tim, as far as I can tell, it's working with the indexer. But you can try this repo:

https://github.com/rotty3000/liferay-cdi-osgi

- Ray
Raymond Augé (@rotty3000)
Senior Software Architect Liferay, Inc. (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance (@OSGiAlliance)

Timothy Ward

unread,
Dec 19, 2016, 10:51:46 AM12/19/16
to bndtoo...@googlegroups.com, Peter Kriens
Another simple example would be the Paremus hello sequence. The most basic one has a single bndrun used to create an application:

https://github.com/paremus/hello-examples/tree/hello-1.13.x

The bndrun is inside the helloworld-system folder.

https://github.com/paremus/hello-examples/blob/hello-1.13.x/helloworld/helloworld-system/src/main/resources/hello-app.bndrun

From what I’m hearing (and hoping) it sounds as though this will just work as is, but I’d like to be sure of the details to make sure I know what’s supposed to be supported :)

Thanks,

Tim


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

Greg Amerson

unread,
Dec 19, 2016, 12:22:56 PM12/19/16
to bndtoo...@googlegroups.com, Peter Kriens
Hey Tim,

Discussed a bit offline with Ray and I don't think this integration is going to give the indexes in your posted examples the 'real-time' feel that you may be expecting.  I.e. the indexes will not get rebuilt (mojos get invoked) as a part of the standard Eclipse build lifecycle.

Now we could do something like this (just talking out loud a bit here)

- during m2e project configuration(import/update of maven projects/poms) we look for projects that have 'bnd-indexer' or 'bnd-testing' plugins, projects that "care" about the index.  
- when we find interesting 'indexer' pom projects, we look at the dependency hierarchy of that project and see if any of the projects that its depends on are "eclipse workspace" projects that have bnd-process goal configured (where eclipse+bndtools m2e feature is going to be rebuilding those jars automatically)
- if we find such interesting "upstream" projects for an indexer pom, we register Eclipse resource change listeners, where we are looking for the jars from those projects to get rebuilt (by the new m2e integration that has already landed)
- once we see an upstream jar has changed, we execute the indexer mojo goal

This way your generated index is always getting updated automatically if any output jars from your current eclipse workspace projects change.  Right now I don't have any plan to send a PR for this right now, but just wanted to have it documented here in case me or someone else wants to pick up this work and send a PR.  

Timothy Ward

unread,
Dec 19, 2016, 12:28:58 PM12/19/16
to bndtoo...@googlegroups.com, Peter Kriens
Hi Greg,

Thanks for the detailed answer about what’s going on - it would be awesome to get this level of incremental rebuild for the indexes, but I can see why we’re not there yet. Am I right in saying, however, that a running bndrun would still pick up updates?

Specifically, if I am running the bndrun for my app and make a change to one of the bundle projects then will the bundle in the running framework get updated? I understand that the index will be out of sync for resolving (which is what your proposal would fix) but even so the overall experience would be a lot better than before your changes!

Regards

Tim

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

Greg Amerson

unread,
Dec 19, 2016, 12:31:53 PM12/19/16
to bndtoo...@googlegroups.com, Peter Kriens
Yes!  Now running bndrun from a maven project will now pick up the updates to the jars from the eclipse incremental build automatically.

Tim Ward

unread,
Dec 19, 2016, 12:34:46 PM12/19/16
to bndtoo...@googlegroups.com, Peter Kriens
That is already a lot more than I had hoped for in 3.4 :)

Tim
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-dev...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages