Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tycho-user] Using Tycho P2 repository functionality while a Maven session is being setup

Why do you need extra work where Tycho does the same kind of job ?


On Tue, Mar 4, 2014 at 9:01 PM, Shahim Essaid <shahim@xxxxxxxxxx> wrote:

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();
            stub.addP2Repository(new URI(""));
        } catch (URISyntaxException e1)
        ExecutionEnvironmentConfigurationStub ee = new ExecutionEnvironmentConfigurationStub("");
        PomDependencyCollector collector = rf.newPomDependencyCollector();

        TargetPlatform tp = rf.getTargetPlatformFactory().createTargetPlatform(stub, ee, null,

        P2Resolver resolver = rf.createResolver(new MavenLoggerAdapter(logger, getLog()

        P2ResolutionResult rr = resolver.resolveInstallableUnit(tp,
                "", "[0.0.0,");

        for (Entry e : rr.getArtifacts())
            for (Object o : e.getInstallableUnits())

Not sure if all these steps are needed but I was just trying to get something working. Also, this is in a plugin but I would like to do this in a AbstractMavenLifecycleParticipant.  I will have the Tycho Jars loaded in a custom ClassRealm that is setup in the same participant so this is not my real problem.

Is there some documentation that can help me with my use case, maybe some test cases? Any pointers or pseudocode will be greatly appreciated.


tycho-user mailing list


"Legacy code" often differs from its suggested alternative by actually working and scaling.
 - Bjarne Stroustrup

Back to the top