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

青春壹個敷衍的年華 提交于 2019-12-04 00:38:01

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.

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.

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!