Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/refactor/merge-universe-into-wor…
Browse files Browse the repository at this point in the history
…ld-pregen-screen' into refactor/merge-universe-into-world-pregen-screen
  • Loading branch information
jdrueckert committed Oct 15, 2023
2 parents 3cd4817 + 0701a8e commit 83d0a25
Show file tree
Hide file tree
Showing 29 changed files with 477 additions and 317 deletions.
5 changes: 2 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pipeline {

stage('Analytics') {
steps {
sh './gradlew --console=plain check -x test'
sh './gradlew --console=plain check -x test -x pmdMain -x pmdTest -x pmdJmh' // TODO: Probably more cleanly remove PMD overall if no use?
}
post {
always {
Expand All @@ -140,8 +140,7 @@ pipeline {

recordIssues(skipBlames: true, enabledForFailure: true,
tools: [
spotBugs(pattern: '**/build/reports/spotbugs/*.xml', useRankAsPriority: true),
pmdParser(pattern: '**/build/reports/pmd/*.xml')
spotBugs(pattern: '**/build/reports/spotbugs/*.xml', useRankAsPriority: true)
])

recordIssues(skipBlames: true, enabledForFailure: true,
Expand Down
16 changes: 8 additions & 8 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ plugins {
`kotlin-dsl`
}

kotlin {
jvmToolchain(11)
}

repositories {
mavenCentral()
google() // gestalt uses an annotation package by Google
gradlePluginPortal()

maven {
name = "Terasology Artifactory"
url = URI("http://artifactory.terasology.org/artifactory/virtual-repo-live")
@Suppress("UnstableApiUsage")
isAllowInsecureProtocol = true // 😱
url = URI("https://artifactory.terasology.io/artifactory/virtual-repo-live")
}

// TODO MYSTERY: As of November 7th 2011 virtual-repo-live could no longer be relied on for latest snapshots - Pro feature?
// TODO MYSTERY: As of November 7th 2021 virtual-repo-live could no longer be relied on for latest snapshots - Pro feature?
// We've been using it that way for *years* and nothing likewise changed in the area for years as well. This seems to work ....
maven {
name = "Terasology snapshot locals"
url = URI("http://artifactory.terasology.org/artifactory/terasology-snapshot-local")
@Suppress("UnstableApiUsage")
isAllowInsecureProtocol = true // 😱
url = URI("https://artifactory.terasology.io/artifactory/terasology-snapshot-local")
}
}

Expand All @@ -46,7 +46,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
29 changes: 25 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,30 @@ tasks.withType<Test> {
}
}

tasks.withType<Checkstyle> {
//FIXME: This is a workaround for module harness builds, where the config
// files are part of the harness but the task is not defined.
if (rootProject.name == "Terasology") {
dependsOn(tasks.getByPath(":extractConfig"))
}
}

tasks.withType<Pmd> {
//FIXME: This is a workaround for module harness builds, where the config
// files are part of the harness but the task is not defined.
if (rootProject.name == "Terasology") {
dependsOn(tasks.getByPath(":extractConfig"))
}
}

tasks.withType<SpotBugsTask> {
//FIXME: This is a workaround for module harness builds, where the config
// files are part of the harness but the task is not defined.
if (rootProject.name == "Terasology") {
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 +105,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
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,14 @@ repositories {
} else {
// Our default is the main virtual repo containing everything except repos for testing Artifactory itself
name = "Terasology Artifactory"
url = URI("http://artifactory.terasology.org/artifactory/virtual-repo-live")
isAllowInsecureProtocol = true // 😱
url = URI("https://artifactory.terasology.io/artifactory/virtual-repo-live")
}
}

// TODO MYSTERY: As of November 7th 2011 virtual-repo-live could no longer be relied on for latest snapshots - Pro feature?
// We've been using it that way for *years* and nothing likewise changed in the area for years as well. This seems to work ....
maven {
name = "Terasology snapshot locals"
url = URI("http://artifactory.terasology.org/artifactory/terasology-snapshot-local")
isAllowInsecureProtocol = true // 😱
url = URI("https://artifactory.terasology.io/artifactory/terasology-snapshot-local")
}
}
72 changes: 60 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ buildscript {
maven {
// required to provide runtime dependencies to build-logic.
name = "Terasology Artifactory"
url = "http://artifactory.terasology.org/artifactory/virtual-repo-live"
allowInsecureProtocol = true // 😱
url = "https://artifactory.terasology.io/artifactory/virtual-repo-live"
}

// TODO MYSTERY: As of November 7th 2011 virtual-repo-live could no longer be relied on for latest snapshots - Pro feature?
// We've been using it that way for *years* and nothing likewise changed in the area for years as well. This seems to work ....
maven {
name = "Terasology snapshot locals"
url = "http://artifactory.terasology.org/artifactory/terasology-snapshot-local"
allowInsecureProtocol = true // 😱
url = "https://artifactory.terasology.io/artifactory/terasology-snapshot-local"
}
}

Expand Down Expand Up @@ -56,15 +54,15 @@ 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
safe to use, any newer than 11 may cause issues.
If you encounter oddities try Java 11.
See https://github.com/MovingBlocks/Terasology/issues/3976.
Current detected Java version is ${JavaVersion.current()}
from vendor ${System.getProperty("java.vendor")}
from vendor ${System.getProperty("java.vendor")}
located at ${System.getProperty("java.home")}
""")
}
Expand Down Expand Up @@ -95,7 +93,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 +149,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 +193,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 +205,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 Expand Up @@ -282,3 +280,53 @@ idea {
cleanIdea.doLast {
new File('Terasology.iws').delete()
}

// A task to assemble various files into a single zip for distribution as 'build-harness.zip' for module builds
task assembleBuildHarness(type: Zip) {
description 'Assembles a zip of files useful for module development'

dependsOn extractNatives
from('natives'){
include '**/*'
// TODO: use output of extractNatives?
// TODO: which module needs natives to build?
into 'natives'
}

dependsOn extractConfig
from('config'){
//include 'gradle/**/*', 'metrics/**/*'
include '**/*'
// TODO: depend on output of extractConfig?
into 'config'
}

from('gradle'){
include '**/*' // include all files in 'gradle'
// TODO: exclude groovy jar?
into 'gradle'
}

from('build-logic'){
include 'src/**', '*.kts'
into 'build-logic'
}

from('templates') {
include 'build.gradle'
}

from('.') {
include 'gradlew'
}

// include file 'templates/module.logback-test.xml' as 'src/test/resources/logback-test.xml'
from('templates'){
include 'module.logback-test.xml'
rename 'module.logback-test.xml', 'logback-test.xml'
into 'src/test/resources'
}

// set the archive name
archiveFileName.set('build-harness.zip')
}
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
6 changes: 2 additions & 4 deletions config/gradle/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ publishing {

if (rootProject.hasProperty("publishRepo")) {
// This first option is good for local testing, you can set a full explicit target repo in gradle.properties
url = "http://artifactory.terasology.org/artifactory/$publishRepo"
allowInsecureProtocol true // 😱
url = "https://artifactory.terasology.io/artifactory/$publishRepo"
logger.info("Changing PUBLISH repoKey set via Gradle property to {}", publishRepo)
} else {
// Support override from the environment to use a different target publish org
Expand All @@ -38,8 +37,7 @@ publishing {
}

logger.info("The final deduced publish repo is {}", deducedPublishRepo)
url = "http://artifactory.terasology.org/artifactory/$deducedPublishRepo"
allowInsecureProtocol true
url = "https://artifactory.terasology.io/artifactory/$deducedPublishRepo"
}
}

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
Loading

0 comments on commit 83d0a25

Please sign in to comment.