diff --git a/build.gradle b/build.gradle index 7470e727f..46258cc7a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,6 @@ // Copyright 2020 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 -/* - * This is a Gradle build file: - * - Gradle Homepage: http://gradle.org/ - * - Gradle Documentation: http://gradle.org/documentation - * - View tasks for this project: $ gradlew tasks - */ buildscript { repositories { @@ -19,21 +13,21 @@ buildscript { } plugins { - id 'application' - id 'checkstyle' - id "com.github.spotbugs" version "5.2.3" - id 'de.undercouch.download' version '5.3.0' - id 'java' + id("application") + id("checkstyle") + id("com.github.spotbugs") version "5.2.3" + id("de.undercouch.download") version "5.3.0" + id("java") // to help clarify conflicting logging providers - id 'name.remal.component-metadata' version '1.5.0' - id 'nebula.release' version '16.0.0' - id 'pmd' - id 'project-report' - id 'org.openjfx.javafxplugin' version '0.0.13' - id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.5" + id("name.remal.component-metadata") version "1.5.0" + id("nebula.release") version "16.0.0" + id("pmd") + id("project-report") + id("org.openjfx.javafxplugin") version "0.0.13" + id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.5" } -apply plugin: 'org.terasology.gradlegoo' +apply plugin: "org.terasology.gradlegoo" apply from: "./config/gradle/jre.gradle" // Test for right version of Java in use for running this script @@ -62,10 +56,10 @@ ext { startDateTimeString = dateTimeFormat.format(new Date()) // Splash image for the JAR - splashImage = 'org/terasology/launcher/images/splash.jpg' + splashImage = "org/terasology/launcher/images/splash.jpg" // Shared code analytics configurations via retrieved config zip - metricsConfigDir = layout.getProjectDirectory().dir('config/metrics') + metricsConfigDir = layout.getProjectDirectory().dir("config/metrics") } // Declare remote repositories we're interested in - library files will be fetched from here @@ -97,61 +91,61 @@ dependencies { because "1.3 series uses ServiceLoader (more packaging friendly?)" } - implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5' - implementation group: "com.google.guava", name: "guava", version: "31.1-jre" - implementation group: 'com.github.everit-org.json-schema', name: 'org.everit.json.schema', version: '1.14.1' + implementation("com.google.code.gson:gson:2.8.5") + implementation("com.google.guava:guava:31.1-jre") + implementation("com.github.everit-org.json-schema:org.everit.json.schema:1.14.1") - implementation group: 'org.kohsuke', name: 'github-api', version: '1.318' - implementation group: 'org.semver4j', name: 'semver4j', version: '5.2.2' - implementation group: 'com.vladsch.flexmark', name: 'flexmark-all', version: '0.64.0' + implementation("org.kohsuke:github-api:1.318") + implementation("org.semver4j:semver4j:5.2.2") + implementation("com.vladsch.flexmark:flexmark-all:0.64.0") - implementation('org.hildan.fxgson:fx-gson:5.0.0') { + implementation("org.hildan.fxgson:fx-gson:5.0.0") { because "de-/serialization of launcher properties to JSON" } - implementation('com.squareup.okhttp3:okhttp:4.12.0') { + implementation("com.squareup.okhttp3:okhttp:4.12.0") { because "built-in caching of HTTP requests" } // These dependencies are only needed for running tests - testImplementation 'org.hamcrest:hamcrest:2.2' - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2' - testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.2' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2' + testImplementation("org.hamcrest:hamcrest:2.2") + testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.2") + testImplementation("org.junit.jupiter:junit-jupiter-params:5.10.2") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.2") - testImplementation('org.mockito:mockito-inline:5.2.0') { + testImplementation("org.mockito:mockito-inline:5.2.0") { because "-inline build enables mocking final classes" // https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#0.2 // > Be aware that this artifact may be abolished when the inline mock making feature is integrated into the default mock maker. } - testImplementation 'org.mockito:mockito-junit-jupiter:5.2.0' + testImplementation("org.mockito:mockito-junit-jupiter:5.2.0") - testImplementation('org.spf4j:spf4j-slf4j-test:8.10.0') { + testImplementation("org.spf4j:spf4j-slf4j-test:8.10.0") { because "testable logging" } - testImplementation('org.slf4j:slf4j-api:2.0.13') + testImplementation("org.slf4j:slf4j-api:2.0.13") testImplementation("org.testfx:testfx-core:4.0.18") { because "to test JavaFX Application" // -alpha because that's the only kind of release they have? } - testImplementation "org.testfx:testfx-junit5:4.0.18" + testImplementation("org.testfx:testfx-junit5:4.0.18") testImplementation("org.testfx:openjfx-monocle:17.0.10") { // nobody's uploaded a jdk-14 build yet. does the jdk-12 one work? because "CI builders are headless environments" } - testImplementation('com.github.gmazzo.okhttp.mock:mock-client:2.0.0') { + testImplementation("com.github.gmazzo.okhttp.mock:mock-client:2.0.0") { because "to easily write OkHttpClient interceptors for testing" } - testImplementation('com.squareup.okhttp3:mockwebserver:4.10.0') { + testImplementation("com.squareup.okhttp3:mockwebserver:4.10.0") { because "to control server responses for testing" } // Config for our code analytics from: https://github.com/MovingBlocks/TeraConfig - codeMetrics group: 'org.terasology.config', name: 'codemetrics', version: '1.7.1', ext: 'zip' + codeMetrics group: "org.terasology.config", name: "codemetrics", version: "1.7.1", ext: "zip" } configurations.matching({ it =~ ~/test(Runtime|Compile|Implementation|PmdAux)Classpath/ }).all { @@ -161,7 +155,7 @@ configurations.matching({ it =~ ~/test(Runtime|Compile|Implementation|PmdAux)Cla "spf4j-slf4j-test", "tests use slf4j-test")) // SPF4J has a dependency on "avro-logical-types-gen:1.3", which does not exist. However, version "1.3p" does. - resolutionStrategy.force('org.spf4j:avro-logical-types-gen:1.3p') + resolutionStrategy.force("org.spf4j:avro-logical-types-gen:1.3p") // old hamcrest versions exist only to spite us // http://hamcrest.org/JavaHamcrest/distributables#upgrading-from-hamcrest-1x exclude group: "org.hamcrest", module: "hamcrest-core" @@ -178,9 +172,9 @@ compileTestJava.options.encoding = "UTF-8" javafx { version = "17.0.2" modules = [ - 'javafx.graphics', - 'javafx.fxml', - 'javafx.web' + "javafx.graphics", + "javafx.fxml", + "javafx.web" ] } @@ -209,11 +203,11 @@ pmd { spotbugs { ignoreFailures = true - effort = 'max' - reportLevel = 'medium' + effort = "max" + reportLevel = "medium" } -mainClassName = 'org.terasology.launcher.TerasologyLauncher' +mainClassName = "org.terasology.launcher.TerasologyLauncher" def convertGitBranch = { gitBranch -> if (gitBranch != null) { @@ -225,10 +219,10 @@ def convertGitBranch = { gitBranch -> } task createVersionInfoFile { - inputs.property('version', version.toString()) + inputs.property("version", version.toString()) - File versionInfoFileDir = new File(sourceSets.main.output.resourcesDir, 'org/terasology/launcher/') - File versionFile = new File(versionInfoFileDir, 'version.txt') + File versionInfoFileDir = new File(sourceSets.main.output.resourcesDir, "org/terasology/launcher/") + File versionFile = new File(versionInfoFileDir, "version.txt") outputs.file(versionFile) @@ -258,11 +252,11 @@ clean { processResources.dependsOn(createVersionInfoFile) jar { - //TODO we only use this name because the `.exe` start scripts require the JAR to be named 'TerasologyLauncher.jar' + //TODO we only use this name because the `.exe` start scripts require the JAR to be named "TerasologyLauncher.jar" jar.archiveFileName = "${project.name}.jar" // replace development "logback.xml" with productive "logback_jar.xml" exclude "logback.xml" - rename('logback_jar.xml', 'logback.xml') + rename("logback_jar.xml", "logback.xml") manifest { def manifestClasspath = configurations.runtimeClasspath.collect { it.getName() }.join(" ") attributes("Main-Class": mainClassName) @@ -272,50 +266,50 @@ jar { attributes("SplashScreen-Image": splashImage) // allow everything - attributes('Permissions': 'all-permissions') - attributes('Codebase': '*') - attributes('Application-Name': project.name) - attributes('Application-Library-Allowable-Codebase': '*') - attributes('Caller-Allowable-Codebase': '*') - attributes('Trusted-Only': 'false') + attributes("Permissions": "all-permissions") + attributes("Codebase": "*") + attributes("Application-Name": project.name) + attributes("Application-Library-Allowable-Codebase": "*") + attributes("Caller-Allowable-Codebase": "*") + attributes("Trusted-Only": "false") } } task copyExtra(type: Copy) { filter(FixCrLfFilter, eol: FixCrLfFilter.CrLf.newInstance("crlf")) - from('README.md') { - rename('README.md', 'README.txt') + from("README.md") { + rename("README.md", "README.txt") } - from('CHANGELOG.md') { - rename('CHANGELOG.md', 'CHANGELOG.txt') + from("CHANGELOG.md") { + rename("CHANGELOG.md", "CHANGELOG.txt") } - from('CONTRIBUTING.md') { - rename('CONTRIBUTING.md', 'CONTRIBUTING.txt') + from("CONTRIBUTING.md") { + rename("CONTRIBUTING.md", "CONTRIBUTING.txt") } - from('LICENSE') - from('NOTICE') + from("LICENSE") + from("NOTICE") into "$buildDir/distributions" } task copyExtraIntoResources(type: Copy) { - from('README.md') - from('CHANGELOG.md') - from('docs/CONTRIBUTING.md') - from('LICENSE') + from("README.md") + from("CHANGELOG.md") + from("docs/CONTRIBUTING.md") + from("LICENSE") - into('src/main/resources/org/terasology/launcher/about') + into("src/main/resources/org/terasology/launcher/about") } processResources.dependsOn copyExtraIntoResources task copyIconsIntoResources(type: Copy) { - from('icons') + from("icons") - into('src/main/resources/org/terasology/launcher/icons') + into("src/main/resources/org/terasology/launcher/icons") } processResources.dependsOn copyIconsIntoResources @@ -329,7 +323,7 @@ idea { } } -tasks.named('wrapper') { +tasks.named("wrapper") { // IDEA likes this distribution to better know things. distributionType = Wrapper.DistributionType.ALL } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 481137ef8..cbb9bedaf 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 plugins { - id 'java-gradle-plugin' - id 'groovy' + id("java-gradle-plugin") + id("groovy") } repositories { @@ -17,8 +17,8 @@ dependencies { gradlePlugin { plugins { simplePlugin { - id = 'org.terasology.gradlegoo' - implementationClass = 'org.terasology.gradlegoo.GradleGooPlugin' + id = "org.terasology.gradlegoo" + implementationClass = "org.terasology.gradlegoo.GradleGooPlugin" } } } diff --git a/config/gradle/jre.gradle b/config/gradle/jre.gradle index 1fa49c507..88710cc50 100644 --- a/config/gradle/jre.gradle +++ b/config/gradle/jre.gradle @@ -3,31 +3,31 @@ // Uses Bellsoft Liberica JRE // https://bell-sw.com/pages/liberica_install_guide-11.0.16.1/ -def jdkVersion = '17.0.11+12' +def jdkVersion = "17.0.11+12" def jreUrlFilenames = [ - Linux64 : 'linux-amd64-full.tar.gz', - Windows64 : 'windows-amd64-full.zip', - Mac : 'macos-amd64-full.zip' + Linux64 : "linux-amd64-full.tar.gz", + Windows64 : "windows-amd64-full.zip", + Mac : "macos-amd64-full.zip" ] -task createRelease() { - group 'Distribution' - description 'Bundles the project with a JRE for each platform' +tasks.register("createRelease") { + group "Distribution" + description "Bundles the project with a JRE for each platform" dependsOn distZip doLast { - println 'Created release: ' + version + println "Created release: " + version } } -task downloadJreAll { - group 'JRE' - description 'Downloads Launcher JREs for all platforms' +tasks.register("downloadJreAll") { + group "JRE" + description "Downloads Launcher JREs for all platforms" } -task unpackJreAll { - group 'JRE' - description 'Unpack JREs for all platforms' +tasks.register("unpackJreAll") { + group "JRE" + description "Unpack JREs for all platforms" } @@ -36,15 +36,15 @@ def createJreTasks(String taskNameBase, String downloadFile, String unpackDir) { - task "download$taskNameBase"(type: Download) { - group 'JRE' + tasks.register("download$taskNameBase", Download) { + group "JRE" src downloadUrl dest downloadFile overwrite false } def unpackTask = task "unpack$taskNameBase"(type: Copy) { - group 'JRE' + group "JRE" from(downloadFile.endsWith("zip") ? zipTree(downloadFile) : tarTree(downloadFile)) { @@ -55,7 +55,9 @@ def createJreTasks(String taskNameBase, includeEmptyDirs = false } into unpackDir - + filePermissions { + user.write = true + } dependsOn "download${taskNameBase}" } @@ -78,7 +80,7 @@ jreUrlFilenames.each { os, file -> contents { with distributions.main.contents - into('jre') { + into("jre") { from unpackTask } @@ -97,8 +99,8 @@ jreUrlFilenames.each { os, file -> distributions { mac { contents { - into 'TerasologyLauncher.app/Contents' - exclude '**/*.bat' + into "TerasologyLauncher.app/Contents" + exclude "**/*.bat" eachFile { details -> details.path = details.path.toString().replaceAll("(Contents)/bin/(.+)", "\$1/MacOS/\$2") } @@ -106,7 +108,7 @@ distributions { } } -tasks.withType(CreateStartScripts) { +tasks.withType(CreateStartScripts).configureEach { def unixTemplate = file("$projectDir/buildres/scripts/unixStartScript.txt") def windowsTemplate = file("$projectDir/buildres/scripts/windowsStartScript.txt") diff --git a/settings.gradle b/settings.gradle index c4aa331c1..fc666c4f5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,8 +1,8 @@ // Copyright 2020 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 -rootProject.name = 'TerasologyLauncher' +rootProject.name = "TerasologyLauncher" -if (new File('web-api-client').exists()) { +if (new File("web-api-client").exists()) { include 'web-api-client' }