Automatic updates for bundle jars and eclipse m2e incremental build

50 views
Skip to first unread message

Matteo Rulli

unread,
Jan 14, 2017, 9:19:46 AM1/14/17
to bndtools-users
Hello!

I'm using the last snapshot both for bndtools and bnd maven plugins and I'm building a couple of projects using a pure maven approach. As a part of the projects I developed some integration tests that I'm able to execute either through "mvn install" or launching the correspondent bndrun file through the "Debug As -> Bnd OSGi Test Launcher (JUnit)" menu in eclipse.

The problem I have is that in eclipse incremental builds, m2e plugin does not build the projects JARs and it does not put them in local m2 repository: it only builds the classes within my project's target/classes folder in eclipse. This is rather unfortunate: due to this, to debug my projects through the "Debug As -> Bnd OSGi Test Launcher (JUnit)" menu I have to switch to a console first and run mvn install to get the latest changes I perform in the IDE.

On the other hand I read this thread. Apparently, if I got it correctly, we should already have a sort of automatic update for jars in m2 repo when we launch a bndrun file from eclipse. Why don't I see this happening in my m2e project? Is there any special configuration that must be specified in bnd/bndrun files or within the project pom? What I did is to specify the bnd-testing-maven-plugin in the itest projects pom and the bnd-maven-plugin in the parent pom. Besides, in the bndrun file I also use the MavenBndRepository plugin to stash some non-OSGi artifacts in bnd runpath.

Thanks for your help,
matteo

Greg Amerson

unread,
Jan 14, 2017, 3:36:13 PM1/14/17
to bndtool...@googlegroups.com
Hey Matteo,

Right with the latest Bndtools snapshot and if your bundle projects have the bnd-maven-plugin (3.0.0 or greater), then the "build the jar automatically as a part of Eclipse build" should be enabled.  

Do a quick sanity check and look at the "Project > Properties > Maven > Lifecycle mapping" and make sure that bnd-process is mapped to extension,configurator to make sure both are getting mapped correctly.  

If you aren't seeing this configured properly, next step is to make sure the bndtools.m2e bundle is installed and is in state "STARTING" in side of Eclipse's osgi console.  If that looks correct, then send me a git repo where you can reproduce the problem and I can take a look.

--
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-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



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

Matteo Rulli

unread,
Jan 14, 2017, 6:09:25 PM1/14/17
to bndtools-users
Thank you Gregory!
Following your hints it turned out I did not have the bndtools.m2e plugin installed. I updated bndtools from 3.3 and probably the update process did not add it. 

After uninstalling bndtools and installing it again everything worked! 

One more thing: in the bndtools projects I used to configure the "-buildrepo: <Maven-Local>" property in the bnd files in order to publish artifacts on maven local automatically. Is there the same possibility with the bndtools.m2e bundle? I tried putting the following config in my projects bnd files but apparently my jars in .m2/repository do not get automatically updated:

-plugin.maven  \

       aQute.bnd.repository.maven.provider.MavenBndRepository; \

       name=Local

-buildrepo: Local


Thank you again!

matteo
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.

Greg Amerson

unread,
Jan 16, 2017, 10:04:37 AM1/16/17
to bndtool...@googlegroups.com
Oh yeah I forgot to mention that.  The jars are not published automatically into .m2/repository with this new integration.  Only the jars in <project>/target/ folder get created on the fly.

Regarding your MavenBndRepository configured as your -buildrepo.  This instruction only makes sense in a Bnd/Gradle workspace, where Bnd is the main driver of the build (Project.build() is invoked by Bndtools Eclipse builder.  In your case, you have a maven workspace so Eclipse/M2e is in charge of the top level maven build, and maven/m2e doesn't know anything about bnd build instructions (-buildrepo:)

So likely you will need to install artifacts into your .m2/local in the normal maven way (mvn install).  

However, there is one way you could achieve what you want with Eclipse/m2e.  You can tweak the m2e lifecycle-mappings in Eclipse to map the "install:install" goal to be executed on incremental builds by m2e builder.  I've never personally tried it, but it should work.  You could add something like this below to you pom:

<pluginManagement>
  <plugins>
    <plugin>
     <groupId>org.eclipse.m2e</groupId>
     <artifactId>lifecycle-mapping</artifactId>
     <version>1.0.0</version>
     <configuration>
       <lifecycleMappingMetadata>
         <pluginExecutions>
           <pluginExecution>
             <pluginExecutionFilter>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-install-plugin</artifactId>
               <versionRange>[1.0.0,)</versionRange>
               <goals>
                 <goal>install</goal>
               </goals>
             </pluginExecutionFilter>
             <action>
               <execute>
                 <runOnConfiguration>true</runOnConfiguration>
                 <runOnIncremental>true</runOnIncremental>
</execute>          </action>        </pluginExecution>      </pluginExecutions>    </lifecycleMappingMetadata>  </configuration> </plugin> </plugins> </pluginManagement>

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.

Matteo Rulli

unread,
Jan 16, 2017, 5:33:29 PM1/16/17
to bndtools-users
Got it, thank you for the explanation Gregory. 
I think that providing a way to publish automatically bundles on maven local (without executing tests) could be helpful though, especially when it comes to different modules that consume the output of another module. What do you think?

Thank you again for your answers!
matteo

Timothy Ward

unread,
Jan 17, 2017, 4:16:07 AM1/17/17
to bndtool...@googlegroups.com
I think that this is a requirement for m2e, not for Bndtools. I would also disagree with any attempt to make this sort of change through Bndtools.

When you’re using maven to build (as you are in this case) Bnd and Bndtools are absolutely not in charge of the build, simply the behaviour of a small subset of Maven plugins. What you’re asking for a significant change to the Maven lifecycle, and it would fundamentally change what m2e needs to do. I have no idea how they would cope with having ignored some plugins when they have to write a “complete” jar into the Local Repository. Especially because this installed JAR may then persist for a long time (or even indefinitely). In any event it would be a huge over-reach for Bndtools to try to override this behaviour, and it would potentially break a lot of existing Eclipse users’ maven builds, just because they installed Bndtools!

Note that this is a totally different scenario from the Bnd workspace model, where Bnd/Bndtools *are* in charge of the build. At that point we absolutely can publish build outputs automatically (if configured to do so) because we are responsible for the build.

I hope this makes sense,

Regards,

Tim Ward

BJ Hargrave

unread,
Jan 17, 2017, 8:14:13 AM1/17/17
to bndtool...@googlegroups.com
+1
BJ

Christian Schneider

unread,
Jan 17, 2017, 10:40:22 AM1/17/17
to bndtool...@googlegroups.com
I agree that m2e should take care of publishing the jar to the local
maven repo.
It would be great to have this feature. I think this would also help
with developing for plain karaf. As karaf watches the local repo for
updates it would update the bundles.
So saving a java file would end in karaf getting the updated bundle.

Christian

On 17.01.2017 10:16, Timothy Ward wrote:
> I think that this is a requirement for m2e, not for Bndtools. I would
> also disagree with any attempt to make this sort of change through
> Bndtools.
>
> When you’re using maven to build (as you are in this case) Bnd and
> Bndtools are absolutely not in charge of the build, simply the
> behaviour of a small subset of Maven plugins. What you’re asking for a
> significant change to the Maven lifecycle, and it would fundamentally
> change what m2e needs to do. I have no idea how they would cope with
> having ignored some plugins when they have to write a “complete” jar
> into the Local Repository. Especially because this installed JAR may
> then persist for a long time (or even indefinitely). In any event it
> would be a huge over-reach for Bndtools to try to override this
> behaviour, and it would potentially break a lot of existing Eclipse
> users’ maven builds, just because they installed Bndtools!
>
> Note that this is a totally different scenario from the Bnd workspace
> model, where Bnd/Bndtools *are* in charge of the build. At that point
> we absolutely can publish build outputs automatically (if configured
> to do so) because we are responsible for the build.

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

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

Reply all
Reply to author
Forward
0 new messages