How can I use Eclipse p2 repositories from Maven?

烈酒焚心 提交于 2019-12-04 17:07:38
oberlies

Tycho projects can pull their dependencies from both p2 repositories and Maven repositories (see this related answer). This could be a solution for you, even if you are not building for an OSGi runtime: Most OSGi bundles also work as "plain" JARs on the classpath.

Limitation: The artifacts referenced from Maven repositories also have to be OSGi bundles, so that Tycho considers them for dependency resolution. If this is not the case (and you can't find replacements which are OSGi bundles), you may be able to combine Tycho's dependency resolution with plain Maven plug-ins:

  • Use one of Tycho's packaging types (e.g. eclipse-feature) and specify the dependencies to the p2 artifacts in the file format for the packaging type (e.g. a feature.xml)
  • Additionally configure the plain Maven goals in your POM. Tycho injects the OSGi/p2 dependencies into the Maven model at runtime, so for example a maven-compiler-plugin:compile call would see both the Maven dependencies and the p2 dependencies.

The solution is to create a multi module setup with Maven, and declare a dependency on the outputs of EMF library re-packaging (from the question I've referenced) The parent pom for all projects has this:

    <dependencies>
    <dependency>
        <groupId>com.mymodule</groupId>
        <artifactId>myartifact</artifactId>
        <version>0.0.1</version>
        <classifier>repackaged</classifier>                 
    </dependency>
  </dependencies>
      <modules>
            <module>../mymodule</module>
     </modules>

Which lets all modules that has this module as parents access the repackaged P2 artifacts.

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