Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tycho-dev] java.lang.ClassCastException: TargetPlatformBuilderImpl cannot be cast to P2TargetPlatform

are you explicitly invoking a mojo goal on the commandline, such as

mvn org.eclipse.tycho.extras:tycho-version-bump-plugin:update-product


explicit mojo goals without version resolve to the latest *released* version, i.e. 0.14.0.

Now if you invoke this on a pom.xml which registers the tycho build extension in another version, e.g.


this will lead to class loading conflicts as the build extension artifacts (which are also used by the mojo above) are hooked into the maven classloader hierarchy at low level.

So make sure you use the same version consistently everywhere, e.g. by using 

mvn org.eclipse.tycho.extras:tycho-version-bump-plugin:0.15.0-SNAPSHOT:update-product


From: tycho-dev-bounces@xxxxxxxxxxx [mailto:tycho-dev-bounces@xxxxxxxxxxx] On Behalf Of Mickael Istria
Sent: Dienstag, 22. Mai 2012 16:15
To: tycho-dev@xxxxxxxxxxx
Subject: [tycho-dev] java.lang.ClassCastException: TargetPlatformBuilderImpl cannot be cast to P2TargetPlatform


I am trying to write the plugin requested here: to validate .target files.
I started by imitating what is done on tycho-version-bump-plugin to read and resolve target platforms:

==== CODE ====
 this.factory = this.equinox.getService(P2ResolverFactory.class);
 this.p2 = this.factory.createResolver(new MavenLoggerAdapter(this.logger, false));
 resolutionContext = this.factory.createTargetPlatformBuilder(null, false);
 TargetDefinitionFile target =;
 resolutionContext.addTargetDefinition(target, this.environment);
 P2ResolutionResult result = this.p2.resolveMetadata(resolutionContext, this.environment.get(0));
==== END CODE ====

but this return me the following:
java.lang.ClassCastException: cannot be cast to org.eclipse.tycho.artifacts.p2.P2TargetPlatform
    at org.eclipse.tycho.p2.impl.resolver.P2ResolverImpl.resolveMetadata(
    at org.eclipse.tycho.extras.tpvalidator.TPValidationMojo.validateTarget(
==== END OUTPUT ====

By looking at code, there is indeed a cast from TargetPlatformBuilder to P2TargetPlatform, but I don't understand how it is supposed to work. Could you please provide me some insight about this issue?
Mickael Istria
Eclipse developer at JBoss, by Red Hat
My blog - My Tweets

Back to the top