If you are creating a framework, you may want to compile with Java 6 for backward compatibility. Also, in new projects, I don't use the old JDK, so even if the compilation is Java 6, I want to test with Java 6, 7, 8 and 11.
Recent Maven doesn't work on Java 6, but if you devise it, you can run Maven on Java 8 while compiling with Java 6 and testing with Java 11.
You can compile with any JDK by specifying the javac
command with ʻexecutable of
maven-compiler-plugin. Then you can test with any JDK by specifying the
java command with
jvmof
maven-surefire-plugin`.
Both can be set in the system properties.
The command example looks like this.
export JAVA_HOME=/path/to/jdk8
mvn -Dmaven.compiler.executable=/path/to/jdk6/bin/javac \
-Dmaven.compiler.fork=true \
-Djvm=/path/to/jdk11/bin/java \
test
Recommended Posts