From e7dc731e4c422cabc17340269d5caf2967835316 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Thu, 26 Oct 2023 14:16:59 +0200 Subject: [PATCH] Support jdk 21 (#311) --- .github/workflows/maven.yml | 12 +++--------- .../javac/JavacErrorProneCompilerTest.java | 10 +++++----- .../compiler/javac/AbstractJavacCompilerTest.java | 15 ++++++++++++--- .../compiler/javac/JavaxToolsCompilerTest.java | 11 +++++++++++ 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 33aeb267..6339be53 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -26,15 +26,9 @@ jobs: name: Build it uses: codehaus-plexus/.github/.github/workflows/maven.yml@master with: - jdk-fast-fail-build: '11' - jdk-matrix: '["11", "17", "20"]' - jdk-distribution-matrix: '["zulu", "temurin", "microsoft", "liberica","corretto"]' + jdk-fast-fail-build: '21' + jdk-matrix: '["11", "17", "21"]' + jdk-distribution-matrix: '["zulu", "temurin", "microsoft", "liberica", "corretto"]' os-matrix: '["ubuntu-latest","windows-latest", "macOS-latest"]' - matrix-exclude: '[ - { "jdk": "21-ea", "distribution": "corretto" }, - { "jdk": "21-ea", "distribution": "liberica" }, - { "jdk": "20", "distribution": "microsoft" }, - { "jdk": "21-ea", "distribution": "temurin" } - ]' maven_args: 'install javadoc:javadoc -e -B -V -fae -Pno-tests-if-not-on-osx' diff --git a/plexus-compilers/plexus-compiler-javac-errorprone/src/test/java/org/codehaus/plexus/compiler/javac/JavacErrorProneCompilerTest.java b/plexus-compilers/plexus-compiler-javac-errorprone/src/test/java/org/codehaus/plexus/compiler/javac/JavacErrorProneCompilerTest.java index 242decfb..f1c21798 100644 --- a/plexus-compilers/plexus-compiler-javac-errorprone/src/test/java/org/codehaus/plexus/compiler/javac/JavacErrorProneCompilerTest.java +++ b/plexus-compilers/plexus-compiler-javac-errorprone/src/test/java/org/codehaus/plexus/compiler/javac/JavacErrorProneCompilerTest.java @@ -21,12 +21,12 @@ protected int expectedWarnings() String javaVersion = getJavaVersion(); if (javaVersion.startsWith("1.8")) { return 1; - } else { - if (javaVersion.contains("18") || javaVersion.contains("19") || javaVersion.contains("20")) { - return 5; - } - return 2; + } else if (javaVersion.contains("18") || javaVersion.contains("19") || javaVersion.contains("20")) { + return 5; + } else if (javaVersion.contains("21")) { + return 6; } + return 2; } @Override diff --git a/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/AbstractJavacCompilerTest.java b/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/AbstractJavacCompilerTest.java index 8cf53bbb..dcbfc7ca 100644 --- a/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/AbstractJavacCompilerTest.java +++ b/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/AbstractJavacCompilerTest.java @@ -69,7 +69,8 @@ protected int expectedErrors() String javaVersion = getJavaVersion(); if (javaVersion.contains("9.0")||javaVersion.contains("11")||javaVersion.contains("14")|| javaVersion.contains("15")||javaVersion.contains("16")||javaVersion.contains("17")|| - javaVersion.contains("18")||javaVersion.contains("19")||javaVersion.contains("20")){ + javaVersion.contains("18")||javaVersion.contains("19")||javaVersion.contains("20")|| + javaVersion.contains("21")){ return 5; } // javac output changed for misspelled modifiers starting in 1.6...they now generate 2 errors per occurrence, not one. @@ -89,7 +90,8 @@ protected int expectedWarnings() String javaVersion = getJavaVersion(); if (javaVersion.contains("9.0")||javaVersion.contains("11")||javaVersion.contains("14")|| javaVersion.contains("15")||javaVersion.contains("16")||javaVersion.contains("17")|| - javaVersion.contains("18")||javaVersion.contains("19")||javaVersion.contains("20")){ + javaVersion.contains("18")||javaVersion.contains("19")||javaVersion.contains("20")|| + javaVersion.contains("21")){ return 1; } if (javaVersion.contains("1.8")){ @@ -137,6 +139,9 @@ public String getTargetVersion() if (javaVersion.contains("20")){ return "20"; } + if (javaVersion.contains("21")){ + return "21"; + } return super.getTargetVersion(); } @@ -175,6 +180,9 @@ public String getSourceVersion() if (javaVersion.contains("20")){ return "20"; } + if (javaVersion.contains("21")){ + return "21"; + } return super.getTargetVersion(); } @@ -184,7 +192,8 @@ protected Collection expectedOutputFiles() String javaVersion = getJavaVersion(); if (javaVersion.contains("9.0")||javaVersion.contains("11")||javaVersion.contains("14")|| javaVersion.contains("15")||javaVersion.contains("16")||javaVersion.contains("17")|| - javaVersion.contains("18")||javaVersion.contains("19")||javaVersion.contains("20") + javaVersion.contains("18")||javaVersion.contains("19")||javaVersion.contains("20")|| + javaVersion.contains("21") ){ return Arrays.asList( "org/codehaus/foo/Deprecation.class", "org/codehaus/foo/ExternalDeps.class", "org/codehaus/foo/Person.class" ); diff --git a/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/JavaxToolsCompilerTest.java b/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/JavaxToolsCompilerTest.java index b362f3be..598bad40 100644 --- a/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/JavaxToolsCompilerTest.java +++ b/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/JavaxToolsCompilerTest.java @@ -25,4 +25,15 @@ public class JavaxToolsCompilerTest extends AbstractJavacCompilerTest { // no op default is to javax.tools if available + + @Override + protected int expectedWarnings() { + String javaVersion = getJavaVersion(); + if (javaVersion.contains("21")) { + return 8; + } else { + return super.expectedWarnings(); + } + } + }