Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle deprecations #5153

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fun moduleDependencyOrdering(modulesConfig: Configuration): List<String> {

val result = resolvable.resolutionResult
val allDependencies = result.allDependencies
val resolvedDependencies = allDependencies.mapNotNull {
allDependencies.mapNotNull {
if (it is ResolvedDependencyResult) {
return@mapNotNull it
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import java.net.URLClassLoader
tasks.register("cacheReflections") {
description = "Caches reflection output to make regular startup faster. May go stale and need cleanup at times."

val sourceSets = project.convention.getPlugin(JavaPluginConvention::class.java).sourceSets
val sourceSets = project.extensions.getByType(SourceSetContainer::class.java)
val mainSourceSet: SourceSet = sourceSets[SourceSet.MAIN_SOURCE_SET_NAME]

inputs.files(mainSourceSet.output.classesDirs)
Expand Down
8 changes: 4 additions & 4 deletions build-logic/src/main/kotlin/terasology-module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ apply(from = "$rootDir/config/gradle/publish.gradle")
// Handle some logic related to where what is
configure<SourceSetContainer> {
main {
java.destinationDirectory.set(buildDir.resolve("classes"))
java.destinationDirectory.set(layout.buildDirectory.dir("classes"))
}
test {
java.destinationDirectory.set(buildDir.resolve("testClasses"))
java.destinationDirectory.set(layout.buildDirectory.dir("testClasses"))
}
}

Expand Down Expand Up @@ -178,8 +178,8 @@ configure<IdeaModel> {
module {
// Change around the output a bit
inheritOutputDirs = false
outputDir = buildDir.resolve("classes")
testOutputDir = buildDir.resolve("testClasses")
outputDir = layout.buildDirectory.dir("classes").get().asFile
testOutputDir = layout.buildDirectory.dir("testClasses").get().asFile
isDownloadSources = true
}
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ plugins {
// For the "Build and run using: Intellij IDEA | Gradle" switch
id "org.jetbrains.gradle.plugin.idea-ext" version "1.0"

id("com.google.protobuf") version "0.8.16" apply false
id("com.google.protobuf") version "0.9.4" apply false
id("terasology-repositories")
}

Expand Down
4 changes: 2 additions & 2 deletions engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ sourceSets {
}

task jmh(type: JavaExec, dependsOn: jmhClasses) {
main = 'org.openjdk.jmh.Main'
mainClass = 'org.openjdk.jmh.Main'
classpath = sourceSets.jmh.compileClasspath + sourceSets.jmh.runtimeClasspath
}

Expand Down Expand Up @@ -251,7 +251,7 @@ def createVersionInfoFile = tasks.register("createVersionInfoFile", WritePropert
property("dateTime", startDateTimeString)
}

outputFile = "$buildDir/createVersionInfoFile/versionInfo.properties"
destinationFile = layout.buildDirectory.dir("createrVersionInfoFile").get().file("versionInfo.properties")
}

tasks.named("processResources", Copy) {
Expand Down
6 changes: 3 additions & 3 deletions facades/PC/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ val createVersionFile = tasks.register<Copy>("createVersionFile") {

inputs.property("dateTime", startDateTimeString)
from(templatesDir)
into("$buildDir/versionfile")
into(layout.buildDirectory.dir("versionfile").get().asFile)
include(versionFileName)
expand(mapOf(
"buildNumber" to env["BUILD_NUMBER"],
Expand Down Expand Up @@ -205,7 +205,7 @@ val distForLauncher = tasks.register<Zip>("distForLauncher") {
if (this.sourcePath == "Terasology" || this.sourcePath == "Terasology.bat") {
// I don't know how the "lib/" makes its way in to the classpath used by CreateStartScripts,
// so we're adjusting it after-the-fact.
filter(ScriptClasspathRewriter(this, defaultLibraryDirectory, launcherLibraryDirectory))
filter(ScriptClasspathRewriter(this, defaultLibraryDirectory, launcherLibraryDirectory) as Transformer<String?, String>)
}
}
})
Expand Down Expand Up @@ -248,7 +248,7 @@ tasks.register<Task>("testDist") {
dependsOn("testDistForLauncher", "testDistZip")
}

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

override fun transform(line: String): String = if (isBatchFile) {
Expand Down
4 changes: 2 additions & 2 deletions subsystems/DiscordRPC/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ apply(from = "$rootDir/config/gradle/common.gradle")

configure<SourceSetContainer> {
// Adjust output path (changed with the Gradle 6 upgrade, this puts it back)
main { java.destinationDirectory.set(File("$buildDir/classes")) }
test { java.destinationDirectory.set(File("$buildDir/testClasses")) }
main { java.destinationDirectory.set(layout.buildDirectory.dir("classes")) }
test { java.destinationDirectory.set(layout.buildDirectory.dir("testClasses")) }
}

dependencies {
Expand Down
4 changes: 2 additions & 2 deletions subsystems/TypeHandlerLibrary/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ version = project(":engine").version

configure<SourceSetContainer> {
// Adjust output path (changed with the Gradle 6 upgrade, this puts it back)
main { java.destinationDirectory.set(File("$buildDir/classes")) }
test { java.destinationDirectory.set(File("$buildDir/testClasses")) }
main { java.destinationDirectory.set(layout.buildDirectory.dir("classes")) }
test { java.destinationDirectory.set(layout.buildDirectory.dir("testClasses")) }
}

dependencies {
Expand Down
3 changes: 1 addition & 2 deletions subsystems/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ subprojects {
plugins.apply('java')
plugins.apply('idea')

def sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).sourceSets

def sourceSets = project.getExtensions().getByType(SourceSetContainer.class)

sourceSets.main.java.destinationDirectory = new File("$buildDir/classes")
idea {
Expand Down