Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[tycho-user] Compiling for different Java versions with Maven


This is a follow-up to:

So, as Mickael suggested, I updated the pom.xml to use:
and also adding a <configuration> for maven-toolchains-plugin:toolchain.

The Jenkins job is overriding a maven property jdk.version=1.8 or 11. This is used to set <source> and <target> in tycho-compiler-plugin configuration.

When I tried this, it had no effect. The build was compiled for JavaSE-11 even if jdk.version=1.8. However, the build was successful: (-Djdk.version=1.8)

I found that in order to control the JDK version, I also have to set <release> in tycho-compiler-plugin configuration to 8 or 11. Now the build compiles with the desired JDK, however both builds fail, for different reasons: (-Djdk.version=1.8 -Djdk.release=8)
14:13:14  [ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:2.0.0-SNAPSHOT:compile (default-compile) on project org.eclipse.tracecompass.common.core: Compilation failure: Compilation failure: 
14:13:14  [ERROR] /home/jenkins/agent/workspace/tracecompass-master-jdk11/common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/[91] 
14:13:14  [ERROR] 	return requireNonNull(requireNonNull(stream).<@NonNull T> map(Objects::requireNonNull));
14:13:14  [ERROR] 	                      ^^^^^^^^^^^^^^^^^^^^^^
14:13:14  [ERROR] Potential null pointer access: The method requireNonNull(Stream) may return null
It appears that with the new tycho version and JavaSE-1.8, our external null annotations are no longer working properly. In our project we have configured them so that Objects.requireNonNull(T) returns a @NonNull T. (-Djdk.version=11 -Djdk.release=11)
14:42:46  [ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:2.0.0-SNAPSHOT:compile (default-compile) on project org.eclipse.tracecompass.tmf.ui: Compilation failure: Compilation failure: 
14:42:46  [ERROR] /home/jenkins/agent/workspace/tracecompass-master-jdk11/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/colors/[23] 
14:42:46  [ERROR] 	import javax.xml.parsers.DocumentBuilder;
14:42:46  [ERROR] 	       ^^^^^^^^^^^^^^^^^
14:42:46  [ERROR] The package javax.xml.parsers is accessible from more than one module: <unnamed>, java.xml
Something is wrong with the javax.xml modules when using JavaSE-11, but I am not sure how to fix it.

Thank you for any help, I seem to be stuck.

Back to the top