Skip to content

Commit 17c30ca

Browse files
committed
ci: switch to using language toolchains
1 parent 6375d62 commit 17c30ca

File tree

19 files changed

+113
-55
lines changed

19 files changed

+113
-55
lines changed

.github/workflows/ci-netty-snapshot.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
steps:
2121
- name: Checkout Code
2222
uses: actions/checkout@v5
23-
- name: Set up JDK ${{ matrix.java }}
23+
- name: Set up JDK 21 (Gradle Execution)
2424
uses: actions/setup-java@v5
2525
with:
26-
java-version: ${{ matrix.java }}
26+
java-version: 21
2727
distribution: 'zulu'
2828
cache: 'gradle'
2929
- name: Print JDK Version
@@ -37,6 +37,8 @@ jobs:
3737
- name: Clean Gradle project
3838
run: ./gradlew --parallel clean
3939
- name: Build and Test
40+
env:
41+
ORG_GRADLE_PROJECT_testJavaVersion: ${{ matrix.java }}
4042
run: sudo -E env "PATH=$PATH" bash -c "ulimit -l 65536 && ulimit -a && ./gradlew --no-daemon --parallel test"
4143
- name: Publish Test Results
4244
if: always()

.github/workflows/ci-prb.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
- '**.txt'
1414
jobs:
1515
build:
16-
name: JDK ${{ matrix.java }} ${{ matrix.os_label }}
16+
name: JDK ${{ matrix.java }} Toolchain (Gradle on JDK 21)
1717
runs-on: ${{ matrix.os }}
1818
strategy:
1919
matrix:
@@ -27,10 +27,10 @@ jobs:
2727
steps:
2828
- name: Checkout Code
2929
uses: actions/checkout@v5
30-
- name: Set up JDK ${{ matrix.java }}
30+
- name: Set up JDK 21 (Gradle Execution)
3131
uses: actions/setup-java@v5
3232
with:
33-
java-version: ${{ matrix.java }}
33+
java-version: 21
3434
distribution: 'zulu'
3535
cache: 'gradle'
3636
- name: Print JDK Version
@@ -51,11 +51,13 @@ jobs:
5151
if: runner.os == 'Linux'
5252
env:
5353
JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
54+
ORG_GRADLE_PROJECT_testJavaVersion: ${{ matrix.java }}
5455
run: sudo -E env "PATH=$PATH" bash -c "ulimit -l 65536 && ulimit -a && ./gradlew --no-daemon --parallel test"
5556
- name: Build and Test (non-Linux)
5657
if: runner.os != 'Linux'
5758
env:
5859
JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
60+
ORG_GRADLE_PROJECT_testJavaVersion: ${{ matrix.java }}
5961
run: ./gradlew --no-daemon --parallel test
6062
- name: Upload Test Results
6163
if: always()

.github/workflows/ci-prq.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ on:
1212
- '*.txt'
1313
jobs:
1414
quality:
15-
name: JDK ${{ matrix.java }}
15+
name: JDK ${{ matrix.java }} Toolchain (Gradle on JDK 21)
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
1919
java: [ 8, 11 ] # These are the JDK's we publish artifacts with.
2020
steps:
2121
- name: Checkout Code
2222
uses: actions/checkout@v5
23-
- name: Set up JDK ${{ matrix.java }}
23+
- name: Set up JDK 21 (Gradle Execution)
2424
uses: actions/setup-java@v5
2525
with:
26-
java-version: ${{ matrix.java }}
26+
java-version: 21
2727
distribution: 'zulu'
2828
cache: 'gradle'
2929
- name: Print JDK Version
@@ -37,6 +37,8 @@ jobs:
3737
- name: Clean Gradle project
3838
run: ./gradlew --parallel clean
3939
- name: Build with Gradle
40+
env:
41+
ORG_GRADLE_PROJECT_testJavaVersion: ${{ matrix.java }}
4042
run: ./gradlew --parallel -Pdependency.analysis.print.build.health=true quality
4143
- name: Upload CheckStyle Results
4244
if: always()

.github/workflows/ci-release.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- "[0-9]+.[0-9]+.[0-9]+.[0-9]+"
77
jobs:
88
build:
9-
name: Release JDK ${{ matrix.java }}
9+
name: Release JDK ${{ matrix.java }} Toolchain (Gradle on JDK 21)
1010
runs-on: ubuntu-latest
1111
strategy:
1212
fail-fast: false
@@ -17,10 +17,10 @@ jobs:
1717
uses: actions/checkout@v5
1818
- name: Check NO SNAPSHOT version suffix
1919
run: if [[ $(cat gradle.properties | grep version= | sed 's/^version=//') =~ .*-SNAPSHOT ]]; then exit 1; else exit 0; fi
20-
- name: Set up JDK ${{ matrix.java }}
20+
- name: Set up JDK 21 (Gradle Execution)
2121
uses: actions/setup-java@v5
2222
with:
23-
java-version: ${{ matrix.java }}
23+
java-version: 21
2424
distribution: 'zulu'
2525
cache: 'gradle'
2626
- name: Print JDK Version
@@ -35,6 +35,7 @@ jobs:
3535
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }}
3636
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
3737
SONATYPE_TOKEN: ${{ secrets.SONATYPE_TOKEN }}
38+
ORG_GRADLE_PROJECT_testJavaVersion: ${{ matrix.java }}
3839
run: |
3940
# Build arguments to feed to the single gradlew publish command
4041
if [ "${{ matrix.java }}" = "8" ]; then

.github/workflows/ci-snapshot.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616
- '*.txt'
1717
jobs:
1818
build:
19-
name: Snapshot JDK ${{ matrix.java }}
19+
name: Snapshot JDK ${{ matrix.java }} Toolchain (Gradle on JDK 21)
2020
runs-on: ubuntu-latest
2121
strategy:
2222
fail-fast: false
@@ -27,10 +27,10 @@ jobs:
2727
uses: actions/checkout@v5
2828
- name: Check SNAPSHOT version suffix
2929
run: if [[ $(cat gradle.properties | grep version= | sed 's/^version=//') =~ .*-SNAPSHOT ]]; then exit 0; else exit 1; fi
30-
- name: Set up JDK ${{ matrix.java }}
30+
- name: Set up JDK 21 (Gradle Execution)
3131
uses: actions/setup-java@v5
3232
with:
33-
java-version: ${{ matrix.java }}
33+
java-version: 21
3434
distribution: 'zulu'
3535
cache: 'gradle'
3636
- name: Print JDK Version
@@ -45,6 +45,7 @@ jobs:
4545
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }}
4646
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
4747
SONATYPE_TOKEN: ${{ secrets.SONATYPE_TOKEN }}
48+
ORG_GRADLE_PROJECT_testJavaVersion: ${{ matrix.java }}
4849
run: |
4950
# Build arguments to feed to the single gradlew publish command
5051
if [ "${{ matrix.java }}" = "8" ]; then

build.gradle

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -50,44 +50,40 @@ buildscript {
5050
}
5151
}
5252
dependencies {
53-
if (JavaVersion.current().isJava11Compatible()) {
54-
classpath("com.autonomousapps:dependency-analysis-gradle-plugin:$dependencyAnalysisPluginVersion")
55-
}
53+
// With toolchains, the dependency analysis plugin can always be applied since Gradle runs on JDK 17+
54+
classpath("com.autonomousapps:dependency-analysis-gradle-plugin:$dependencyAnalysisPluginVersion")
5655
}
5756
}
5857

5958
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-root"
6059

61-
// Unfortunately, we can not make this validation part of our servicetalk-gradle-plugin-internal because it requires
62-
// JDK11 while we build and package our plugin with JDK8.
63-
if (JavaVersion.current().isJava11Compatible()) {
64-
apply plugin: "com.autonomousapps.dependency-analysis"
60+
// With toolchains, Gradle always runs on JDK 17+ so dependency analysis can always be applied
61+
apply plugin: "com.autonomousapps.dependency-analysis"
6562

66-
dependencyAnalysis {
67-
issues {
68-
all {
69-
onAny {
70-
severity("fail")
71-
}
72-
onUnusedDependencies {
73-
// We use it for log4j2.xml configuration
74-
exclude(":servicetalk-test-resources")
75-
}
76-
onUsedTransitiveDependencies {
77-
// We import it as api dependency via :servicetalk-annotations
78-
exclude("com.google.code.findbugs:jsr305")
79-
}
80-
onIncorrectConfiguration {
81-
// We import it as api dependency via :servicetalk-annotations
82-
exclude("com.google.code.findbugs:jsr305")
83-
}
63+
dependencyAnalysis {
64+
issues {
65+
all {
66+
onAny {
67+
severity("fail")
68+
}
69+
onUnusedDependencies {
70+
// We use it for log4j2.xml configuration
71+
exclude(":servicetalk-test-resources")
72+
}
73+
onUsedTransitiveDependencies {
74+
// We import it as api dependency via :servicetalk-annotations
75+
exclude("com.google.code.findbugs:jsr305")
76+
}
77+
onIncorrectConfiguration {
78+
// We import it as api dependency via :servicetalk-annotations
79+
exclude("com.google.code.findbugs:jsr305")
8480
}
8581
}
8682
}
87-
88-
quality.dependsOn buildHealth
8983
}
9084

85+
quality.dependsOn buildHealth
86+
9187
task validateLocalDocSite(type: Exec) {
9288
group = 'Documentation'
9389
description = 'Generate and validate servicetalk.io site documentation'
@@ -97,8 +93,11 @@ task validateLocalDocSite(type: Exec) {
9793
quality.dependsOn validateLocalDocSite
9894

9995
subprojects {
100-
// mockito 5 only supports jdk11+
101-
if (JavaVersion.current() < JavaVersion.VERSION_11) {
96+
// mockito 5 only supports jdk11+, but with toolchains we check the toolchain version, not Gradle's JVM
97+
def toolchainVersion = project.hasProperty('testJavaVersion')
98+
? Integer.parseInt(project.property('testJavaVersion').toString())
99+
: 8
100+
if (toolchainVersion < 11) {
102101
project.setProperty("mockitoCoreVersion", mockitoCorePreJdk11Version)
103102
} else {
104103
apply plugin: "com.autonomousapps.dependency-analysis"

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ org.gradle.parallel=true
1919
org.gradle.caching=true
2020
org.gradle.configureondemand=true
2121
org.gradle.java.installations.auto-download=false
22+
org.gradle.java.installations.auto-detect=true
2223
org.gradle.jvmargs=-Xms2g -Xmx4g -dsa -da -ea:io.servicetalk... -XX:+HeapDumpOnOutOfMemoryError
2324

2425
# project metadata used for publications

servicetalk-concurrent-jdkflow/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"
1919
// Required version for module
2020
def javaLanguageVersion = JavaVersion.VERSION_1_9
2121

22-
if (!JavaVersion.current().isCompatibleWith(javaLanguageVersion)) {
22+
def toolchainVersion = project.hasProperty('testJavaVersion')
23+
? Integer.parseInt(project.property('testJavaVersion').toString())
24+
: 8
25+
if (toolchainVersion < Integer.parseInt(javaLanguageVersion.getMajorVersion())) {
2326
project.tasks.all { task -> task.enabled = false }
2427
}
2528

servicetalk-data-jackson-jersey3-jakarta10/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"
1919
// Required version for module
2020
def javaLanguageVersion = JavaVersion.VERSION_11
2121

22-
if (!JavaVersion.current().isCompatibleWith(javaLanguageVersion)) {
22+
def toolchainVersion = project.hasProperty('testJavaVersion')
23+
? Integer.parseInt(project.property('testJavaVersion').toString())
24+
: 8
25+
if (toolchainVersion < Integer.parseInt(javaLanguageVersion.getMajorVersion())) {
2326
project.tasks.all { task -> task.enabled = false }
2427
}
2528

servicetalk-data-jackson-jersey3-jakarta9/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"
1919
// Required version for module
2020
def javaLanguageVersion = JavaVersion.VERSION_11
2121

22-
if (!JavaVersion.current().isCompatibleWith(javaLanguageVersion)) {
22+
def toolchainVersion = project.hasProperty('testJavaVersion')
23+
? Integer.parseInt(project.property('testJavaVersion').toString())
24+
: 8
25+
if (toolchainVersion < Integer.parseInt(javaLanguageVersion.getMajorVersion())) {
2326
project.tasks.all { task -> task.enabled = false }
2427
}
2528

0 commit comments

Comments
 (0)