Skip to content

Commit 2abb366

Browse files
committed
Upgrade Gradle from 8.1 to 8.8
1 parent cbb7466 commit 2abb366

File tree

8 files changed

+57
-104
lines changed

8 files changed

+57
-104
lines changed

build.gradle

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
import org.gradle.jvm.toolchain.JavaLanguageVersion
23

34
plugins {
45
id 'java-library'
5-
id 'org.jetbrains.kotlin.jvm' version '1.8.0'
6-
id "org.jetbrains.kotlin.plugin.serialization" version "1.8.0"
6+
id 'org.jetbrains.kotlin.jvm' version '2.0.20'
7+
id "org.jetbrains.kotlin.plugin.serialization" version "2.0.20"
78
id 'com.diffplug.spotless' version '6.16.0'
89
id 'org.sonarqube' version '4.0.0.2929'
910
id("org.jetbrains.kotlinx.kover") version "0.7.0"
@@ -16,12 +17,18 @@ group = 'com.worksap.nlp'
1617
archivesBaseName = 'analysis-sudachi'
1718
version = properties["pluginVersion"]
1819

20+
java {
21+
toolchain {
22+
languageVersion = JavaLanguageVersion.of(21)
23+
}
24+
}
25+
1926
compileKotlin {
20-
compilerOptions.jvmTarget.set(JvmTarget.JVM_17)
27+
compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
2128
}
2229

2330
compileTestKotlin {
24-
compilerOptions.jvmTarget.set(JvmTarget.JVM_17)
31+
compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
2532
}
2633

2734
configurations {

buildSrc/src/main/groovy/com/worksap/nlp/tools/EsConventions.groovy

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,10 @@ package com.worksap.nlp.tools
22

33
import org.gradle.api.Plugin
44
import org.gradle.api.Project
5-
import org.gradle.api.tasks.compile.JavaCompile
65

76
class EsConventions implements Plugin<Project> {
87
@Override
98
void apply(Project target) {
10-
target.tasks.withType(JavaCompile).configureEach {
11-
options.release.set(17)
12-
options.encoding = 'UTF-8'
13-
}
14-
15-
169
target.repositories {
1710
mavenLocal()
1811
mavenCentral()

buildSrc/src/main/groovy/com/worksap/nlp/tools/EsTestEnvPlugin.groovy

Lines changed: 36 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.worksap.nlp.tools
22

33
import org.gradle.api.Plugin
44
import org.gradle.api.Project
5+
import org.gradle.api.Action
56
import org.gradle.api.Task
67
import org.gradle.api.Transformer
78
import org.gradle.api.model.ObjectFactory
@@ -49,67 +50,6 @@ class PluginDescriptor {
4950
}
5051
}
5152

52-
class StringProvider implements Provider<String>, Serializable {
53-
private static final long serialVersionUID = 42L
54-
String value
55-
56-
@Override
57-
String get() {
58-
return value
59-
}
60-
61-
@Override
62-
String getOrNull() {
63-
return value
64-
}
65-
66-
@Override
67-
String getOrElse(String defaultValue) {
68-
if (value == null) return defaultValue else return value
69-
}
70-
71-
@Override
72-
def <S> Provider<S> map(Transformer<? extends S, ? super String> transformer) {
73-
throw new IllegalStateException("not implemented")
74-
}
75-
76-
@Override
77-
def <S> Provider<S> flatMap(Transformer<? extends Provider<? extends S>, ? super String> transformer) {
78-
throw new IllegalStateException("not implemented")
79-
}
80-
81-
@Override
82-
boolean isPresent() {
83-
return value != null
84-
}
85-
86-
@Override
87-
Provider<String> orElse(String value) {
88-
return this
89-
}
90-
91-
@Override
92-
Provider<String> orElse(Provider<? extends String> provider) {
93-
if (value == null) return provider else return this
94-
}
95-
96-
@Override
97-
Provider<String> forUseAtConfigurationTime() {
98-
return this
99-
}
100-
101-
@Override
102-
def <U, R> Provider<R> zip(Provider<U> right, BiFunction<? super String, ? super U, ? extends R> combiner) {
103-
throw new IllegalStateException("not implemented")
104-
}
105-
106-
107-
@Override
108-
String toString() {
109-
return value;
110-
}
111-
}
112-
11353
class EsTestEnvPlugin implements Plugin<Project> {
11454

11555
private final ObjectFactory objectFactory
@@ -124,14 +64,28 @@ class EsTestEnvPlugin implements Plugin<Project> {
12464
EsTestEnvExtension ext = new EsTestEnvExtension()
12565
target.extensions.add(EsTestEnvExtension.class, "esTestEnv", ext)
12666
target.tasks.named("test").configure { Test task ->
127-
Provider<String> envRoot = new StringProvider()
67+
// Determine the final, unique path for this test run during the configuration phase.
68+
// This is required because the test JVM is forked before the task's actions run,
69+
// and it needs java.io.tmpdir to exist on startup. A newer/faster JDK can expose
70+
// this timing issue.
71+
def formatter = DateTimeFormatter.ofPattern("yyyyMMdd-HH-mm-ss-SSS", Locale.ROOT)
72+
def now = Instant.now().atZone(ZoneId.of("UTC"))
73+
def timepart = formatter.format(now)
12874
Path esHomePath = target.buildDir.toPath().resolve("es-env")
129-
envRoot.setValue(esHomePath.toString())
130-
task.systemProperty("sudachi.es.root", envRoot)
75+
Path finalEnvRootPath = esHomePath.resolve(timepart)
76+
77+
// Create the directory during configuration. This is generally an anti-pattern,
78+
// but necessary to prevent the "java.io.tmpdir directory does not exist" warning from the forked JVM.
79+
Files.createDirectories(finalEnvRootPath)
80+
81+
task.systemProperty("sudachi.es.root", finalEnvRootPath.toString())
82+
task.systemProperty("java.io.tmpdir", finalEnvRootPath.toString())
83+
13184
task.doFirst {
132-
envRoot.setValue(prepareEnvironment(target, task, esHomePath, ext).toString())
85+
// The root directory is already created, just populate it with files.
86+
populateEnvironment(target, task, finalEnvRootPath, ext)
13387
}
134-
task.doLast { cleanupEnvironment(esHomePath) }
88+
task.doLast { cleanupEnvironment(target, esHomePath) }
13589
ext.additionalPlugins.forEach {
13690
if (it.value instanceof TaskProvider || it.value instanceof Task) {
13791
dependsOn(it.value)
@@ -147,7 +101,18 @@ class EsTestEnvPlugin implements Plugin<Project> {
147101
task.systemProperty("tests.task", task.getPath())
148102
task.systemProperty("gradle.dist.lib", gradleRtDir.resolve("lib").toString())
149103
task.systemProperty("gradle.worker.jar", gradleCacheDir.resolve("workerMain/gradle-worker.jar").toString())
150-
task.systemProperty("java.io.tmpdir", envRoot)
104+
105+
// OpenSearch test framework requires reflective access to JDK internals, which is restricted on Java 17+.
106+
// It also uses a Security Manager, which is disabled by default in Java 17+.
107+
// We need to add JVM arguments to re-enable these features for the tests to run.
108+
def esExtension = target.extensions.findByName("sudachiEs")
109+
if (esExtension != null && esExtension.kind.get().engine == EngineType.OpenSearch) {
110+
task.jvmArgs(
111+
'--add-opens=java.base/java.lang=ALL-UNNAMED'
112+
)
113+
// Allow the test framework to set a Security Manager
114+
task.systemProperty("java.security.manager", "allow")
115+
}
151116
}
152117

153118
target.gradle.taskGraph.whenReady {
@@ -172,12 +137,8 @@ class EsTestEnvPlugin implements Plugin<Project> {
172137
}
173138
}
174139

175-
private Path prepareEnvironment(Project project, Test testTask, Path basePath, EsTestEnvExtension ext) {
176-
def formatter = DateTimeFormatter.ofPattern("yyyyMMdd-HH-mm-ss", Locale.ROOT)
177-
def now = Instant.now().atZone(ZoneId.of("UTC"))
178-
def timepart = formatter.format(now)
179-
def rootPath = basePath.resolve(timepart)
180-
140+
/** Populates the pre-created environment directory with necessary files for the test run. */
141+
private void populateEnvironment(Project project, Test testTask, Path rootPath, EsTestEnvExtension ext) {
181142
def pluginDir = rootPath.resolve("plugins")
182143
def configPath = rootPath.resolve("config")
183144

@@ -204,12 +165,10 @@ class EsTestEnvPlugin implements Plugin<Project> {
204165
Files.createDirectories(sudachiConfigDir)
205166
Files.copy(ext.systemDic, sudachiConfigDir.resolve("system_core.dic"))
206167
Files.copy(ext.configFile, sudachiConfigDir.resolve("sudachi.json"))
207-
208-
return rootPath
209168
}
210169

211-
private void cleanupEnvironment(Path envPath) {
212-
170+
private void cleanupEnvironment(Project project, Path envPath) {
171+
// project.delete(envPath)
213172
}
214173

215174

@@ -273,5 +232,3 @@ class EsTestEnvPlugin implements Plugin<Project> {
273232
.writeTo(outputStream.newWriter('utf-8'))
274233
}
275234
}
276-
277-

gradle.properties

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
# opensearch version: 2.18.0, 2.17.1, 2.16.0, 2.15.0, 2.14.0, 2.13.0, 2.12.0, 2.11.1,
44
# 2.10.0, 2.9.0, 2.8.0, 2.7.0, 2.6.0
55
engineVersion=es:8.19.2
6-
org.gradle.jvmargs=-XX:MaxMetaspaceSize=350m \
7-
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
8-
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
9-
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
10-
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
11-
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
6+
org.gradle.jvmargs=-XX:MaxMetaspaceSize=350m
127
org.gradle.caching=true
138
org.gradle.parallel=true
149
pluginVersion=3.3.1-SNAPSHOT

gradle/wrapper/gradle-wrapper.jar

502 Bytes
Binary file not shown.
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.1.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

gradlew

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ done
8585
APP_BASE_NAME=${0##*/}
8686
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
8787

88-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90-
9188
# Use the maximum available, or set MAX_FD != -1 to use that value.
9289
MAX_FD=maximum
9390

@@ -144,15 +141,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144141
case $MAX_FD in #(
145142
max*)
146143
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147-
# shellcheck disable=SC3045
144+
# shellcheck disable=SC3045
148145
MAX_FD=$( ulimit -H -n ) ||
149146
warn "Could not query maximum file descriptor limit"
150147
esac
151148
case $MAX_FD in #(
152149
'' | soft) :;; #(
153150
*)
154151
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155-
# shellcheck disable=SC3045
152+
# shellcheck disable=SC3045
156153
ulimit -n "$MAX_FD" ||
157154
warn "Could not set maximum file descriptor limit to $MAX_FD"
158155
esac
@@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then
197194
done
198195
fi
199196

197+
198+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
199+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
200+
200201
# Collect all arguments for the java command;
201202
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
202203
# shell script including quotes and variable substitutions, so put them in

integration/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ plugins {
1414
version = properties["pluginVersion"]
1515

1616
compileKotlin {
17-
compilerOptions.jvmTarget.set(JvmTarget.JVM_17)
17+
compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
1818
}
1919

2020
compileTestKotlin {
21-
compilerOptions.jvmTarget.set(JvmTarget.JVM_17)
21+
compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
2222
}
2323

2424
configurations { buildSudachiDict }

0 commit comments

Comments
 (0)