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

refactor: fix gradle warnings #5130

Closed
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
4 changes: 2 additions & 2 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.net.URI

plugins {
id("org.gradle.kotlin.kotlin-dsl") version "4.1.0"
id("org.gradle.kotlin.kotlin-dsl") version "4.0.14"
}

kotlin {
Expand Down Expand Up @@ -50,7 +50,7 @@ dependencies {
implementation("org.terasology.gestalt:gestalt-module:7.1.0")

// plugins we configure
implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:4.8.0") // TODO: upgrade with gradle 7.x
implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:5.1.3")
implementation("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3")

api(kotlin("test"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,10 @@ fun moduleDependencyOrdering(modulesConfig: Configuration): List<String> {
// configurations.resolvedConfiguration is more straightforward if you just want all the artifacts,
// but using `.incoming` lets us turn on lenient mode as well as do more accurate filtering of local modules
val resolvable = modulesConfig.incoming
val artifactView = resolvable.artifactView {
lenient(true)
}
Comment on lines -93 to -95
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this no longer needed or no longer possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it made no difference to building the project, artifactView may have been used before but not anymore. I believe all that method does is create a builder, but since it used nowhere in the function it is kinda pointless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡


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 @@ -43,7 +43,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