Hi,
I am interested in using the Tycho plugin to resolve bundles, their dependencies, features, etc. from P2 repositories during a Maven run but before we have any projects loaded. Specifically, I would like to do this in an AbstractMavenLifecycleParticipant in the afterSessionStart call. where I only have an initial Maven session and the execution request. I am interested in setting up custom ClassRealm(s), registering components, extending the "maven-api" ClassRealm, etc with artifacts from P2 repositories and I am hoping that I can use Tycho as a P2 client to resolve and download all needed artifacts starting from a high level bundle, or from a feature.
I'm still trying to look through the Tycho code to understand how it works and by trial and error I was able to download an IU by doing the following in a Maven plugin for a project that has Tycho extensions enabled :
P2ResolverFactory rf = equinoxServiceFactory.getService(P2ResolverFactory.class);
TargetPlatformConfigurationStub stub = new TargetPlatformConfigurationStub();
try
{
stub.addP2Repository(new URI("http://download.eclipse.org/releases/kepler/"));
} catch (URISyntaxException e1)
{
e1.printStackTrace();
}
ExecutionEnvironmentConfigurationStub ee = new ExecutionEnvironmentConfigurationStub("");
PomDependencyCollector collector = rf.newPomDependencyCollector();
TargetPlatform tp = rf.getTargetPlatformFactory().createTargetPlatform(stub, ee, null,
collector);
P2Resolver resolver = rf.createResolver(new MavenLoggerAdapter(logger, getLog()
.isDebugEnabled()));
P2ResolutionResult rr = resolver.resolveInstallableUnit(tp,
"org.eclipse.rap.sdk.feature.feature.group", "[0.0.0,4.1.1.20130902-1345)");
for (Entry e : rr.getArtifacts())
{
System.out.println(e.getType());
for (Object o : e.getInstallableUnits())
{
System.out.println(o);
}
System.out.println(e.getLocation());
}