From a61fe39f4e86ce5ab2c0615612deae1c51aff927 Mon Sep 17 00:00:00 2001 From: Juuz Date: Thu, 21 Aug 2025 23:53:50 +0300 Subject: Update Gradle and fix buildscripts (#557) * Fix Gradle configuration cache compat with generateResources task The task now also declares its inputs properly, making it support up-to-date checks. * Update Gradle and Shadow Shadow 9 is incompatible with including the flatlaf natives, so I updated to the last 8.x version which also works with Gradle 9. The Shadow plugin automatically publishes the shadow jar, so I removed the overlapping publications which overrode each other. * Fix more Gradle 10 deprecations * Enable configuration cache by default * Fix missing task dependency of :enigma-cli:test--- build.gradle | 14 +++++++------- enigma-cli/build.gradle | 10 ++-------- enigma-swing/build.gradle | 10 +--------- enigma/build.gradle | 23 ++++++++++++++--------- gradle.properties | 1 + gradle/wrapper/gradle-wrapper.jar | Bin 63721 -> 45457 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 14 ++++++++------ gradlew.bat | 26 ++++++++++++++------------ 9 files changed, 48 insertions(+), 52 deletions(-) create mode 100644 gradle.properties diff --git a/build.gradle b/build.gradle index 9f31184..caf78f1 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'maven-publish' - id 'com.github.johnrengelman.shadow' version '8.1.1' apply false + id 'com.gradleup.shadow' version '8.3.9' apply false id 'com.diffplug.spotless' version '7.2.1' } @@ -13,7 +13,7 @@ subprojects { repositories { mavenLocal() mavenCentral() - maven { url 'https://maven.fabricmc.net/' } + maven { url = 'https://maven.fabricmc.net/' } } dependencies { @@ -60,9 +60,9 @@ subprojects { publishing { publications { "$project.name"(MavenPublication) { - groupId project.group - artifactId project.name - version project.version + groupId = project.group + artifactId = project.name + version = project.version from components.java } } @@ -89,10 +89,10 @@ allprojects { } // A task to ensure that the version being released has not already been released. -task checkVersion { +tasks.register('checkVersion') { doFirst { def xml = new URL("https://maven.fabricmc.net/cuchaz/enigma/maven-metadata.xml").text - def metadata = new XmlSlurper().parseText(xml) + def metadata = new groovy.xml.XmlSlurper().parseText(xml) def versions = metadata.versioning.versions.version*.text(); if (versions.contains(version)) { throw new RuntimeException("${version} has already been released!") diff --git a/enigma-cli/build.gradle b/enigma-cli/build.gradle index 05e644e..7bffb21 100644 --- a/enigma-cli/build.gradle +++ b/enigma-cli/build.gradle @@ -1,6 +1,6 @@ plugins { id 'application' - id 'com.github.johnrengelman.shadow' + id 'com.gradleup.shadow' } dependencies { @@ -13,10 +13,4 @@ application { jar.manifest.attributes 'Main-Class': application.mainClass.get() -publishing { - publications { - shadow(MavenPublication) { publication -> - project.shadow.component publication - } - } -} +test.dependsOn project(':enigma').tasks.named('packageAccessTestObf') diff --git a/enigma-swing/build.gradle b/enigma-swing/build.gradle index 452df5e..8a8d679 100644 --- a/enigma-swing/build.gradle +++ b/enigma-swing/build.gradle @@ -1,6 +1,6 @@ plugins { id 'application' - id 'com.github.johnrengelman.shadow' + id 'com.gradleup.shadow' } def flatLafNatives = [ @@ -31,11 +31,3 @@ application { } jar.manifest.attributes 'Main-Class': application.mainClass.get() - -publishing { - publications { - shadow(MavenPublication) { publication -> - publication.from components.java - } - } -} \ No newline at end of file diff --git a/enigma/build.gradle b/enigma/build.gradle index 6bbb200..e92052f 100644 --- a/enigma/build.gradle +++ b/enigma/build.gradle @@ -19,15 +19,20 @@ dependencies { // Generate "version.txt" file -ext.genOutputDir = file("$buildDir/generated-resources") +def genOutputDir = layout.buildDirectory.dir('generated-resources').get().asFile -task generateResources { - ext.versionFile = file("$genOutputDir/version.txt") - ext.langsFile = file("$genOutputDir/lang/index.txt") +tasks.register('generateResources') { + def langDir = file('src/main/resources/lang') + inputs.dir(langDir) + inputs.property 'version', project.version + + def versionFile = file("$genOutputDir/version.txt") + def langsFile = file("$genOutputDir/lang/index.txt") outputs.files(versionFile, langsFile) + doLast { - versionFile.text = "${project.version}" - langsFile.text = file("$projectDir/src/main/resources/lang") + versionFile.text = inputs.properties.version + langsFile.text = langDir .listFiles() .collect { it.name } .findAll { it.endsWith(".json") } @@ -45,7 +50,7 @@ def libraryJarsArg = "/jmods" // If your test fails for class file version problem with proguard, run gradle with -Dorg.gradle.java.home="" flag file('src/test/java/cuchaz/enigma/inputs').listFiles().each { theFile -> if (theFile.directory) { - task("${theFile.name}TestJar", type: Jar) { + tasks.register("${theFile.name}TestJar", Jar) { from(sourceSets.test.output) { include "cuchaz/enigma/inputs/$theFile.name/**/*.class" include 'cuchaz/enigma/inputs/Keep.class' @@ -55,8 +60,8 @@ file('src/test/java/cuchaz/enigma/inputs').listFiles().each { theFile -> destinationDirectory = file('build/test-inputs') } - task("${theFile.name}TestObf", type: JavaExec, - dependsOn: "${theFile.name}TestJar") { + tasks.register("${theFile.name}TestObf", JavaExec) { + dependsOn "${theFile.name}TestJar" mainClass = 'proguard.ProGuard' classpath configurations.proGuard diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..5ad6974 --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +org.gradle.configuration-cache=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7f93135..8bdaf60 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3fa8f86..2a84e18 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a4..ef07e01 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,7 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -203,7 +205,7 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. @@ -211,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/gradlew.bat b/gradlew.bat index 93e3f59..db3a6ac 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,22 +59,22 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell -- cgit v1.2.3