[doc] Add JDK21 to the build for integration testing

Note: This is using 21-ea for now
This commit is contained in:
Andreas Dangel 2023-08-10 15:32:26 +02:00
parent 99948c8fb6
commit a93c8f2b7b
No known key found for this signature in database
GPG Key ID: 93450DF2DF9A3FA3
3 changed files with 43 additions and 4 deletions

View File

@ -9,7 +9,7 @@ SCRIPT_INCLUDES="log.bash utils.bash setup-secrets.bash openjdk.bash maven.bash
source "$(dirname "$0")/inc/fetch_ci_scripts.bash" && fetch_ci_scripts
function build() {
pmd_ci_log_group_start "Prepare Java 8+11+17, Bundler"
pmd_ci_log_group_start "Prepare Java 8+11+17+21, Bundler"
pmd_ci_openjdk_install_adoptium 11
pmd_ci_openjdk_setdefault 11
PMD_MAVEN_EXTRA_OPTS=()
@ -18,7 +18,13 @@ function build() {
pmd_ci_openjdk_install_adoptium 8
pmd_ci_log_info "Install openjdk17 for integration tests and pmd-regression-tests"
pmd_ci_openjdk_install_adoptium 17
PMD_MAVEN_EXTRA_OPTS=(-Djava8.home="${HOME}/openjdk8" -Djava17.home="${HOME}/openjdk17")
pmd_ci_log_info "Install openjdk21 for integration tests and pmd-regression-tests"
pmd_ci_openjdk_install_adoptium "21-ea"
PMD_MAVEN_EXTRA_OPTS=(
-Djava8.home="${HOME}/openjdk8"
-Djava17.home="${HOME}/openjdk17"
-Djava21.home="${HOME}/openjdk21"
)
fi
pmd_ci_build_setup_bundler
pmd_ci_log_group_end

View File

@ -11,6 +11,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
@ -220,11 +221,12 @@ public class Formatter {
// fall-through
}
// Maybe this is Java17? Then there will be
// Maybe this is Java17+? Then there will be
// https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/Console.html#charset()
// instead of the field "cs".
try {
Charset charset = (Charset) MethodUtils.invokeMethod(console, "charset");
Method charsetMethod = Console.class.getDeclaredMethod("charset");
Charset charset = (Charset) charsetMethod.invoke(console);
return charset.name();
} catch (IllegalArgumentException | ReflectiveOperationException ignored) {
// fall-through

View File

@ -256,5 +256,36 @@
</plugins>
</build>
</profile>
<profile>
<id>jdk21-compat-it</id>
<activation>
<property>
<name>java21.home</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>jdk21-compat-it</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<environmentVariables>
<JAVA_HOME>${java21.home}</JAVA_HOME>
<PATH>${java21.home}/bin:${env.PATH}</PATH>
</environmentVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>