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 Oct 18, 2023
2 parents 639b719 + 254db60 commit 9397bb1
Show file tree
Hide file tree
Showing 17 changed files with 100 additions and 87 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
14 changes: 5 additions & 9 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"
`kotlin-dsl`
}

kotlin {
Expand All @@ -18,18 +18,14 @@ repositories {

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 @@ -50,7 +46,7 @@ dependencies {
implementation("org.terasology.gestalt:gestalt-module:7.1.0")

// plugins we configure
implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:5.1.3")
implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:5.2.0")
implementation("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3")

api(kotlin("test"))
Expand Down
28 changes: 20 additions & 8 deletions build-logic/src/main/kotlin/terasology-metrics.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ plugins {
}

dependencies {
"pmd"("net.sourceforge.pmd:pmd-core:6.15.0")
"pmd"("net.sourceforge.pmd:pmd-java:6.15.0")
pmd("net.sourceforge.pmd:pmd-core:6.55.0")
pmd("net.sourceforge.pmd:pmd-java:6.55.0")

testRuntimeOnly("ch.qos.logback:logback-classic:1.2.11") {
because("runtime: to configure logging during tests with logback.xml")
Expand All @@ -27,7 +27,7 @@ dependencies {
because("redirects java.util.logging (from e.g. junit) through slf4j")
}

add("testImplementation", platform("org.junit:junit-bom:5.8.1"))
add("testImplementation", platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
Expand Down Expand Up @@ -60,16 +60,28 @@ tasks.withType<Test> {
}
}

tasks.withType<Checkstyle> {
dependsOn(tasks.getByPath(":extractConfig"))
}
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> {
dependsOn(tasks.getByPath(":extractConfig"))
//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> {
dependsOn(tasks.getByPath(":extractConfig"))
//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
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")
}
}
60 changes: 54 additions & 6 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 @@ -64,7 +62,7 @@ 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 @@ -106,7 +104,7 @@ dependencies {


// Config for our code analytics lives in a centralized repo: https://github.com/MovingBlocks/TeraConfig
codeMetrics group: 'org.terasology.config', name: 'codemetrics', version: '1.6.3', ext: 'zip'
codeMetrics group: 'org.terasology.config', name: 'codemetrics', version: '2.1.0', ext: 'zip'

// Natives for JNLua (Kallisti, KComputers)
natives group: 'org.terasology.jnlua', name: 'jnlua_natives', version: '0.1.0-SNAPSHOT', ext: 'zip'
Expand Down Expand Up @@ -294,3 +292,53 @@ if (hasProperty('buildScan')
}
}
}

// 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')
}
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
2 changes: 1 addition & 1 deletion engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def createVersionInfoFile = tasks.register("createVersionInfoFile", WritePropert
// It is a value we can always get (on Jenkins or otherwise) but we don't want local builds
// to invalidate their cache whenever the time changes.
// TODO: after upgrading to Gradle 6.8, see if we can have it ignore this property specifically:
// https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:property_file_normalization
// https://docs.gradle.org/current/userguide/incremental_build.html#sec:property_file_normalization
property("dateTime", startDateTimeString)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,13 @@ private void setupSandbox() {
permissionSet.grantPermission(new PropertyPermission("reactor.schedulers.defaultBoundedElasticQueueSize", "read"));
}

Policy.setPolicy(new ModuleSecurityPolicy());
System.setSecurityManager(new ModuleSecurityManager());
if (Runtime.version().feature() < 18 || "allow".equals(System.getProperty("java.security.manager"))) {
Policy.setPolicy(new ModuleSecurityPolicy());
System.setSecurityManager(new ModuleSecurityManager());
} else {
logger.warn("SecurityManager is disabled starting with Java 18 - module sandbox functionality is limited!");
logger.warn("To enable SecurityManager, use the \"-Djava.security.manager=allow\" JVM option.");
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ public String dumpEntities(@CommandParam(value = "componentNames", required = fa
PrefabSerializer prefabSerializer =
new PrefabSerializer(engineEntityManager.getComponentLibrary(), engineEntityManager.getTypeSerializerLibrary());
WorldDumper worldDumper = new WorldDumper(engineEntityManager, prefabSerializer);
Path outFile = PathManager.getInstance().getHomePath().resolve(Instant.now() + "-entityDump.json");
Path outFile = PathManager.getInstance().getHomePath().resolve(Instant.now().toString().replaceAll(":", "-") + "-entityDump.json");
if (componentNames.length == 0) {
savedEntityCount = worldDumper.save(outFile);
} else {
Expand Down
7 changes: 0 additions & 7 deletions facades/PC/src/main/startScripts/unixStartScript.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,6 @@ save () {
}
APP_ARGS=`save "\$@"`

# Terasology-specific changes - Re-enable SecurityManager on Java 18+
# According to https://openjdk.org/jeps/223, this string is intentionally parsable.
JAVA_VERSION=`java -fullversion 2>&1 | sed 's/.* //;s/"//;s/\\([0-9]*\\)\\..*/\\1/'`
if [ \$JAVA_VERSION -gt 17 ]; then
DEFAULT_JVM_OPTS="\$DEFAULT_JVM_OPTS -Djava.security.manager=allow"
fi

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- \$DEFAULT_JVM_OPTS \$JAVA_OPTS \$${optsEnvironmentVar} <% if ( appNameSystemProperty ) { %>"\"-D${appNameSystemProperty}=\$APP_BASE_NAME\"" <% } %> <% if ( mainClassName.startsWith('--module ') ) { %>--module-path "\"\$MODULE_PATH\"" <% } %>-jar lib/Terasology.jar "\$APP_ARGS"

Expand Down
8 changes: 0 additions & 8 deletions facades/PC/src/main/startScripts/windowsStartScript.bat.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,6 @@ goto fail

<% if ( mainClassName.startsWith('--module ') ) { %>set MODULE_PATH=$modulePath<% } %>

@rem Terasology-specific changes - Re-enable SecurityManager on Java 18+
@rem According to https://openjdk.org/jeps/223, this string is intentionally parsable.
for /f "tokens=4 delims= " %%a in ('"%JAVA_EXE%" -fullversion 2^>^&1 1^>nul') do ( for /f "delims=." %%b in ('echo %%a') do set JAVA_VERSION="%%b" )
set JAVA_VERSION=%JAVA_VERSION:"=%
if %JAVA_VERSION% gtr 17 (
set DEFAULT_JVM_OPTS=%DEFAULT_JVM_OPTS% -Djava.security.manager=allow
)

@rem Execute ${applicationName}
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %${optsEnvironmentVar}% <% if ( appNameSystemProperty ) { %>"-D${appNameSystemProperty}=%APP_BASE_NAME%"<% } %> <% if ( mainClassName.startsWith('--module ') ) { %>--module-path "%MODULE_PATH%" <% } %>-jar lib\\Terasology.jar %*

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Binary file modified gradle/wrapper/groovy-wrapper.jar
Binary file not shown.
28 changes: 1 addition & 27 deletions groovyw.bat
Original file line number Diff line number Diff line change
Expand Up @@ -77,33 +77,7 @@ set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute

@REM Escapes all arguments containing either "*" or "?" before passing them to the groovy process
:process_args
@REM If we have no more arguments to process then exit the loop
IF "%1"=="" GOTO end
SET ARG=%~1
@REM "echo "%ARG%" will simply output the argument as an escaped text string
@REM for piping to other applications. This is needed to ensure that the arguments are not expanded.
@REM findstr is a built-in Windows utility (it has been since Windows 2000)
@REM that finds matches in strings based on regular expressions.
@REM The "&&" operator is followed if the findstr program returns an exit code of 0
@REM Otherwise, the "||" operator is followed instead.
echo "%ARG%" | findstr /C:"\*" 1>nul && (
SET CMD_LINE_ARGS=%CMD_LINE_ARGS% "%ARG%"
) || (
echo "%ARG%" | findstr /C:"\?" 1>nul && (
SET CMD_LINE_ARGS=%CMD_LINE_ARGS% "%ARG%"
) || (
SET CMD_LINE_ARGS=%CMD_LINE_ARGS% %ARG%
)
)
SHIFT
GOTO process_args

:end
@REM For some reason, the escaped arguments always contain an extra space at the end, which confuses groovy.
@REM This should remove it.
SET CMD_LINE_ARGS=%CMD_LINE_ARGS:~1%
set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line
Expand Down
6 changes: 2 additions & 4 deletions templates/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,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
2 changes: 1 addition & 1 deletion templates/facades.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repositories {
// MovingBlocks Artifactory instance for libs not readily available elsewhere plus our own libs
maven {
name "Terasology Artifactory"
url "http://artifactory.terasology.org/artifactory/repo"
url "https://artifactory.terasology.io/artifactory/repo"
}
}

Expand Down
2 changes: 1 addition & 1 deletion templates/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ org.gradle.jvmargs=-Xmx1024m
# To pass via CLI use: -Dorg.gradle.internal.publish.checksums.insecure=true

# Alternative resolution repo to use - this can be used to ignore "live" artifacts and only accept experimental ones.
# alternativeResolutionRepo=http://artifactory.terasology.org/artifactory/virtual-nanoware-and-remote
# alternativeResolutionRepo=https://artifactory.terasology.io/artifactory/virtual-nanoware-and-remote

# Credentials for publishing to Artifactory. Good for local testing
# mavenUser=
Expand Down

0 comments on commit 9397bb1

Please sign in to comment.