Skip to content

Commit b496edf

Browse files
committed
upgrade to support java 25 and gradle 9.2.1
1 parent b6b5d3b commit b496edf

File tree

4 files changed

+62
-16
lines changed

4 files changed

+62
-16
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88

99
strategy:
1010
matrix:
11-
version: [ 24 ]
11+
version: [ 25 ]
1212
vector-length: [ 256, 512 ]
1313

1414
steps:

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ jobs:
1717

1818
- uses: gradle/actions/wrapper-validation@v4
1919

20-
- name: Set up JDK 24
20+
- name: Set up JDK 25
2121
uses: actions/setup-java@v4
2222
with:
2323
distribution: temurin
24-
java-version: 24
24+
java-version: 25
2525

2626
- name: Setup Gradle
2727
uses: gradle/actions/setup-gradle@v3

build.gradle

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,52 @@ repositories {
2828
mavenCentral()
2929
}
3030

31+
// Dynamically resolve Java major version from:
32+
// 1) env BUILD_JAVA_VERSION (if set), else
33+
// 2) the JVM running Gradle (JavaVersion.current().majorVersion)
34+
//
35+
// Accepts values like: "24", "24.0.1", "24-ea", "24.0.2-tem", etc.
36+
static int resolveBuildJavaVersion() {
37+
String v = System.getenv('BUILD_JAVA_VERSION') ?: JavaVersion.current().majorVersion
38+
39+
int dot = v.indexOf('.')
40+
if (dot >= 0) {
41+
v = v.substring(0, dot)
42+
}
43+
44+
int dash = v.indexOf('-')
45+
if (dash >= 0) {
46+
v = v.substring(0, dash)
47+
}
48+
49+
try {
50+
return Integer.parseInt(v)
51+
} catch (Exception e) {
52+
throw new GradleException("Invalid BUILD_JAVA_VERSION '${System.getenv('BUILD_JAVA_VERSION')}'. " +
53+
"Expected a Java major version like '24' (optionally with suffixes like '24.0.1' or '24-ea').", e)
54+
}
55+
}
56+
57+
// Usage
58+
def buildJavaVersion = resolveBuildJavaVersion()
59+
60+
// recommended build java version is 25
61+
if (buildJavaVersion < 24) {
62+
throw new GradleException(
63+
"This build requires Java 24+.\n" +
64+
"Detected buildJavaVersion=${buildJavaVersion}.\n" +
65+
"Either run Gradle with JDK 24+ (JAVA_HOME / PATH), or set BUILD_JAVA_VERSION=24 (or higher)."
66+
)
67+
}
68+
3169
java {
32-
// It seems that specifying the minimum supported Java version while allowing the use of newer
33-
// ones isn't possible in Gradle. To test the library against multiple Java versions, the
34-
// workaround proposed in https://github.com/gradle/gradle/issues/16256 has been applied:
35-
if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_24)) {
36-
toolchain {
37-
languageVersion = JavaLanguageVersion.of(24)
38-
}
70+
toolchain {
71+
languageVersion = JavaLanguageVersion.of(buildJavaVersion)
3972
}
4073
withJavadocJar()
4174
withSourcesJar()
75+
sourceCompatibility = JavaVersion.toVersion(buildJavaVersion)
76+
targetCompatibility = JavaVersion.toVersion(buildJavaVersion)
4277
}
4378

4479
ext {
@@ -99,7 +134,9 @@ tasks.withType(Test).configureEach {
99134
}
100135

101136
tasks.register('test256', Test) {
102-
dependsOn downloadTestData
137+
// IMPORTANT: run the normal test task first (no cycles)
138+
dependsOn tasks.named('test')
139+
103140
useJUnitPlatform()
104141
jvmArgs += [
105142
'--add-modules', 'jdk.incubator.vector',
@@ -112,7 +149,9 @@ tasks.register('test256', Test) {
112149
}
113150

114151
tasks.register('test512', Test) {
115-
dependsOn downloadTestData
152+
// IMPORTANT: run the normal test task first (no cycles)
153+
dependsOn tasks.named('test')
154+
116155
useJUnitPlatform()
117156
jvmArgs += [
118157
'--add-modules', 'jdk.incubator.vector',
@@ -131,14 +170,17 @@ test {
131170
jvmArgs += [
132171
'--add-modules', 'jdk.incubator.vector', '-Xmx2g'
133172
]
134-
// still run the vector-width-specific tasks first
135-
dependsOn 'test256'
136-
dependsOn 'test512'
137173

138-
// and don't blow up if this particular task finds nothing
174+
// Don't blow up if this particular task finds nothing
139175
failOnNoDiscoveredTests = false
140176
}
141177

178+
// Recommended: `./gradlew check` runs all test variants
179+
tasks.named('check') {
180+
dependsOn tasks.named('test256')
181+
dependsOn tasks.named('test512')
182+
}
183+
142184
tasks.withType(JmhBytecodeGeneratorTask).configureEach {
143185
jvmArgs.set(["--add-modules=jdk.incubator.vector"])
144186
}

settings.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
plugins {
2+
id("org.gradle.toolchains.foojay-resolver-convention") version "0.10.0"
3+
}
4+
15
rootProject.name = 'simdjson-java'

0 commit comments

Comments
 (0)