Skip to content

Commit

Permalink
Merge branch 'develop' into topic/github-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrueckert authored Sep 10, 2023
2 parents cf0d2ae + 43a7e05 commit 639b719
Show file tree
Hide file tree
Showing 15 changed files with 247 additions and 150 deletions.
8 changes: 6 additions & 2 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import java.net.URI

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

kotlin {
jvmToolchain(11)
}

repositories {
Expand Down Expand Up @@ -46,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
17 changes: 13 additions & 4 deletions 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 All @@ -60,6 +60,18 @@ tasks.withType<Test> {
}
}

tasks.withType<Checkstyle> {
dependsOn(tasks.getByPath(":extractConfig"))
}

tasks.withType<Pmd> {
dependsOn(tasks.getByPath(":extractConfig"))
}

tasks.withType<SpotBugsTask> {
dependsOn(tasks.getByPath(":extractConfig"))
}

// The config files here work in both a multi-project workspace (IDEs, running from source) and for solo module builds
// Solo module builds in Jenkins get a copy of the config dir from the engine harness so it still lives at root/config
// TODO: Maybe update other projects like modules to pull the zipped dependency so fewer quirks are needed in Jenkins
Expand All @@ -81,9 +93,6 @@ configure<PmdExtension> {
}

configure<SpotBugsExtension> {
// The version of the spotbugs tool https://github.com/spotbugs/spotbugs
// not necessarily the same as the version of spotbugs-gradle-plugin
toolVersion.set("4.7.0")
ignoreFailures.set(true)
excludeFilter.set(file(rootDir.resolve("config/metrics/findbugs/findbugs-exclude.xml")))
}
Expand Down
8 changes: 6 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 Expand Up @@ -144,6 +144,10 @@ tasks.named("processResources") {
dependsOn("syncAssets", "syncOverrides", "syncDeltas", "syncModuleInfo")
}

tasks.named("compileJava") {
dependsOn("processResources")
}

tasks.named<Test>("test") {
description = "Runs all tests (slow)"
useJUnitPlatform ()
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
5 changes: 1 addition & 4 deletions config/gradle/common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ apply plugin: 'idea'

apply plugin: 'terasology-repositories'

java {
sourceCompatibility = JavaVersion.VERSION_11
}

javadoc.options.encoding = 'UTF-8'

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.release.set(11)
}

task sourceJar(type: Jar) {
Expand Down
21 changes: 12 additions & 9 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 Expand Up @@ -88,14 +88,21 @@ dependencies {
// See terasology-metrics for other test-only internal dependencies
}

//TODO: Remove it when gestalt will can to handle ProtectionDomain without classes (Resources)
task copyResourcesToClasses(type:Copy) {
from sourceSets.main.output.resourcesDir
from tasks.named("processResources")
into sourceSets.main.output.classesDirs.first()
}

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

jar { // Workaround about previous copy to classes. idk why engine-tests:jar called before :engine ...
duplicatesStrategy = "EXCLUDE"
}

test {
//TODO: Remove it when gestalt will can to handle ProtectionDomain without classes (Resources)
dependsOn copyResourcesToClasses
dependsOn rootProject.extractNatives

description("Runs all tests (slow)")
Expand All @@ -104,8 +111,6 @@ test {
}

task unitTest(type: Test) {
//TODO: Remove it when gestalt will can to handle ProtectionDomain without classes (Resources)
dependsOn copyResourcesToClasses
dependsOn rootProject.extractNatives

group "Verification"
Expand All @@ -118,8 +123,6 @@ task unitTest(type: Test) {
}

task integrationTest(type: Test) {
//TODO: Remove it when gestalt will can to handle ProtectionDomain without classes (Resources)
dependsOn copyResourcesToClasses
dependsOn rootProject.extractNatives

group "Verification"
Expand Down
10 changes: 5 additions & 5 deletions engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ 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")
}
test.java.destinationDirectory = new File("$buildDir/testClasses")
}
}

Expand Down Expand Up @@ -189,6 +190,7 @@ sourceSets {
java.srcDirs = ['src/jmh/java']
resources.srcDirs = ['src/jmh/resources']
compileClasspath += sourceSets.main.runtimeClasspath
java.destinationDirectory = new File("$buildDir/jmhClasses")
}
}

Expand Down Expand Up @@ -263,14 +265,12 @@ tasks.named("processResources", Copy) {

//TODO: Remove this when gestalt can handle ProtectionDomain without classes (Resources)
task copyResourcesToClasses(type: Copy) {
from sourceSets.main.output.resourcesDir
from processResources
into sourceSets.main.output.classesDirs.first()

dependsOn processResources
mustRunAfter compileJava
}

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

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
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.1-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Binary file modified gradle/wrapper/groovy-wrapper.jar
Binary file not shown.
Loading

0 comments on commit 639b719

Please sign in to comment.