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

build(gradle): upgrade gradle 6.4.2 >>> 8.2.1 #5109

Merged
merged 17 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/terasology-metrics.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ tasks.withType<Test> {
// If false, the outputs are still collected and visible in the test report, but they don't spam the console.
testLogging.showStandardStreams = false
reports {
junitXml.isEnabled = true
junitXml.required.set(true)
}
jvmArgs("-Xms512m", "-Xmx1024m")

Expand Down
4 changes: 2 additions & 2 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.outputDir = buildDir.resolve("classes")
java.destinationDirectory.set(buildDir.resolve("classes"))
}
test {
java.outputDir = buildDir.resolve("testClasses")
java.destinationDirectory.set(buildDir.resolve("testClasses"))
}
}

Expand Down
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import static org.gradle.internal.logging.text.StyledTextOutput.Style

// Test for right version of Java in use for running this script
assert org.gradle.api.JavaVersion.current().isJava11Compatible()
if(!(JavaVersion.current() == JavaVersion.VERSION_11)) {
if (!(JavaVersion.current() == JavaVersion.VERSION_11)) {
def out = services.get(StyledTextOutputFactory).create("an-ouput")
out.withStyle(Style.FailureHeader).println("""
WARNING: Compiling with a JDK of not version 11. While some other Javas may be
Expand Down Expand Up @@ -95,7 +95,7 @@ configurations {
dependencies {
// For the "natives" configuration make it depend on the native files from LWJGL
natives platform("org.lwjgl:lwjgl-bom:$LwjglVersion")
["natives-linux","natives-windows","natives-macos"].forEach {
["natives-linux", "natives-windows", "natives-macos"].forEach {
natives "org.lwjgl:lwjgl::$it"
natives "org.lwjgl:lwjgl-assimp::$it"
natives "org.lwjgl:lwjgl-glfw::$it"
Expand Down Expand Up @@ -151,12 +151,12 @@ task extractJNLuaNatives(type: Copy) {
into("$dirNatives")
}

task extractNativeBulletNatives(type:Copy) {
task extractNativeBulletNatives(type: Copy) {
description = "Extracts the JNBullet natives from the downloaded zip"
from {
configurations.natives.collect { it.getName().contains('JNBullet') ? zipTree(it) : [] }
}
into ("$dirNatives")
into("$dirNatives")
}


Expand Down Expand Up @@ -195,8 +195,8 @@ clean.doLast {
allprojects {
configurations.all {
resolutionStrategy.dependencySubstitution {
substitute module("org.terasology.engine:engine") because "we have sources!" with project(":engine")
substitute module("org.terasology.engine:engine-tests") because "we have sources!" with project(":engine-tests")
substitute module("org.terasology.engine:engine") using project(":engine") because "we have sources!"
substitute module("org.terasology.engine:engine-tests") using project(":engine-tests") because "we have sources!"
}
}
}
Expand All @@ -207,7 +207,7 @@ project(":modules").subprojects.forEach { proj ->
project(":modules").subprojects {
configurations.all {
resolutionStrategy.dependencySubstitution {
substitute module("org.terasology.modules:${proj.name}") because "we have sources!" with project(":modules:${proj.name}")
substitute module("org.terasology.modules:${proj.name}") using project(":modules:${proj.name}") because "we have sources!"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions engine-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ println "Version for $project.name loaded as $version for group $group"

sourceSets {
// Adjust output path (changed with the Gradle 6 upgrade, this puts it back)
main.java.outputDir = new File("$buildDir/classes")
test.java.outputDir = new File("$buildDir/testClasses")
main.java.destinationDirectory = new File("$buildDir/classes")
test.java.destinationDirectory = new File("$buildDir/testClasses")
}

// Primary dependencies definition
Expand Down
6 changes: 1 addition & 5 deletions engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ sourceSets {
}
java {
// Adjust output path (changed with the Gradle 6 upgrade, this puts it back)
outputDir = new File("$buildDir/classes")
destinationDirectory = new File("$buildDir/classes")
}
}
}
Expand Down Expand Up @@ -270,10 +270,6 @@ task copyResourcesToClasses(type: Copy) {
mustRunAfter compileJava
}

tasks.named("classes") {
dependsOn(tasks.named("copyResourcesToClasses"))
}

Copy link
Member

Choose a reason for hiding this comment

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

What happened to this? All the other changes look like simple drop-in replacements, but this is just removed. Do we just not need it anymore?

Copy link
Member

Choose a reason for hiding this comment

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

gradlew unitTest fails with a message seemingly related to this:

FAILURE: Build failed with an exception.

* What went wrong:
Some problems were found with the configuration of task ':engine-tests:copyResourcesToClasses' (type 'Copy').
  - Gradle detected a problem with the following location: '/home/jenkins/agent/workspace/Terasology_engine_PR-5109/engine-tests/build/classes'.
    
    Reason: Task ':engine-tests:compileTestJava' uses this output of task ':engine-tests:copyResourcesToClasses' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':engine-tests:copyResourcesToClasses' as an input of ':engine-tests:compileTestJava'.
      2. Declare an explicit dependency on ':engine-tests:copyResourcesToClasses' from ':engine-tests:compileTestJava' using Task#dependsOn.
      3. Declare an explicit dependency on ':engine-tests:copyResourcesToClasses' from ':engine-tests:compileTestJava' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.2/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.
  - Gradle detected a problem with the following location: '/home/jenkins/agent/workspace/Terasology_engine_PR-5109/engine-tests/build/resources/main'.
    
    Reason: Task ':engine-tests:copyResourcesToClasses' uses this output of task ':engine-tests:processResources' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':engine-tests:processResources' as an input of ':engine-tests:copyResourcesToClasses'.
      2. Declare an explicit dependency on ':engine-tests:processResources' from ':engine-tests:copyResourcesToClasses' using Task#dependsOn.
      3. Declare an explicit dependency on ':engine-tests:processResources' from ':engine-tests:copyResourcesToClasses' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.2/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm. I just delete it , and game running.
And i see how fix this now.
Seems there we should declare second edge for task graph.

Copy link
Member

Choose a reason for hiding this comment

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

First I tried to add those missing dependencies, but it gets weird quickly, and you also have to add DupliactesStrategys (I suspect because we wildly copy files around and don't care about duplicates or anything). I've added more and more dependsOn and duplicatesStrategy = 'exclude', but in the end still failed to run the tests 😔

My second attempt was to remove the copyResourcesToClasses task and pointers to it completely, from both :engine and :engine-tests. Eventually, the engine (tests) seemingly built, but then errors popped up when dealing with modules:

* What went wrong:
Some problems were found with the configuration of task ':modules:CoreWorlds:compileTestJava' (type 'JavaCompile').
  - Gradle detected a problem with the following location: '/home/skaldarnar/Code/movingblocks/ts-iota/modules/BiomesAPI/build/classes'.
    
    Reason: Task ':modules:CoreWorlds:compileTestJava' uses this output of task ':modules:BiomesAPI:syncModuleInfo' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':modules:BiomesAPI:syncModuleInfo' as an input of ':modules:CoreWorlds:compileTestJava'.
      2. Declare an explicit dependency on ':modules:BiomesAPI:syncModuleInfo' from ':modules:CoreWorlds:compileTestJava' using Task#dependsOn.
      3. Declare an explicit dependency on ':modules:BiomesAPI:syncModuleInfo' from ':modules:CoreWorlds:compileTestJava' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.2/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.
  - Gradle detected a problem with the following location: '/home/skaldarnar/Code/movingblocks/ts-iota/modules/BiomesAPI/build/classes'.
    
    Reason: Task ':modules:CoreWorlds:compileTestJava' uses this output of task ':modules:BiomesAPI:syncAssets' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':modules:BiomesAPI:syncAssets' as an input of ':modules:CoreWorlds:compileTestJava'.
      2. Declare an explicit dependency on ':modules:BiomesAPI:syncAssets' from ':modules:CoreWorlds:compileTestJava' using Task#dependsOn.
      3. Declare an explicit dependency on ':modules:BiomesAPI:syncAssets' from ':modules:CoreWorlds:compileTestJava' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.2/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.
  - Gradle detected a problem with the following location: '/home/skaldarnar/Code/movingblocks/ts-iota/modules/BiomesAPI/build/classes'.
    
    Reason: Task ':modules:CoreWorlds:compileTestJava' uses this output of task ':modules:BiomesAPI:syncDeltas' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':modules:BiomesAPI:syncDeltas' as an input of ':modules:CoreWorlds:compileTestJava'.
      2. Declare an explicit dependency on ':modules:BiomesAPI:syncDeltas' from ':modules:CoreWorlds:compileTestJava' using Task#dependsOn.
      3. Declare an explicit dependency on ':modules:BiomesAPI:syncDeltas' from ':modules:CoreWorlds:compileTestJava' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.2/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.
  - Gradle detected a problem with the following location: '/home/skaldarnar/Code/movingblocks/ts-iota/modules/BiomesAPI/build/classes'.
    
    Reason: Task ':modules:CoreWorlds:compileTestJava' uses this output of task ':modules:BiomesAPI:syncOverrides' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':modules:BiomesAPI:syncOverrides' as an input of ':modules:CoreWorlds:compileTestJava'.
      2. Declare an explicit dependency on ':modules:BiomesAPI:syncOverrides' from ':modules:CoreWorlds:compileTestJava' using Task#dependsOn.
      3. Declare an explicit dependency on ':modules:BiomesAPI:syncOverrides' from ':modules:CoreWorlds:compileTestJava' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.2/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.
  - Gradle detected a problem with the following location: '/home/skaldarnar/Code/movingblocks/ts-iota/modules/CoreAssets/build/classes'.
    
    Reason: Task ':modules:CoreWorlds:compileTestJava' uses this output of task ':modules:CoreAssets:syncModuleInfo' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':modules:CoreAssets:syncModuleInfo' as an input of ':modules:CoreWorlds:compileTestJava'.
      2. Declare an explicit dependency on ':modules:CoreAssets:syncModuleInfo' from ':modules:CoreWorlds:compileTestJava' using Task#dependsOn.
      3. Declare an explicit dependency on ':modules:CoreAssets:syncModuleInfo' from ':modules:CoreWorlds:compileTestJava' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.2/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

Copy link
Member

Choose a reason for hiding this comment

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

Do we have to re-model all these dependencies to make Gradle happy? Is the new Gradle version just pointing us to places where the setup was "shaky" in the first place?

Copy link
Member

Choose a reason for hiding this comment

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

@BenjaminAmos @DarkWeird do you know what exactly is meant by

//TODO: Remove it  when gestalt will can to handle ProtectionDomain without classes (Resources)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@BenjaminAmos @DarkWeird do you know what exactly is meant by

//TODO: Remove it  when gestalt will can to handle ProtectionDomain without classes (Resources)

Gestalt works with one source of module.(one jar, one dir etc)
Gradle split resouces and classes(compiled classes) dirs when build sources.
More gradle creates separate classes dir on every sources (java/kotlin/groovy - etc)

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// General IDE customization //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions facades/TeraEd/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ group = 'org.terasology.facades'

sourceSets {
// Adjust output path (changed with the Gradle 6 upgrade, this puts it back)
main.java.outputDir = new File("$buildDir/classes")
test.java.outputDir = new File("$buildDir/testClasses")
main.java.destinationDirectory = new File("$buildDir/classes")
test.java.destinationDirectory = new File("$buildDir/testClasses")
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion subsystems/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ subprojects {
def sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).sourceSets


sourceSets.main.java.outputDir = new File("$buildDir/classes")
sourceSets.main.java.destinationDirectory = new File("$buildDir/classes")
idea {
module {
// Change around the output a bit
Expand Down