diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 547116b..3de34e9 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -10,18 +10,29 @@ on: jobs: gradle: strategy: + fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] + # 11 is the baseline the published main artifact targets, 21 the runtime most + # consumers are on. Running the suite on both is the only way to catch a Java 11 + # problem that compiling to 11 on a 21 JDK cannot see. + java-version: [11, 21] runs-on: ${{ matrix.os }} steps: - name: Checkout uses: actions/checkout@v4 - - name: Set up JDK 21 + # Both JDKs are installed. The last entry becomes JAVA_HOME, so Gradle's daemon + # always runs on 21 -- the bnd OSGi plugin is class file 61 and cannot load on an + # 11 JVM. The matrix JDK is picked up by the toolchain for compiling and running + # the tests, which is the part that needs to happen on Java 11. + - name: Set up JDK ${{ matrix.java-version }} and 21 uses: actions/setup-java@v4 with: distribution: temurin - java-version: 21 + java-version: | + ${{ matrix.java-version }} + 21 - name: Setup Gradle uses: gradle/actions/setup-gradle@v3 @@ -29,4 +40,4 @@ jobs: gradle-version: wrapper - name: Build with Gradle - run: ./gradlew build \ No newline at end of file + run: ./gradlew build -PjavaTestVersion=${{ matrix.java-version }} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 5ff466b..2ae7298 100644 --- a/build.gradle +++ b/build.gradle @@ -133,8 +133,22 @@ subprojects { } } - sourceCompatibility = 21 - targetCompatibility = 21 + // Bytecode stays at 11 to match the Maven main artifact, whatever JDK is running. + // The published jdk21 classifier is produced by Maven, which is what publishes. + sourceCompatibility = 11 + targetCompatibility = 11 + + // -PjavaTestVersion selects the JDK that compiles and runs the tests, so CI can + // exercise the same Java 11 bytecode on an 11 and a 21 runtime. Gradle itself keeps + // running on the launcher JDK: the bnd OSGi plugin is class file 61 and throws + // UnsupportedClassVersionError if the daemon is on Java 11, so the toolchain has to + // move rather than the whole build. + java { + toolchain { + languageVersion = JavaLanguageVersion.of( + (project.findProperty('javaTestVersion') ?: '21') as Integer) + } + } tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } task sourcesJar(type: Jar) { diff --git a/pom.xml b/pom.xml index 91dba92..a139d56 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,11 @@ UTF-8 - 21 + + 11 + 21 0.8.12 + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + + compile-jdk21 + compile + + compile + + + ${jdk21.release} + ${project.build.directory}/classes-jdk21 + + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.3.1 + + + copy-resources-jdk21 + process-classes + + copy-resources + + + ${project.build.directory}/classes-jdk21 + + + ${project.build.outputDirectory} + + **/*.class + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.4.1 + + + jar-jdk21 + package + + jar + + + jdk21 + ${project.build.directory}/classes-jdk21 + + true + + + + org.jacoco jacoco-maven-plugin