How to use directory containing third party bundles in a Tycho build
Asked Answered
A

4

12

In the past, we had our bundles and features on the file system and made them available in Eclipse through a target definition file with a 'Directory' location. In this way, it was easy to use them with the Export wizards in Eclipse.

Now I'm trying to build an eclipse-plugin with Tycho which has third party dependencies, e.g. javax.vecmath and org.apache.commons.math.

From what I know, the best way to obtain the dependencies in a Tycho build is through a p2 repository. So I'm using one for the Eclipse bundles. But for my third-party bundles, it seems that there is no p2 repository available.

So my question is: How do I easily get the JARs (vecmath, commons-math) into a p2 repository?

I thought I could build a p2 repository with Tycho, but how to do this when I can't access the third-party bundles in Tycho? I tried to use a target definition, but Tycho only supports links to p2 repositories, and not directories or installations. So are there other ways to use my third-party dependencies in a Maven/Tycho build?

Annalist answered 7/11, 2012 at 10:54 Comment(0)
B
0

According to your question, the third party dependencies are already bundles. This is good – all that is left to do is to generate p2 metadata for the bundles.

This can be done easily through the Features and Bundles Publisher application. The result is a p2 repository. Obviously, you don't want that all your developers have to do this locally in order to run the Tycho build, so you should put the result of the publisher application onto a web server. Then, reference the bundles via an http URL in the target file of your project.

Bigner answered 7/11, 2012 at 12:5 Comment(4)
That was the easiest and fastest way, to create a p2 repo. thanks everybody.Annalist
I disagree. You have to generate the site manually and if the jars are not bundles you have to "bundle" them yourself. All of that is mundane, cumbersome and could be easily automated using the p2-maven-plugin (that is mentioned below). I am the author of p2-maven-plugin and I coded it only because I found it really cumbersome to use the "Features and Bundles Publisher Application". Try p2-maven-plugin and you will see it's muuuuch easier than anything else: github.com/reficio/p2-maven-pluginHomovec
Yep, I agree the p2-maven-plugin looks like the best solution. Dealing with third-party dependencies in Eclipse/RCP projects really is such a pain. Looks like p2-maven-plugin can reduce this pain significantly to just maintaining a list somewhere and publishing a p2 update site from CI build so we can use it in all our tycho builds.Huffish
If the jars are not bundles ... - In the scenario described in the question, the third-party JARs were used via a target definition directory, so they are already bundles. Don't blame me if the question doesn't match your scenario.Bigner
P
12

A few different options...

P2 plugin

Use p2-maven-plugin to wrap all your non-OSGi dependencies into bundles, and create a p2 repository.

I haven't tried p2-maven-plugin (it didn't exist when I was setting up my current project). Its implementation is based on tycho, but you may find it provides a more convenient way to solve your problem than just the tycho plugins on their own.

Bundle plugin

Use maven-bundle-plugin to wrap your non-OSGi dependencies (one wrapper pom per dependency), and install it into your repository. I think commons-math is already a dependency, so you might just need to wrap vecmath. You could then list those dependencies in the <dependencies> of your tycho-based pom files.

This approach has the advantage that you don't need to set up a p2 repository just to build your project. The disadvantage is that managing dependencies in your bundle projects is no longer a case of just modifying the MANIFEST.MF file: you might also need to update the pom too.

Bundle plugin and Tycho

If you use the Bundle plugin approach to wrapping your dependencies into OSGi bundles, it may still be useful to set up a p2 repository for those dependencies anyway, as this simplifies setting up the target platform in Eclipse PDE.

To do this, you can create a new tycho-based project to collect the dependencies into a p2 repository: that is, the dependencies that are already bundles, together with the wrapped versions of the non-OSGi dependencies. This way, the project that creates the p2 repository lists the wrapped dependencies in its pom, and your bundle projects can consume the p2 repository without listing any dependencies in their poms.

This is the approach I am using. Specifically, I am using an eclipse-feature project to define a base feature which includes all the third-party dependencies. I also have the <deployableFeature> configuration option on the packaging plugin set to true, which will create a p2 repository in the target directory. This feature can be installed into my usual Eclipse instance, which makes it easy to use the current Eclipse platform as the target platform. It can also be used as a p2 repository that can be used elsewhere in the tycho build (i.e. by my code), or as a repository in an Eclipse .target file.

The eclipse-feature seemed to be the best packaging type in Tycho 0.13.0. There may be a more appropriate packaging type in more recent versions.

Paragraphia answered 7/11, 2012 at 11:17 Comment(1)
This answer rather answers this question: https://mcmap.net/q/1009924/-using-maven-dependencies-on-eclipse-plug-ins/1523648Bigner
W
2

a good place to look for 3rd party bundle jars in p2 repos is eclipse orbit

http://download.eclipse.org/tools/orbit/downloads/

commons.math is in there.

If your 3rd party OSGi bundle is not available in a p2 repo, but in a maven repo such as

http://search.maven.org/

you may use tycho's pomDependency=consider switch:

http://wiki.eclipse.org/Tycho/How_Tos/Dependency_on_pom-first_artifacts

Wheat answered 7/11, 2012 at 15:17 Comment(1)
I found orbit already a few minutes ago, it's really convenient. The other advice looks interesting, thanks.Annalist
B
0

According to your question, the third party dependencies are already bundles. This is good – all that is left to do is to generate p2 metadata for the bundles.

This can be done easily through the Features and Bundles Publisher application. The result is a p2 repository. Obviously, you don't want that all your developers have to do this locally in order to run the Tycho build, so you should put the result of the publisher application onto a web server. Then, reference the bundles via an http URL in the target file of your project.

Bigner answered 7/11, 2012 at 12:5 Comment(4)
That was the easiest and fastest way, to create a p2 repo. thanks everybody.Annalist
I disagree. You have to generate the site manually and if the jars are not bundles you have to "bundle" them yourself. All of that is mundane, cumbersome and could be easily automated using the p2-maven-plugin (that is mentioned below). I am the author of p2-maven-plugin and I coded it only because I found it really cumbersome to use the "Features and Bundles Publisher Application". Try p2-maven-plugin and you will see it's muuuuch easier than anything else: github.com/reficio/p2-maven-pluginHomovec
Yep, I agree the p2-maven-plugin looks like the best solution. Dealing with third-party dependencies in Eclipse/RCP projects really is such a pain. Looks like p2-maven-plugin can reduce this pain significantly to just maintaining a list somewhere and publishing a p2 update site from CI build so we can use it in all our tycho builds.Huffish
If the jars are not bundles ... - In the scenario described in the question, the third-party JARs were used via a target definition directory, so they are already bundles. Don't blame me if the question doesn't match your scenario.Bigner
B
0

Here is an actual example how you can do this: https://github.com/skosmalla/generate-p2-repository-from-maven-artifacts

Buyers answered 25/3, 2014 at 6:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.