In our project (Eclipse Trace Compass) we are planning to support Java 11 platform for 2020-09 but we still have to support older targets that use Java 1.8.
We have updated our Java code base so that it compiles and runs in both Java 1.8 and 11.
In the plug-in properties we have set the Java Build Path and Java Compiler (JDK Compliance) to JavaSE-11. But in the plug-in Manifests we have left the minimum execution environment to JavaSE-1.8.
Then in the main pom.xml we have added our own maven property so that different Jenkins jobs could set the Java version independently.
In the pom.xml this property (either "1.8" or "11") is used to set:
- maven-enforcer-plugin <requireJavaVersion> property
- tycho-compiler-plugin <source> property
- tycho-compiler-plugin <target> property
- tycho-eclipserun-plugin <executionEnvironment> property (prefixed with "JavaSE-")
However, when running the Jenkins job or maven from command-line, the pom.xml settings have no effect at all. The code is always compiled for JavaSE-11.
From some testing it appears that the only thing that matters is the plug-in's Java Compiler (JDK Compliance) setting, specifically: org.eclipse.jdt.core.compiler.codegen.targetPlatform in .settings/org.eclipse.jdt.core.prefs
If that is the case, what is the purpose of the tycho-compiler-plugin source and target properties? Are we using it wrong?
Is this the proper way to support different Java versions with the same version of the code base, or is that not possible? Has any other project done this successfully?