Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[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