Skip to content

Commit

Permalink
Merge branch 'develop' into java-18-disable-securitymanager
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrueckert authored Sep 24, 2023
2 parents 9cca631 + 1ce6368 commit aa43873
Show file tree
Hide file tree
Showing 25 changed files with 1,012 additions and 552 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
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
64 changes: 57 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 Expand Up @@ -282,3 +282,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
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
12 changes: 6 additions & 6 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 @@ -154,7 +155,7 @@ dependencies {
api fileTree(dir: 'libs', include: '*.jar')

// TODO: Consider moving this back to the PC Facade instead of having the engine rely on it?
implementation group: 'org.terasology.crashreporter', name: 'cr-terasology', version: '4.2.0'
implementation group: 'org.terasology.crashreporter', name: 'cr-terasology', version: '5.0.0'

api(project(":subsystems:TypeHandlerLibrary"))
}
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
Loading

0 comments on commit aa43873

Please sign in to comment.