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 ?

Jeff


On Tue, Mar 4, 2014 at 9:01 PM, Shahim Essaid <shahim@xxxxxxxxxx> wrote:
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());
        }


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.

Best,
Shahim

_______________________________________________
tycho-user mailing list
tycho-user@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/tycho-user




--
Jeff MAURY


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

http://www.jeffmaury.com
http://riadiscuss.jeffmaury.com
http://www.twitter.com/jeffmaury

Back to the top