Skip to content

Commit e81cfaf

Browse files
authored
4.x: Add optional build/test for future JDKs (#8077)
* 4.x: Add optional build/test for future JDKs * try temurin builds * use toolchain override * Run Gradle on 26, invoke toolchain for 27 * Minor log fix * hope gradle runs on 26 * Don't run jacoco on EA as it breaks its assembly parser * another attempt at running Gradle on 26 and code on 27 * Fix jacoco again * fix java home * No jacoco for experimentals
1 parent 7603054 commit e81cfaf

File tree

2 files changed

+86
-12
lines changed

2 files changed

+86
-12
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# This workflow will build a Java project with Gradle
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
3+
4+
name: Preview-JDKs
5+
6+
on:
7+
push:
8+
branches: [ '4.x' ]
9+
pull_request:
10+
branches: [ '4.x' ]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
continue-on-error: true
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
jdk: [27] # add 28-ea etc. later
23+
24+
steps:
25+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
26+
- name: Set up JDK 26
27+
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
28+
with:
29+
distribution: 'zulu'
30+
java-version: '26'
31+
cache: gradle
32+
33+
- name: Set up JDK ${{ matrix.jdk }}-ea
34+
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
35+
with:
36+
distribution: 'temurin'
37+
java-version: '${{ matrix.jdk }}-ea'
38+
39+
- name: Cache Gradle packages
40+
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
41+
with:
42+
path: ~/.gradle/caches
43+
key: ${{ runner.os }}-gradle-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/*.gradle') }}
44+
restore-keys: ${{ runner.os }}-gradle-${{ secrets.CACHE_VERSION }}
45+
- name: Grant execute permission for gradlew
46+
run: chmod +x gradlew
47+
48+
- name: Run Validity Tests Upfront
49+
env:
50+
JDK_EXPERIMENTAL: ${{ matrix.jdk }}
51+
JAVA_HOME: ${{ env.JAVA_HOME_26_X64 }}
52+
run: ./gradlew test --tests "io.reactivex.rxjava4.validators.*" --stacktrace --no-daemon
53+
- name: Build RxJava
54+
env:
55+
JDK_EXPERIMENTAL: ${{ matrix.jdk }}
56+
JAVA_HOME: ${{ env.JAVA_HOME_26_X64 }}
57+
run: ./gradlew build --stacktrace
58+
- name: Generate Javadoc
59+
env:
60+
JDK_EXPERIMENTAL: ${{ matrix.jdk }}
61+
JAVA_HOME: ${{ env.JAVA_HOME_26_X64 }}
62+
run: ./gradlew javadoc --stacktrace
63+

build.gradle

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ plugins {
33
id("java-library")
44
id("checkstyle")
55
id("eclipse")
6-
id("jacoco")
76
id("maven-publish")
87
id("me.champeau.jmh") version "0.7.3"
98
id("com.github.hierynomus.license") version "0.16.1"
@@ -54,10 +53,17 @@ dependencies {
5453
testRuntimeOnly "org.junit.platform:junit-platform-launcher:$jupiterLauncherVersion" // match your JUnit version family
5554
}
5655

56+
// === Experimental JDK handling for Outreach Program ===
57+
def experimental = System.getenv("JDK_EXPERIMENTAL")
58+
def toolchainJdk = "26" // default / baseline
59+
60+
if (experimental != null && !experimental.trim().isEmpty()) {
61+
toolchainJdk = experimental // e.g. "27"
62+
}
63+
5764
java {
5865
toolchain {
59-
// vendor = JvmVendorSpec.ADOPTIUM <-- for now
60-
languageVersion = JavaLanguageVersion.of(26)
66+
languageVersion = JavaLanguageVersion.of(toolchainJdk)
6167
}
6268
sourceCompatibility = JavaVersion.VERSION_26
6369
targetCompatibility = JavaVersion.VERSION_26
@@ -256,18 +262,23 @@ tasks.withType(Test) {
256262
}
257263
}
258264

259-
jacocoTestReport {
260-
dependsOn test
261-
dependsOn testNG
262-
263-
reports {
264-
xml.required.set(true)
265-
csv.required.set(false)
266-
html.required.set(true)
265+
if (experimental == null || "".equals(experimental)) {
266+
apply plugin: "jacoco"
267+
268+
jacocoTestReport {
269+
dependsOn test
270+
dependsOn testNG
271+
272+
reports {
273+
xml.required.set(true)
274+
csv.required.set(false)
275+
html.required.set(true)
276+
}
267277
}
278+
279+
check.dependsOn jacocoTestReport
268280
}
269281

270-
check.dependsOn jacocoTestReport
271282

272283
checkstyle {
273284
configFile = project.file("config/checkstyle/checkstyle.xml")

0 commit comments

Comments
 (0)