Community
Participate
Working Groups
Created attachment 219484 [details] sample project with different tycho versions causing cryptic error message We are frequently facing user reports with cryptic error messages that turn out to be caused by several different tycho versions being configured in different modules of (large) multi-module projects. Errors can take various shapes, e.g. ClassCastExceptions like [ERROR] Internal error: java.lang.ClassCastException: org.eclipse.tycho.core.osgitools.DefaultReactorProject cannot be cast to org.eclipse.tycho.ReactorProject -> [Help 1] [exec] org.apache.maven.InternalErrorException: Internal error: java.lang.ClassCastException: org.eclipse.tycho.core.osgitools.DefaultReactorProject cannot be cast to org.eclipse.tycho.ReactorProject or even p2 resolution errors which do not hint at different tycho versions as demonstrated by attched sample project: [ERROR] Internal error: java.lang.RuntimeException: "No solution found because the problem is unsatisfiable.": ["Unable to satisfy dependenc y from tycho.demo.itp01 1.0.0.qualifier to bundle org.eclipse.core.runtime 0.0.0.", "Unable to satisfy dependency from tycho.demo.itp01 1.0. 0.qualifier to bundle org.eclipse.ui 0.0.0.", "Unable to satisfy dependency from tycho.demo.itp01.tests 1.0.0.qualifier to bundle org.junit4 0.0.0.", "Unable to satisfy dependency from tycho.demo.itp01.tests 1.0.0.qualifier to bundle org.eclipse.ui 0.0.0.", "No solution found bec ause the problem is unsatisfiable."] -> [Help 1] Most of those errors do not point to the root cause and we spend considerable amounts of time analysing debug logs to find out that this was just another tycho version misconfiguration. Other tycho versions can leak in e.g. via different parent poms, so the problem is not as obvious to spot as in the attached example. I am openeing this bug to solicit feedback if there is anything we can do to detect this situation and fail-fast with a clear error message. It seems that the problem is augmented by the fact that tycho registers as a maven build extension which will hook into the maven classloader on a lower level where mutliple versions of the same build extension in the same reactor are no longer supported (whereas multiple versions of the same build plugin, not build extension, are supported and separated via separate classloader). Feedback from the maven core experts appreciated.
For the case when Tycho plugin version and core version do not match, the most straightforward solution is to simply check that tycho core version matches plugin version in each Mojo#execute implementation. Little tedious to implement and maintain, but I think workable given relatively small and stable set of mojos we have. We can also relatively easily detect and fail fast when multiple versions of Tycho core are present on classpath. I do not have a good solution for more exotic scenario, when different parts of multi-module project consistently use different Tycho version.
(In reply to comment #1) > For the case when Tycho plugin version and core version do not match, the > most straightforward solution is to simply check that tycho core version > matches plugin version in each Mojo#execute implementation. Little tedious > to implement and maintain, but I think workable given relatively small and > stable set of mojos we have. Most of the errors I have seen happen before the actual lifecycle (in afterProjectsRead()) so Mojo#execute will be too late for these cases. > We can also relatively easily detect and fail fast when multiple versions of > Tycho core are present on classpath. I assume "Tycho core" means the build extension tycho-maven-plugin? > I do not have a good solution for more exotic scenario, when different parts > of multi-module project consistently use different Tycho version. Would looping over all reactor projects in afterProjectsRead() and checking MavenProject.getBuild().getExtensions() for non-unique tycho-maven-plugin versions be a valid option?
(In reply to comment #2) > > Most of the errors I have seen happen before the actual lifecycle (in > afterProjectsRead()) so Mojo#execute will be too late for these cases. > > > We can also relatively easily detect and fail fast when multiple versions of > > Tycho core are present on classpath. > > I assume "Tycho core" means the build extension tycho-maven-plugin? I meant tycho-core module, but this is more or less the same thing. > > > I do not have a good solution for more exotic scenario, when different parts > > of multi-module project consistently use different Tycho version. > > Would looping over all reactor projects in afterProjectsRead() and checking > MavenProject.getBuild().getExtensions() for non-unique tycho-maven-plugin > versions be a valid option? Will likely work.
https://git.eclipse.org/r/#/c/7138/
http://git.eclipse.org/c/tycho/org.eclipse.tycho.git/commit/?id=305eb576d58f1adf8c8f80fee8bdca49da196816
Changing the affected version attribute - I believe that this has been an open issue for a long time now. Thank you Jan for fixing it.