From b4bb30354d216b45a13a80937bcac5c2995c8147 Mon Sep 17 00:00:00 2001 From: BJ Hargrave Date: Wed, 18 May 2022 18:12:31 -0400 Subject: [PATCH] Configure javac to use --release when building on JDK 9+ (#58) We use the maven-compiler-plugin's `maven.compiler.release` property to configure the --release value when building on JDK 9 or later. Using --release is preferable to using --source/--target as --release also factors in the class libraries available in the release. Unfortunately, setting this property when building on JDK 8 causes a build error as the maven-compiler-plugin passes the --release option to javac which does not understand it. So we use a maven profile to set the property only when JDK is 9 or higher. Signed-off-by: BJ Hargrave --- pom.xml | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index f1d4316..da1e102 100644 --- a/pom.xml +++ b/pom.xml @@ -32,8 +32,10 @@ UTF-8 - 1.8 - 1.8 + 1.8 + 8 + ${java.version} + ${java.version} 2.0.0 @@ -50,6 +52,7 @@ 1.1 + 3.10.1 3.2.0 3.2.0 3.1.2 @@ -210,6 +213,11 @@ + + org.apache.maven.plugins + maven-compiler-plugin + ${version.plugin.compiler} + org.apache.maven.plugins maven-resources-plugin @@ -1099,5 +1107,15 @@ eftckl-1.0 + + + java-release + + [9,) + + + ${java.release} + +