Kind regards,
Peter Kriens
Kind regards,
Peter Kriens
for most of my projects I use bndtools to maintain bnd.bnd. In the
maven pom I use maven-bundle-plugin whihc is than triggered by
jenkins.
Combining these two works like a charm.
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.0.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<_include>bnd.bnd</_include>
</instructions>
</configuration>
</plugin>
Regards,
Leen
Yes, supporting Nexus repositories is fairly simple. We can do it already using a Repository Plugin into bnd, but we will soon enhance it to use OBR metadata.
Regarding multi-bundle projects: if you are using Maven then you should stick with one output artefact per project. You will be continuously fighting Maven if you try to break this rule.
Could you clarify something here, please?
On 17 October 2011 08:40, Neil Bartlett <njbar...@gmail.com> wrote:
> recent versions of m2e include much better incremental builder
> support than older versions, even with plug-ins such as maven-bundle-plugin
> in use. Therefore m2e will take over the incremental building, so in
> Bndtools we need to detect that m2e is present and not perform the builds
> ourselves.
Do you just mean that m2e will take over incremental compilation? Or,
do you mean m2e will also be updating the manifest, and/or creating a
jar?
The reason I ask is that I haven't found a way to get m2e to run the
'process-classes' phase of the maven lifecycle, which is the phase to
which I have attached the bundle plugin.
> This leaves us with providing the bnd file editor, and running OSGi
> applications (including hot-replace of rebuilt bundles). We think we can do
> a much better job at managing runtimes using OBR, because Maven's model of
> runtime dependencies is badly broken.
Hmm. I'm not sure exactly why you say it's broken, but it's still
usable for assembling bundles in to a distributable runtime package.
I'd be a little worried about having bndtools determine the runtime
jars during development, only to have maven pick a different set for
offline builds.
(One solution to that, perhaps, would be to have an OBR-aware maven
plugin that packages up the runtime bundles.)
Martin
On Monday, 17 October 2011 at 11:24, Martin Ellis wrote:
Do you just mean that m2e will take over incremental compilation? Or,
do you mean m2e will also be updating the manifest, and/or creating a
jar?
The reason I ask is that I haven't found a way to get m2e to run the
'process-classes' phase of the maven lifecycle, which is the phase to
which I have attached the bundle plugin.
Hmm. I'm not sure exactly why you say it's broken, but it's still
usable for assembling bundles in to a distributable runtime package.
I'd be a little worried about having bndtools determine the runtime
jars during development, only to have maven pick a different set for
offline builds.
Aha. That sounds very useful. I'll keep an eye out.
> Maven just doesn't have a good model of runtime dependencies… they are based
> on whole module dependencies (similar to Require-Bundle) and they must be
> maintained manually in the POMs, which means they can easily get out of sync
> with reality and often require dragging down far more dependencies than are
> really necessary. In other words… broken.
I didn't say it was good, I said it was usable. ;o)
I think there are still benefits to using OSGi, even with Maven's
limited model of dependencies. You might ask "why use Maven for
dependencies?", but for us, it seems like the best path at the moment.
We can build everything with Maven, but not everything we have can
based on OSGi (e.g. we have Sonar and Maven plugins).
> Please clarify the second sentence; are you talking about builds or runtime?
> Bndtools will not interfere at all with the build-time dependencies, whether
> offline, command line or in the IDE.
Um... Consider a maven project that creates an assembly including an
OSGi framework, and a bunch of bundles. The version of those bundles
is specified (explicitly or implicitly) in the pom.xml files. All
bundles in the assembly are intended to be used at runtime.
I was worried whether a situation could arise in which bndtools starts
up a framework with a different set of bundle versions as compared to
the versions that were included in that assembly. That is, whether
the bundle versions included in the built product might differ to the
resolution calculated by bnd (which might be more 'accurate' in an
OSGi sense).
Martin
> Hi all,
>
> On the OSGi blog Peter mentions some work on integrating BndTools with
> Maven (m2-eclipse) during the hackaton. I'd like to know if there is a
> release date for these changes.
The changes to m2eclipse are already available in version 0.6.0.201110151902 of the m2e-tycho configurator from the m2e catalog.
You can see if this version is installed by looking at the About Eclipse->Installation Details->Installed Software page.
If it's not installed go to Preferences->Maven->Discovery->Open Catalog, find the Tycho entry, select the checkbox and press Finish.
Then make sure the rest of m2e is up-to-date by using Help->Check For Updates.
Note: the m2e-tycho configurator is also installed when you import an existing Maven project that uses the maven-bundle-plugin. During the import wizard there should be a page called "Setup Maven plugin connectors" with a list of Maven plugins with red/green markers. If you click the "Auto Select" button it should schedule installation of the m2e-tycho configurator.
The recent improvement in m2e (thanks to Igor Fedorenko) was automatic regeneration of the manifest when the bnd instructions in the Maven pom change, or when a bnd file included from the Maven pom changes. This, coupled with Igor's previous work integrating the Maven and Eclipse/PDE backends, means you can develop OSGi bundles incrementally in Eclipse while still being able to drop to the command-line and get the same results from Maven.
To get the best results you should also use the latest 2.4.0-SNAPSHOT of the maven-bundle-plugin (http://www.mail-archive.com/us...@felix.apache.org/msg11255.html) and add <unpackBundle>true</unpackBundle> to the configuration section of the maven-bundle-plugin (ie. outside of the instructions). This setting will make sure that any bnd generated resources, such as declarative services xml, will be unpacked and made available to PDE whenever the manifest or bundle is regenerated.
You can then incrementally develop DS components using Java annotations (http://www.aqute.biz/Blog/20091020) and have m2e/bnd keep the generated XML up-to-date (discussed under https://issues.apache.org/jira/browse/FELIX-3170).
I'll try to find time over the next week or so to put together a video to demonstrate this - but feel free to try out the latest m2e and especially the bundleplugin snapshot.
--
Cheers, Stuart
Hi,Thx for the reply,As I am not familiar with m2-eclipse, does all of this also work with Maven from the commandline?
If needed, I can help testing.
> Hi,
>
> for most of my projects I use bndtools to maintain bnd.bnd. In the
> maven pom I use maven-bundle-plugin whihc is than triggered by
> jenkins.
>
> Combining these two works like a charm.
>
> <plugin>
> <groupId>org.apache.felix</groupId>
> <artifactId>maven-bundle-plugin</artifactId>
> <version>2.0.0</version>
> <extensions>true</extensions>
> <configuration>
> <instructions>
> <_include>bnd.bnd</_include>
> </instructions>
> </configuration>
> </plugin>
Yes this is a good approach, and with the latest m2e installed it should regenerate the manifest whenever you change the instructions in bnd.bnd from Eclipse.
Hi,Interesting solution :). How does all of this relate to dependency management used in Maven? Although I can agree with the objections, we use a Maven repository (Nexus) and this is one of the parts of the process I cannot change.
Nexus is used to retrieve dependencies, but also to release artifacts. Is this possible using maven+bndtools?Also, Maven uses a model in which one project is one bundle, can this be ignored using maven+bndtools? Having a separate (no 1 to 1 relation) development model and deployment models makes much more sense.
Thanks for the reply.2011/10/17 Neil Bartlett <njbar...@gmail.com>Yes, supporting Nexus repositories is fairly simple. We can do it already using a Repository Plugin into bnd, but we will soon enhance it to use OBR metadata.I have used the repository plugin, and for using artifacts this was ok, but at that time it was not yet possible to upload to Nexus, has this changed recently?
> Hi Neil,
>
> Could you clarify something here, please?
>
> On 17 October 2011 08:40, Neil Bartlett <njbar...@gmail.com> wrote:
>> recent versions of m2e include much better incremental builder
>> support than older versions, even with plug-ins such as maven-bundle-plugin
>> in use. Therefore m2e will take over the incremental building, so in
>> Bndtools we need to detect that m2e is present and not perform the builds
>> ourselves.
>
> Do you just mean that m2e will take over incremental compilation? Or,
> do you mean m2e will also be updating the manifest, and/or creating a
> jar?
The way it works in the latest m2e is that Eclipse handles the incremental compilation, and the m2e-tycho configurator updates the manifest as/when required. Because m2e uses the Eclipse/PDE launcher, which expects unpacked bundles, then we don't need to always rebuild the jar. But you could request a full build by using the "Run As... mvn install" command. And with the latest maven-bundle-plugin snapshot you can ask it to selectively unpack generated resources when the manifest is regenerated, which is useful if you're using bnd to generate declarative services XML.
> The reason I ask is that I haven't found a way to get m2e to run the
> 'process-classes' phase of the maven lifecycle, which is the phase to
> which I have attached the bundle plugin.
That should be handled transparently using the latest m2e (from Eclipse Marketplace) ... just import your Maven project and use "Auto Select" on the "Setup Maven Plugin Connectors" page to install the m2e-tycho configurator. It should be able to handle executions of the maven-bundle-plugin at any stage of the lifecycle, just like CLI Maven.
>> This leaves us with providing the bnd file editor, and running OSGi
>> applications (including hot-replace of rebuilt bundles). We think we can do
>> a much better job at managing runtimes using OBR, because Maven's model of
>> runtime dependencies is badly broken.
>
> Hmm. I'm not sure exactly why you say it's broken, but it's still
> usable for assembling bundles in to a distributable runtime package.
> I'd be a little worried about having bndtools determine the runtime
> jars during development, only to have maven pick a different set for
> offline builds.
You can get that sort of fidelity with m2e and the maven-bundle-plugin, just don't add the bndtools classpath nature (we're still working on how this will participate with m2e). Our goal is to allow people to use the bndtools editors even if they don't want to use its repository/obr driven classpath.
The new bndtools will act similar to PDE; warn you that the package you
are using is not in your imports, and even offer a quick fix :-)
After you save the file, the java builder does an incremental build, and
bnd will regenerate the manifest (through the bundle plugin).
Isn't it great? ;-)
We're working hard at fixing up the last issues before release, please
be patient.
--
Ferry Huberts
The changes to m2eclipse are already available in version 0.6.0.201110151902 of the m2e-tycho configurator from the m2e catalog.
You can see if this version is installed by looking at the About Eclipse->Installation Details->Installed Software page.
If it's not installed go to Preferences->Maven->Discovery->Open Catalog, find the Tycho entry, select the checkbox and press Finish.
Then make sure the rest of m2e is up-to-date by using Help->Check For Updates.
Note: the m2e-tycho configurator is also installed when you import an existing Maven project that uses the maven-bundle-plugin. During the import wizard there should be a page called "Setup Maven plugin connectors" with a list of Maven plugins with red/green markers. If you click the "Auto Select" button it should schedule installation of the m2e-tycho configurator.
The recent improvement in m2e (thanks to Igor Fedorenko) was automatic regeneration of the manifest when the bnd instructions in the Maven pom change, or when a bnd file included from the Maven pom changes. This, coupled with Igor's previous work integrating the Maven and Eclipse/PDE backends, means you can develop OSGi bundles incrementally in Eclipse while still being able to drop to the command-line and get the same results from Maven.
To get the best results you should also use the latest 2.4.0-SNAPSHOT of the maven-bundle-plugin (http://www.mail-archive.com/us...@felix.apache.org/msg11255.html) and add <unpackBundle>true</unpackBundle> to the configuration section of the maven-bundle-plugin (ie. outside of the instructions). This setting will make sure that any bnd generated resources, such as declarative services xml, will be unpacked and made available to PDE whenever the manifest or bundle is regenerated.
This is very welcome news, indeed! :o)
Martin
> Hi Stuart!
>
> This is a very nice development. Just a clarification though, does
> this
> help when I use ``unimported'' packages in my code, i.e will it
> trigger
> manifest regeneration?
>
> As you might remember, I'm using maven-bundle-plugin with M2E and in
> fact we rarely change bnd instructions (basically, all bundles simply
> say don't export internal, and import whatever you need).
>
> What we need though is the regeneration of the manifest when we start
> using ``unimported'' API during development, because currently we have
> to do a mvn package manually to regenerate (and extract) the manifest
> or
> we get NCDFEs at runtime.
>
> If am I understanding right, the m2e-tycho-configurator doesn't do
> anything about this use case, but that's where BndTools' interaction
> with M2E will kick in. Please confirm :)
When you save the file JDT will do an incremental build and notify the m2e-tycho-configurator. The tycho configurator requests a manifest regeneration via the maven-bundle-plugin, using the configuration from the pom.xml (and any included bnd files). Eclipse will then pick up this new manifest when launching the application, etc. You can use the "PDE Tools->Open Manifest" menu option to view the manifest - it might not show up in the package explorer as it's a generated/derived file. Also note that the jar won't get updated on every incremental build, but you can request that with "Run As...->Maven install".
The part we still need to work on is the behaviour when both bndtools and m2e natures are attached to a project, because you'll typically want the bndtool editors but not necessarily its buildpath container (since that's already provided by m2e).
> Hi Neil,
>
> In that case, if I'm not mistaken, one would have to copy/paste or
> write down the import statement before running into that situation.
> This is useful when updating/changing the build for an existing
> project where the code is already written and supposedly valid, but in
> my experience when an import is not resolved by JDT's "Organize
> Imports" it is quicker to simply go add the bundle to your -buildpath
> or Maven dependencies manually, where we have editors with UIs with
> filtering/completion, and call the magical Ctrl-Shift-O after :-).
>
> For the record, that quickfix already exists in M2E ("Find artifact
> exporting package" or something along these lines) but I've yet to see
> it work ;).
Yes, that's still being worked on - you can use the "Maven->Add dependency" menu item to search for dependencies by group/artifact, etc. Just remember to use Ctrl-Space in the various fields to get context completion rather than hit return, which will just close the dialog. I don't believe it suggests dependencies based on missing packages, but that is something that could be added in the future via the Maven index. In fact there was a recent update to the index to add OSGi metadata like Bundle-SymbolicName, etc. which would also be useful when locating OSGi dependencies to add to your pom.xml.
Hi Stuart,Thanks for the extensive replies, see some questions inline:The changes to m2eclipse are already available in version 0.6.0.201110151902 of the m2e-tycho configurator from the m2e catalog.
You can see if this version is installed by looking at the About Eclipse->Installation Details->Installed Software page.
If it's not installed go to Preferences->Maven->Discovery->Open Catalog, find the Tycho entry, select the checkbox and press Finish.
Then make sure the rest of m2e is up-to-date by using Help->Check For Updates.I've installed the latest version according to my 3.7.0 Eclipse.Tycho Configurator: 0.6.0... (as mentioned above)m2e: 1.0.100maven-bundle-plugin: 2.4.0-SNAPSHOT
In a new workspace I've created a maven project (without BndTools for now), and added one simple example.
Note: the m2e-tycho configurator is also installed when you import an existing Maven project that uses the maven-bundle-plugin. During the import wizard there should be a page called "Setup Maven plugin connectors" with a list of Maven plugins with red/green markers. If you click the "Auto Select" button it should schedule installation of the m2e-tycho configurator.
I have no existing projects to test this with, creating a new project and adding the maven-bundle-plugin should work equally? I think I still have to add the tycho plugin, but can't find out how to do this. Is this needed, if so how? Some examples on the web show a plugin entry, but using those resulted in errors. I must be overlooking something simple somewhere..
The recent improvement in m2e (thanks to Igor Fedorenko) was automatic regeneration of the manifest when the bnd instructions in the Maven pom change, or when a bnd file included from the Maven pom changes. This, coupled with Igor's previous work integrating the Maven and Eclipse/PDE backends, means you can develop OSGi bundles incrementally in Eclipse while still being able to drop to the command-line and get the same results from Maven.
Is this in the version of Tycho/M2e which I am using? Or should I install some development build? If so, where can I find these? I tried to use the milestone update site as explained on [1], but that resulted in an error (no update site at that location?).
If this is already in the current version, is there something I need to enable? I am not seeing the automatic updates, while building through maven works.
To get the best results you should also use the latest 2.4.0-SNAPSHOT of the maven-bundle-plugin (http://www.mail-archive.com/us...@felix.apache.org/msg11255.html) and add <unpackBundle>true</unpackBundle> to the configuration section of the maven-bundle-plugin (ie. outside of the instructions). This setting will make sure that any bnd generated resources, such as declarative services xml, will be unpacked and made available to PDE whenever the manifest or bundle is regenerated.
How can I test and verify this behavior?
The simplest approach is to create a Maven project, either by hand or using the "quickstart" archetype. Then change the packaging to be "bundle" and make sure you have the maven-bundle-plugin in the pom.xml (or a parent pom) with <extensions>true</extensions> so it picks up the bundle lifecycle. The default bundleplugin settings will create a valid OSGi bundle, but you can customise them as necessary. For example, if you want to put your bnd instructions in a file called "bnd.bnd" your pom.xml might look like:
Note also that the jar file won't update for incremental builds - only the manifest, which you can view from Eclipse by using "PDE Tools->Open Manifest"
I'll try to put together a simple example for distribution, but basically just create a new Java class with "@aQute.bnd.annotation.component.Component" on the type and put "Service-Component: *" in your bnd instructions. That should be enough to trigger bnd to generate DS XML, which will then be unpacked automatically - as long as you have the <unpackBundle>true</unpackBundle> setting in your bundleplugin configuration as shown above.
2011/10/18 Stuart McCulloch <mcc...@gmail.com>The simplest approach is to create a Maven project, either by hand or using the "quickstart" archetype. Then change the packaging to be "bundle" and make sure you have the maven-bundle-plugin in the pom.xml (or a parent pom) with <extensions>true</extensions> so it picks up the bundle lifecycle. The default bundleplugin settings will create a valid OSGi bundle, but you can customise them as necessary. For example, if you want to put your bnd instructions in a file called "bnd.bnd" your pom.xml might look like:Thanks for the example, besides some minor changes this is basically the same as what I created.Note also that the jar file won't update for incremental builds - only the manifest, which you can view from Eclipse by using "PDE Tools->Open Manifest"This is what I was looking for! :). So if I understand it correctly, m2e will only take care of updating the manifest file, in combination with BndTools, does BndTools recreate the actual bundle?
I'll try to put together a simple example for distribution, but basically just create a new Java class with "@aQute.bnd.annotation.component.Component" on the type and put "Service-Component: *" in your bnd instructions. That should be enough to trigger bnd to generate DS XML, which will then be unpacked automatically - as long as you have the <unpackBundle>true</unpackBundle> setting in your bundleplugin configuration as shown above.I've created a small example with a simple bnd file, using the PDE Tools the Manifest can be checked, and it is updated automatically.Now on to added BndTools. Is it best to wait for the new release? Or can I build it myself/download a developer build somewhere?
Actually you shouldn't need to package the full bundle when working in Eclipse, because the built-in launcher can work with unpacked bundles (other OSGi runtimes should also be able to handle directory-based bundles). So m2e will keep the manifest up to date as you work, and you can choose launch/test your code using either the "OSGi framework" or "Eclipse application" run configurations (assuming you don't have bndtools installed). If you do need the actual bundle jar, you can use the "Run As...->Maven install" menu item to package and install it.We're still working on bndtools integration wrt. launching; this might require us to package the bundle first (but not on every incremental build, just when launching).
You can build bndtools locally - http://bndtools.org/doc/development/ - just be aware that things are moving quite fast at the moment, so expect the occasional disruption.At some point we'll have a stable preview build available from a separate update site.