Skip to content

Commit 92432a8

Browse files
soloturnclaude
andcommitted
build: bump wrapper to Gradle 9.7.0, clear the blockers and deprecations
Gradle 9.7.0 ships Kotlin 2.4, which enforces Transformer's declared OUT : Any bound. ContentFilterable.filter takes Transformer<String?, String> - the OUT is nullable because returning null there drops the line - so naming that type is now a compile error (KTLC-358), and facades/PC named it twice: implementing the interface, and casting to it. The net effect is that Gradle's own API is not implementable from the Kotlin that Gradle ships with. Passing a lambda instead lets SAM conversion supply the type argument, so the script never names it; ScriptClasspathRewriter keeps its logic and never returned null anyway. That was a prerequisite for the bump rather than a consequence of it: on 9.6.1 Kotlin only warns ("will become an error in language version 2.5"), so the script had to stop naming the type before the wrapper could move. Anyone already running a system Gradle 9.7.0 could not configure this build at all. Only the distributionUrl moves. The wrapper jar and gradlew scripts are left alone - they are just the bootstrapper, and the existing ones drive 9.7.0 fine, so regenerating them would be diff noise. Staying on -bin too: the wrapper task would have switched it to -all, making every CI run additionally download sources and docs. Also clears the Gradle 10 deprecations this repo owns - 100 warnings before, 39 after: - modules/build.gradle.kts passed the Project object itself to api(), once per subproject. Using a Project as dependency notation fails with an error in Gradle 10; it now depends on project(path). - GradleDependencyInfo.asMap() produced the group:/name:/version: map form, which terasology-module.gradle.kts applies to every module. Multi-string notation also fails in Gradle 10, so it now produces single-string "group:module:version". Version ranges are unaffected - they contain no colons, so the coordinate still splits unambiguously. - config/gradle/publish.gradle read publishRepo/mavenUser/mavenPass as bare names, an implicit lookup in a parent project. Those sit inside hasProperty guards, so they would have broken publishing, not building. Every remaining warning traces into libs/gestalt or libs/TeraNUI, which are independent repos reached through includeBuild and need their own PRs. The module-attributed ones were never the module repos' fault: every modules/*/build.gradle is byte-identical to templates/build.gradle and only applies terasology-module, so those were this repo's build-logic reported once per project. Not addressed: the protoc coordinate warning attributed to :engine comes from protobuf-gradle-plugin 0.9.4's own ToolsLocator, which tokenizes the single-string coordinate we give it and rebuilds it as a map. engine/build.gradle.kts is already correct; that needs a plugin upgrade. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 338d7dd commit 92432a8

6 files changed

Lines changed: 16 additions & 16 deletions

File tree

build-logic/src/main/kotlin/org/terasology/gradology/module_build.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ import java.io.File
1616
// or something else from gradle.api.artifacts, but it exposes no concrete implementation
1717
// of those interfaces.
1818
data class GradleDependencyInfo(val group: String, val module: String, val version: String) {
19-
fun asMap(): Map<String, String> {
20-
return mapOf("group" to group, "name" to module, "version" to version)
21-
}
19+
fun asNotation(): String = "$group:$module:$version"
2220
}
2321

2422

build-logic/src/main/kotlin/terasology-module.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ dependencies {
6161
if (optional) {
6262
// `optional` module dependencies are ones it does not require for runtime
6363
// (but will use opportunistically if available)
64-
compileOnly(gradleDep.asMap())
64+
compileOnly(gradleDep.asNotation())
6565
// though modules also sometimes use "optional" to describe their test dependencies;
6666
// they're not required for runtime, but they *are* required for tests.
67-
testImplementation(gradleDep.asMap())
67+
testImplementation(gradleDep.asNotation())
6868
} else {
69-
implementation(gradleDep.asMap())
69+
implementation(gradleDep.asNotation())
7070
}
7171
}
7272

config/gradle/publish.gradle

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ publishing {
1414

1515
if (rootProject.hasProperty("publishRepo")) {
1616
// This first option is good for local testing, you can set a full explicit target repo in gradle.properties
17-
url = "https://artifactory.terasology.io/artifactory/$publishRepo"
18-
logger.info("Changing PUBLISH repoKey set via Gradle property to {}", publishRepo)
17+
String explicitPublishRepo = rootProject.property("publishRepo")
18+
url = "https://artifactory.terasology.io/artifactory/$explicitPublishRepo"
19+
logger.info("Changing PUBLISH repoKey set via Gradle property to {}", explicitPublishRepo)
1920
} else {
2021
// Support override from the environment to use a different target publish org
2122
String deducedPublishRepo = System.getenv()["PUBLISH_ORG"]
@@ -43,8 +44,8 @@ publishing {
4344

4445
if (rootProject.hasProperty("mavenUser") && rootProject.hasProperty("mavenPass")) {
4546
credentials {
46-
username = "$mavenUser"
47-
password = "$mavenPass"
47+
username = rootProject.property("mavenUser")
48+
password = rootProject.property("mavenPass")
4849
}
4950
authentication {
5051
basic(BasicAuthentication)

facades/PC/build.gradle.kts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ val distForLauncher = tasks.register<Zip>("distForLauncher") {
199199
if (this.sourcePath == "Terasology" || this.sourcePath == "Terasology.bat") {
200200
// I don't know how the "lib/" makes its way in to the classpath used by CreateStartScripts,
201201
// so we're adjusting it after-the-fact.
202-
filter(ScriptClasspathRewriter(this, defaultLibraryDirectory, launcherLibraryDirectory) as Transformer<String?, String>)
202+
val rewriter = ScriptClasspathRewriter(this, defaultLibraryDirectory, launcherLibraryDirectory)
203+
filter { line -> rewriter.rewrite(line) }
203204
}
204205
}
205206
})
@@ -242,10 +243,10 @@ tasks.register<Task>("testDist") {
242243
dependsOn("testDistForLauncher", "testDistZip")
243244
}
244245

245-
class ScriptClasspathRewriter(file: FileCopyDetails, val oldDirectory: String, val newDirectory: String) : Transformer<String?, String> {
246+
class ScriptClasspathRewriter(file: FileCopyDetails, val oldDirectory: String, val newDirectory: String) {
246247
private val isBatchFile = file.name.endsWith(".bat")
247248

248-
override fun transform(line: String): String = if (isBatchFile) {
249+
fun rewrite(line: String): String = if (isBatchFile) {
249250
line.replace("$oldDirectory\\", "$newDirectory\\")
250251
} else {
251252
line.replace("$oldDirectory/", "$newDirectory/")

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-9.6.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.0-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

modules/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ javaPlatform {
2121

2222
dependencies {
2323
// This platform depends on each of its subprojects.
24-
subprojects {
25-
api(this)
24+
subprojects.forEach {
25+
api(project(it.path))
2626
}
2727
}
2828

0 commit comments

Comments
 (0)