Compile with Java 6 and test with Java 11 while running Maven on Java 8

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 jvmofmaven-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

reference

Recommended Posts

Compile with Java 6 and test with Java 11 while running Maven on Java 8
[CircleCI 2.0] [Java] [Maven] [JUnit] Aggregate JUnit test results with CircleCI 2.0
Java automated test implementation with JUnit 5 + Apache Maven
IDE and Maven compile with all debug information
Build and test Java + Gradle applications with Wercker
Compile and run Java on the command line
Install java and maven using brew on new mac
Create a Java (Maven) project with VS Code and develop it on a Docker container
Try gRPC with Java, Maven
Java while and for statements
Use java with MSYS and Cygwin
Distributed tracing with OpenCensus and Java
Install Java and Tomcat with Ansible
Enable Openjdk10 and maven on CentOS
Install Java with zip on Windows
Use JDBC with Java and Scala.
Output PDF and TIFF with Java 8
[Java] Test private methods with JUnit
Running Java VM with WebAssembly: Supplement
Enable Java 8 and Java 11 SDKs on Ubuntu
Copy and paste test with RSpec
Hello World with GWT 2.8.2 and Maven
Notes on Java path and Package
Install Java 9 on windows 10 and CentOS 7
Develop gRPC on Windows + Java 7 + Maven 2
Encrypt with Java and decrypt with C #
Starting with installing Docker on EC2 and running Yellowfin in a container
Activity transition with JAVA class refactoring and instance experimented on Android side
[Java] Deploy a web application created with Eclipse + Maven + Ontology on Heroku
How to compile Java with VsCode & Ant
Monitor Java applications with jolokia and hawtio
[Ruby on Rails] View test with RSpec
Link Java and C ++ code with SWIG
Try running MySql and Blazor with docker-compose
Using JupyterLab + Java with WSL on Windows 10
Java EE test (CDI / interceptor) with Arquillian
Let's try WebSocket with Java and javascript!
[Java] Reading and writing files with OpenCSV
Java version control with jenv on OSX
[Ruby on Rails] Controller test with RSpec
Install Java8 with Yum on Amazon Linux
CICS-Run Java applications-(2) Build management with Maven
Build OpenCV with Java Wrapper on Ubuntu 18.04
[Ruby on Rails] Model test with RSpec
Java automated test implementation with JUnit 5 + Gradle
I built a Java EE environment on AWS and tried running a web application
Create an ARM-cpu environment with qemu on mac and run java [Result → Failure]
Build Apache and Tomcat environment with Docker. By the way, Maven & Java cooperation
Hello World with Java Servlet and JSP (Easy web server startup with Maven + Jetty)
Hello World, a cross-platform GUI app with Groovy running on the Java platform
Try running MPLS-VPN with FR Routing on Docker
[Java] How to test for null with JUnit
Understand Java Serializable while actually running the application
Install java and android-sdk on Mac using homebrew
Put Java 11 and spring tool suite on mac
Easily switch Java versions with alias on macOS
Deploy Java web app to Azure with maven
Install Java 11 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
Try to link Ruby and Java with Dapr
Try running OSPF with FR Routing on Docker
JSON with Java and Jackson Part 2 XSS measures