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

Hello,

I am trying to write the plugin requested here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=378987 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 = TargetDefinitionFile.read(targetFile);
 resolutionContext.addTargetDefinition(target, this.environment);
 P2ResolutionResult result = this.p2.resolveMetadata(resolutionContext, this.environment.get(0));
==== END CODE ====

but this return me the following:
==== OUTPUT EXCEPTION ====
java.lang.ClassCastException: org.eclipse.tycho.p2.target.TargetPlatformBuilderImpl cannot be cast to org.eclipse.tycho.artifacts.p2.P2TargetPlatform
    at org.eclipse.tycho.p2.impl.resolver.P2ResolverImpl.resolveMetadata(P2ResolverImpl.java:92)
    at org.eclipse.tycho.extras.tpvalidator.TPValidationMojo.validateTarget(TPValidationMojo.java:117)
==== 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