tycho icon indicating copy to clipboard operation
tycho copied to clipboard

Feature project not compiled when using toolchains.xml

Open Phillipus opened this issue 1 year ago • 4 comments

If the host system Java version differs from that specified in a plugin's BREE and that plug-in is referenced in an Eclipse Feature project, compilation of the Feature fails even if toolchains.xml contains the path to the correct Java version.

Attached is a test.zip file containing a very simple pom.xml file, an Eclipse Plug-in Project, an Eclipse Feature Project and a toolchains.xml file (and a .mvn folder containing a extensions.xml file).

To test this:

  1. Ensure the host system Java is version 17. (Or run export JAVA_HOME=/pathto/Java17 before running mvn clean verify)
  2. Edit the attached toolchains.xml file so that the jdkHome paths point to Java 17 and 21 locations (you might not need the JavaSE-17 one)
  3. Copy the toolchains.xml file to the ~/.m2 directory or use the --global-toolchains file option to reference it
  4. Run mvn clean verify
  5. The following error occurs:
[INFO] Resolving dependencies of MavenProject: test:TestFeature:1.0.0-SNAPSHOT @ test/TestFeature/.polyglot.feature.xml
[ERROR] TestProject 1.0.0.202411190919 requires Execution Environment that matches (&(osgi.ee=JavaSE)(version=21)) but the current resolution context uses [a.jre.javase 17.0.0]
[INFO] {osgi.os=win32, osgi.ws=win32, org.eclipse.update.install.features=true, osgi.arch=x86_64, org.eclipse.update.install.sources=true}
[ERROR] Cannot resolve project dependencies:
[ERROR]   Software being installed: TestFeature.feature.group 1.0.0.qualifier
[ERROR]   Missing requirement: TestProject 1.0.0.202411190919 requires 'osgi.ee; (&(osgi.ee=JavaSE)(version=21))' but it could not be found
[ERROR]   Cannot satisfy dependency: TestFeature.feature.group 1.0.0.qualifier depends on: org.eclipse.equinox.p2.iu; TestProject 0.0.0

Note that compilation succeeds if <module>TestFeature</module> is removed from the pom.xml file. So the error seems to occur only with Feature Projects.

Phillipus avatar Nov 19 '24 10:11 Phillipus

<useJDK>BREE</useJDK> and <maven.compiler.target>21</maven.compiler.target> do not really make sense, any reason for this combination?

Beside that features are not compiled (just resolved / packaged) and the errors says that your feature depends on something that requires Java 21 but you are using Java 17.

So is there any reason not running the build with Java 21 in the first place, removing BREE and just let Tycho workout the target level itself? You won't even need a toolchains configuration then at all.

laeubi avatar Nov 19 '24 11:11 laeubi

<useJDK>BREE</useJDK> and <maven.compiler.target>21</maven.compiler.target> do not really make sense, any reason for this combination?

Copied and pasted from another project. Can be ignored.

So is there any reason not running the build with Java 21 in the first place, removing BREE and just let Tycho workout the target level itself? You won't even need a toolchains configuration then at all.

I have Java 17 installed as the system Java and was testing against Java 21 so thought this would work. It works OK if there are no feature projects so I thought this might be an issue worth reporting.

Phillipus avatar Nov 19 '24 12:11 Phillipus

Features do not have any BREE obviously so they somehow fall back to the running JVM, this could probably be improved but its quite uncommon to run with a lower JVM but build for a higher JVM.

laeubi avatar Nov 19 '24 12:11 laeubi

Features do not have any BREE obviously so they somehow fall back to the running JVM, this could probably be improved but its quite uncommon to run with a lower JVM but build for a higher JVM.

Fair enough. I just reported it for completeness sake.

Phillipus avatar Nov 19 '24 12:11 Phillipus