Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,30 @@ 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. Compiling to 11 on a 21 JDK cannot catch a problem that only
# appears on an 11 runtime, so both are run.
java-version: [11, 21]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 21
# Both JDKs are installed, 21 last so it becomes JAVA_HOME and Gradle's daemon runs
# there. The matrix JDK is picked up by the toolchain to compile and run the tests.
- 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
- name: Build with Gradle
run: ./gradlew build
run: ./gradlew build -PjavaTestVersion=${{ matrix.java-version }}
env:
GITHUB_USERNAME: ${{ secrets.GITHUB_USERNAME }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
20 changes: 19 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,17 @@ plugins {
}

java {
// Bytecode targets 11 to match the Maven main artifact, whatever JDK compiles it.
// 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 while Gradle itself
// stays on the launcher JDK.
toolchain {
languageVersion = JavaLanguageVersion.of(21)
languageVersion = JavaLanguageVersion.of(
(project.findProperty('javaTestVersion') ?: '21') as Integer)
}

withJavadocJar()
Expand Down Expand Up @@ -111,6 +120,15 @@ repositories {
}
}
}

// cfparser is tracked as a SNAPSHOT. Gradle treats that as a changing module and caches
// it for 24 hours, and the CI workflows restore a Gradle cache -- so a green run shortly
// after a cfparser republish can have tested the *previous* artifact. Re-resolve every
// time; it is one small jar, and a stale one is worth far more than the download.
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

dependencies {
implementation 'com.github.cfmleditor:cfml.parsing:2.16.1-SNAPSHOT'
implementation 'commons-cli:commons-cli:1.2'
Expand Down
67 changes: 65 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<!-- The main artifact is Java 11 so it loads on every supported runtime; the
jdk21 classifier below is the same source compiled at 21. release rather
than source/target because it checks the API surface, not just the
language level. -->
<maven.compiler.release>11</maven.compiler.release>
<jdk21.release>21</jdk21.release>
<maven.compiler.proc>none</maven.compiler.proc>

<cfparser.version>2.16.1-SNAPSHOT</cfparser.version>
Expand Down Expand Up @@ -210,6 +214,28 @@
</execution>
</executions>
</plugin>
<!-- Two artifacts from one source tree, mirroring cfparser. default-compile
emits Java 11 into target/classes for the main jar and the shaded -all
jar; compile-jdk21 emits Java 21 into target/classes-jdk21 for the
jdk21 classifier. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<executions>
<execution>
<id>compile-jdk21</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>${jdk21.release}</release>
<outputDirectory>${project.build.directory}/classes-jdk21</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand All @@ -229,11 +255,48 @@
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<id>jar-jdk21</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>jdk21</classifier>
<classesDirectory>${project.build.directory}/classes-jdk21</classesDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources-jdk21</id>
<!-- classes-jdk21 holds only .class files, so the classified jar
needs the resources copied in. Kept at process-classes for
the reason cfparser's pom documents: setting outputDirectory
on a compiler execution leaks into what dependents resolve,
and a later phase breaks the test run in a way that reads
like a missing resource. -->
<phase>process-classes</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/classes-jdk21</outputDirectory>
<resources>
<resource>
<directory>${project.build.outputDirectory}</directory>
<excludes>
<exclude>**/*.class</exclude>
</excludes>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
Expand Down
Loading