Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 363791

Summary: Tycho-versions-plugin:0.13.0 can't handle Tycho 0.11.0 projects
Product: z_Archived Reporter: Matthias Vach <matthias.vach>
Component: TychoAssignee: Jan Sievers <jan.sievers>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: igor, jan.sievers, jochen.ehret, t-oberlies
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Simple Tycho 0.11.0 test project
none
Bugfix and version compatibility test. jan.sievers: iplog+, jan.sievers: review+

Description Matthias Vach CLA 2011-11-15 04:58:44 EST
Build Identifier: 

Attached is a simple Tycho 0.11.0 project. We'd like to use the tycho-versions-plugin 0.13.0 to change the version. However, the 0.13.0 version of the plugin can't handle older Tycho versions.

Version 0.11.0 works fine. 
 Command line:
mvn org.sonatype.tycho:tycho-versions-plugin:0.11.0:set-version -DnewVersion=1.2.3
 Build result:
Build succeeds.


Version 0.13.0 produces a ClassNotFoundException.
 Command line:
mvn org.eclipse.tycho:tycho-versions-plugin:0.13.0:set-version -DnewVersion=1.2.3
 Build result:
[INFO] --- tycho-versions-plugin:0.13.0:set-version (default-cli) @ test.artifact ---
15.11.2011 10:41:55 org.sonatype.guice.bean.reflect.NamedClass
WARNING: Error injecting: org.eclipse.tycho.versions.manipulation.SiteXmlManipulator
java.lang.NoClassDefFoundError: org/eclipse/tycho/model/FeatureRef
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
        at java.lang.Class.getDeclaredConstructors(Class.java:1836)
        at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:243)
        at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.java:96)
        at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:628)
        at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:835)
        at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:769)
        at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:254)
        at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:205)
        at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:843)
        at com.google.inject.internal.InjectorImpl.getProviderOrThrow(InjectorImpl.java:957)
        at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:990)
        at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:951)
        at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1003)
        at org.sonatype.guice.bean.reflect.AbstractDeferredClass.get(AbstractDeferredClass.java:47)
        at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
        at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
        at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1021)
        at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
        at com.google.inject.Scopes$1$1.get(Scopes.java:59)
        at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
        at com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:968)
        at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1014)
        at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:964)
        at org.sonatype.guice.bean.locators.LazyBeanEntry.getValue(LazyBeanEntry.java:79)
        at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:53)
        at org.sonatype.guice.bean.locators.EntryListAdapter$ValueIterator.next(EntryListAdapter.java:112)
        at org.eclipse.tycho.versions.engine.VersionsEngine.apply(VersionsEngine.java:90)
        at org.eclipse.tycho.versions.SetMojo.execute(SetMojo.java:73)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: java.lang.ClassNotFoundException: org.eclipse.tycho.model.FeatureRef
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
        ... 51 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.985s
[INFO] Finished at: Tue Nov 15 10:41:56 CET 2011
[INFO] Final Memory: 38M/92M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-versions-plugin:0.13.0:set-version (default-cli) on project test.artifact: Execution default-cl
i of goal org.eclipse.tycho:tycho-versions-plugin:0.13.0:set-version failed: Guice provision errors:
[ERROR]
[ERROR] 1) Error injecting: org.eclipse.tycho.versions.manipulation.SiteXmlManipulator
[ERROR] at ClassRealm[plugin>org.eclipse.tycho:tycho-versions-plugin:0.13.0, parent: sun.misc.Launcher$AppClassLoader@11b86e7]
[ERROR] at ClassRealm[plugin>org.eclipse.tycho:tycho-versions-plugin:0.13.0, parent: sun.misc.Launcher$AppClassLoader@11b86e7]
[ERROR] while locating org.eclipse.tycho.versions.engine.MetadataManipulator annotated with @com.google.inject.name.Named(value=eclipse-update-site)
[ERROR]
[ERROR] 1 error: org/eclipse/tycho/model/FeatureRef: org.eclipse.tycho.model.FeatureRef
[ERROR] -> [Help 1]

Reproducible: Always

Steps to Reproduce:
See Bug "Details".
Comment 1 Matthias Vach CLA 2011-11-15 05:07:49 EST
Created attachment 207015 [details]
Simple Tycho 0.11.0 test project
Comment 2 Tobias Oberlies CLA 2011-11-15 05:16:57 EST
I can imagine technical limitations why this doesn't work, but I agree that it really should work... I don't think that we will be able to fix this for 0.13.0, but we shouldn't get the same problem for 0.13.0 projects and the 0.14.0 versions plug-in.
Comment 3 Jochen Ehret CLA 2011-11-15 10:52:29 EST
We've analyzed the problem:

The tycho-maven-plugin 0.11.0 build extension contains an "extension.xml" descriptor. This descriptor defines which packages and artifacts are exported. The artifacts are only indicated with artifactId, but not with groupId.

If you call the tycho-version-plugin:0.13.0 on a project that uses the 0.11.0 build extension, all artifacts from the extension are filtered from the plugin's realm. Matching is done only on artifactId. Example: The tycho-version-plugin has a dependency to org.eclipse.tycho:tycho-metadata-model:0.13.0, but this dependency is filtered because it matches "tycho-metadata-model". So the plugin only "sees" the old org.sonatype.tycho artifacts. This leads to NoClassDefFoundErrors because packages have also been renamed.

The solution would have been to specify groupIds in the extension.xml descriptor:

<extension>
  ...
  <exportedArtifacts>
    <exportedArtifact>org.sonatype.tycho:tycho-metadata-model</exportedArtifact>
    ...
  </exportedArtifacts>
</extension>

The current extension.xml should be fixed so that the problem can't reappear. 
The tycho-versions-plugin could be fixed with a custom ClassLoader. We'll evaluate that and propose a patch, if applicable.
Comment 4 Igor Fedorenko CLA 2011-11-15 11:34:54 EST
Quite honestly, I don't think providing backwards compatibility with tycho 0.11 and earlier is required, especially if it requires non-trivial changes to tycho. Either migrate to tycho 0.13 or use versions plugin from tycho 0.11.
Comment 5 Jochen Ehret CLA 2011-11-16 08:57:46 EST
Created attachment 207088 [details]
Bugfix and version compatibility test.

The patch fixes the exported artifacts of the tycho-maven-plugin build extension. A test ensures that future versions of the tycho-versions-plugin will remain compatible to Tycho 0.12.0 projects.
Comment 6 Jan Sievers CLA 2011-11-18 07:19:30 EST
Comment on attachment 207088 [details]
Bugfix and version compatibility test.

reviewed patch.

corrected copyright header to mention SAP AG instead of Sonatype, stripped down integration test