eclipsemavenp2tycho

How can I use Eclipse p2 repositories from Maven?


I am trying to create an Eclipse based setup where Eclipse projects are Maven based. So it should all work with Maven whether or not Eclipse is used.

I have a dependencies on various Eclipse project libraries, with more to be added. I want to use p2 repositories, and I've managed to pull an Eclipse EMF library and turn it into a jar following this example: Use dependencies from Eclipse p2 repository in a regular Maven build?

The problem is, I could not find a way of streamlining the process. I'd need to manually install the re-packaged dependency from the question given above to local Maven repository so that I can reference that in other projects. I'd like to seamlessly integrate artefacts from p2 repositories to my Maven based setup. m4e does not look like the smooth solution I'm looking for: Ideally I'd like to distribute a set of directories which would do everything in response to a simple mvn clean install : pull libraries from p2 repo, pull other libraries from Maven repositories etc..

Is this doable via Maven and Tycho integration?

Update: first, clarification to the question: just being able to reference to P2 repositories does not help with the scenario where this reference needs to be used from another project. The library (or libraries) referenced from P2 repository must be re-packaged as a jar so that it can be referenced by other Maven projects. The referenced question does the packaging. However, it does not explain how this repackaged output (assembly) can be used from other projects. In my case, this turned out to be referencing the assembly from an aggregating POM, and inheriting form that POM for all projects that would like to use the library with the P2 repository origin.


Solution

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