|Re: [tycho-user] Make a maven-plugin that consumes p2 API|
On 12-02-14 4:52 AM, Mickael Istria wrote:
On 02/13/2012 11:21 AM, Mickael Istria wrote:
I tried to find an existing Service in Tycho that would return me a model of the repository to query it, but this does not exist. Then I have 2 questions:
three questions :-)
* Can I consume p2 API in my Mojo? I'd basically just like to get a IMetadataRepository. If yes, how?
No, you cannot consume P2 API directly from a mojo. All equinox/p2 code runs in a separate classloader space, which is not directly visible from Maven classloaders. Service interfaces server as a bridge between Maven/Tycho and Equinox/P2 classloader spaces and is the only way I was able to find to execute P2 code from Maven.
* Do I HAVE TO create a service to get an IMetadataRepository?
Yes, you do. See above.
* Is it possible/easy to create my own service? TychoP2RuntimeLocator has a static list of packages exported, and its containing jar has a static list of depdendencies...
This is either tricky or not possible at all. You can implement TychoP2RuntimeMetadata component interface to contribute additional jars to Tycho embedded equinox runtime. You have to use plugin/dependency element to add the jar with TychoP2RuntimeMetadata to tycho-maven-plugin classloader. It is currently not possible to introduce additional system packages, but it should be easy enough to extend TychoP2RuntimeMetadata to allow that. I will be willing to review and commit this change. In order to use the new services, however, you need to convince Maven to link your mojo to service api classes from tycho-maven-plugin classloader. For standard Tycho classes this is done with META-INF/maven/extension.xml. You maybe able to use ClassRealmManagerDelegate to force Maven link your mojo to the right classloader, but I have not tried this myself. -- Regards, Igor
Back to the top