Skip to content

Commit 9d6ec32

Browse files
authored
upgrade to support java 25 and gradle 9.2.1 (#75)
1 parent 203bc80 commit 9d6ec32

File tree

9 files changed

+185
-63
lines changed

9 files changed

+185
-63
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

.gitignore

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,59 @@
1+
build/
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
.DS_Store
5+
out/
6+
generated/
7+
generated_tests/
8+
generated-resources-dir/
9+
bin/
10+
*.swp
11+
12+
# python
13+
__pycache__
14+
venv
15+
.pyc
16+
17+
# Compiled class file
18+
*.class
19+
20+
# Log file
21+
*.log
22+
*.log*
23+
24+
# BlueJ files
25+
*.ctxt
26+
27+
# Mobile Tools for Java (J2ME)
28+
.mtj.tmp/
29+
30+
# Package Files #
31+
*.jar
32+
*.war
33+
*.nar
34+
*.ear
35+
*.zip
36+
*.tar.gz
37+
*.rar
38+
39+
### STS ###
40+
.apt_generated
41+
.classpath
42+
.factorypath
43+
.project
44+
.settings
45+
.springBeans
46+
.gradle/*
47+
48+
### IntelliJ IDEA ###
149
.idea
2-
.gradle
3-
build
4-
profilers
5-
testdata
6-
hotspot_*.log
50+
*.iws
51+
*.iml
52+
*.ipr
53+
#### Intellij run configuration
54+
.run/
55+
56+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
57+
hs_err_pid*
58+
replay_pid*
59+
*/.gradle/*

build.gradle

Lines changed: 117 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import me.champeau.jmh.JmhBytecodeGeneratorTask
2-
import org.ajoberstar.grgit.Grgit
32
import org.gradle.internal.os.OperatingSystem
43

54
import java.time.Duration
@@ -8,17 +7,16 @@ plugins {
87
id 'java'
98
id 'scala'
109
id 'me.champeau.jmh' version '0.7.1'
11-
id 'org.ajoberstar.grgit' version '5.2.0'
12-
id 'pl.allegro.tech.build.axion-release' version '1.15.5'
13-
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
10+
id 'pl.allegro.tech.build.axion-release' version '1.21.1'
11+
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
1412
id 'maven-publish'
1513
id 'signing'
1614
}
1715

1816
scmVersion {
1917
versionCreator('versionWithBranch')
2018
tag {
21-
prefix = ''
19+
prefix.set('')
2220
}
2321
}
2422

@@ -29,17 +27,46 @@ repositories {
2927
mavenCentral()
3028
}
3129

30+
// --- Java Version Resolution ---
31+
static int resolveBuildJavaVersion() {
32+
String v = System.getenv('BUILD_JAVA_VERSION') ?: JavaVersion.current().majorVersion
33+
34+
int dot = v.indexOf('.')
35+
if (dot >= 0) {
36+
v = v.substring(0, dot)
37+
}
38+
39+
int dash = v.indexOf('-')
40+
if (dash >= 0) {
41+
v = v.substring(0, dash)
42+
}
43+
44+
try {
45+
return Integer.parseInt(v)
46+
} catch (Exception e) {
47+
throw new GradleException("Invalid BUILD_JAVA_VERSION '${System.getenv('BUILD_JAVA_VERSION')}'. " +
48+
"Expected a Java major version like '24' (optionally with suffixes like '24.0.1' or '24-ea').", e)
49+
}
50+
}
51+
52+
def buildJavaVersion = resolveBuildJavaVersion()
53+
54+
if (buildJavaVersion < 24) {
55+
throw new GradleException(
56+
"This build requires Java 24+.\n" +
57+
"Detected buildJavaVersion=${buildJavaVersion}.\n" +
58+
"Either run Gradle with JDK 24+ (JAVA_HOME / PATH), or set BUILD_JAVA_VERSION=24 (or higher)."
59+
)
60+
}
61+
3262
java {
33-
// It seems that specifying the minimum supported Java version while allowing the use of newer
34-
// ones isn't possible in Gradle. To test the library against multiple Java versions, the
35-
// workaround proposed in https://github.com/gradle/gradle/issues/16256 has been applied:
36-
if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_24)) {
37-
toolchain {
38-
languageVersion = JavaLanguageVersion.of(24)
39-
}
63+
toolchain {
64+
languageVersion = JavaLanguageVersion.of(buildJavaVersion)
4065
}
4166
withJavadocJar()
4267
withSourcesJar()
68+
sourceCompatibility = JavaVersion.toVersion(buildJavaVersion)
69+
targetCompatibility = JavaVersion.toVersion(buildJavaVersion)
4370
}
4471

4572
ext {
@@ -62,49 +89,86 @@ dependencies {
6289
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: junitVersion
6390
}
6491

65-
tasks.register('downloadTestData') {
66-
doFirst {
67-
def testDataDir = new File("${project.projectDir.getAbsolutePath()}/testdata")
68-
if (!testDataDir.exists()) {
69-
testDataDir.mkdir()
70-
}
71-
def numbersTestDataDir = new File("${testDataDir}/parse-number-fxx-test-data")
72-
if (!numbersTestDataDir.exists()) {
73-
def grgit = Grgit.clone(dir: numbersTestDataDir, uri: 'https://github.com/nigeltao/parse-number-fxx-test-data.git')
74-
grgit.close()
92+
// --- Test Data Preparation ---
93+
def testdataParent = layout.projectDirectory.dir("testdata")
94+
def repoDir = testdataParent.dir("parse-number-fxx-test-data")
95+
96+
tasks.register('prepareTestDataDir') {
97+
description = 'Create testdata/ directory if missing'
98+
doLast {
99+
def parent = testdataParent.asFile
100+
if (!parent.exists()) {
101+
logger.lifecycle("Creating ${parent}")
102+
parent.mkdirs()
75103
}
76104
}
77105
}
78106

79-
tasks.register('test256', Test) {
80-
dependsOn downloadTestData
81-
useJUnitPlatform()
82-
jvmArgs += [
83-
'--add-modules', 'jdk.incubator.vector',
84-
'-Xmx2g',
85-
'-Dorg.simdjson.species=256'
86-
]
107+
tasks.register('downloadTestData', Exec) {
108+
description = 'Clone parse-number-fxx-test-data into testdata/ if missing'
109+
group = 'verification'
110+
dependsOn tasks.named('prepareTestDataDir')
111+
112+
// Run if repo dir missing OR empty (handles half-created directories)
113+
onlyIf {
114+
def d = repoDir.asFile
115+
!d.exists() || (d.isDirectory() && (d.listFiles() == null || d.listFiles().length == 0))
116+
}
117+
118+
workingDir testdataParent.asFile
119+
commandLine 'git', 'clone', 'https://github.com/nigeltao/parse-number-fxx-test-data.git', 'parse-number-fxx-test-data'
120+
121+
doFirst {
122+
logger.lifecycle("Cloning parse-number-fxx-test-data into ${repoDir.asFile}")
123+
}
124+
}
125+
126+
// Configuration common to ALL Test tasks (including 'test', 'test256', 'test512')
127+
tasks.withType(Test).configureEach {
128+
dependsOn tasks.named('downloadTestData')
129+
130+
// Fix: Ensure logging is visible in the console
87131
testLogging {
132+
showStandardStreams = true
88133
events 'PASSED', 'SKIPPED', 'FAILED', 'STANDARD_OUT', 'STANDARD_ERROR'
134+
exceptionFormat = 'full'
135+
showExceptions = true
136+
showCauses = true
137+
showStackTraces = true
89138
}
90139
}
91140

92-
tasks.register('test512', Test) {
93-
dependsOn downloadTestData
141+
// --- Test Variants (256/512) ---
142+
test {
94143
useJUnitPlatform()
95144
jvmArgs += [
96-
'--add-modules', 'jdk.incubator.vector',
97-
'-Xmx2g',
98-
'-Dorg.simdjson.species=512'
145+
'--add-modules', 'jdk.incubator.vector', '-Xmx2g'
99146
]
100-
testLogging {
101-
events 'PASSED', 'SKIPPED', 'FAILED', 'STANDARD_OUT', 'STANDARD_ERROR'
147+
failOnNoDiscoveredTests = false
148+
}
149+
150+
// Generate test tasks for specific species (256, 512)
151+
[256, 512].each { species ->
152+
tasks.register("test${species}", Test) {
153+
group = 'verification'
154+
description = "Runs tests with org.simdjson.species=${species}"
155+
156+
// Fix: Removed 'dependsOn test'. This allows test256 to run independently.
157+
// We use mustRunAfter so they don't interleave output if run together via 'check'.
158+
dependsOn tasks.named('test')
159+
160+
useJUnitPlatform()
161+
jvmArgs += [
162+
'--add-modules', 'jdk.incubator.vector',
163+
'-Xmx2g',
164+
"-Dorg.simdjson.species=${species}"
165+
]
102166
}
103167
}
104168

105-
test {
106-
dependsOn 'test256'
107-
dependsOn 'test512'
169+
tasks.named('check') {
170+
dependsOn tasks.named('test256')
171+
dependsOn tasks.named('test512')
108172
}
109173

110174
tasks.withType(JmhBytecodeGeneratorTask).configureEach {
@@ -116,7 +180,6 @@ tasks.withType(JavaCompile).configureEach {
116180
}
117181

118182
tasks.compileJmhScala.classpath = sourceSets.main.compileClasspath
119-
120183
tasks.compileJmhJava.classpath += files(sourceSets.jmh.scala.classesDirectory)
121184

122185
compileTestJava {
@@ -206,15 +269,21 @@ if (System.getenv('GPG_KEY_ID')) {
206269
nexusPublishing {
207270
repositories {
208271
sonatype {
209-
nexusUrl = uri("https://ossrh-staging-api.central.sonatype.com/service/local/")
210-
snapshotRepositoryUrl = uri("https://central.sonatype.com/repository/maven-snapshots/")
211-
stagingProfileId = '3c0bbfe420699e'
212-
username = System.getenv('SONATYPE_USERNAME')
213-
password = System.getenv('SONATYPE_PASSWORD')
272+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
273+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
274+
275+
if (System.getenv('SONATYPE_USERNAME')) {
276+
username.set(System.getenv('SONATYPE_USERNAME'))
277+
}
278+
if (System.getenv('SONATYPE_PASSWORD')) {
279+
password.set(System.getenv('SONATYPE_PASSWORD'))
280+
}
281+
282+
stagingProfileId.set('3c0bbfe420699e')
214283
}
215284
}
216-
connectTimeout = Duration.ofMinutes(3)
217-
clientTimeout = Duration.ofMinutes(3)
285+
connectTimeout.set(Duration.ofMinutes(3))
286+
clientTimeout.set(Duration.ofMinutes(3))
218287
}
219288

220289
def getBooleanProperty(String name, boolean defaultValue) {

gradle/wrapper/gradle-wrapper.jar

1.83 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 1 addition & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradlew.bat

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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)