diff --git a/.github/workflows/test-push.yml b/.github/workflows/test-push.yml index 849ee3da..b9c6ee1f 100644 --- a/.github/workflows/test-push.yml +++ b/.github/workflows/test-push.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - version: [7.5.1-jdk17] + version: [8.1.0-jdk17] runs-on: ubuntu-22.04 container: image: gradle:${{ matrix.version }} @@ -27,7 +27,7 @@ jobs: runs-on: ubuntu-22.04 container: - image: gradle:7.5.1-jdk17 + image: gradle:8.1.0-jdk17 options: --user root steps: @@ -46,7 +46,7 @@ jobs: strategy: fail-fast: false matrix: - version: [7.5.1-jdk17] + version: [8.1.0-jdk17] test: ${{ fromJson(needs.prepare_test_matrix.outputs.matrix) }} runs-on: ubuntu-22.04 @@ -113,7 +113,7 @@ jobs: strategy: fail-fast: false matrix: - java: [ 17, 18 ] + java: [ 17, 20 ] os: [ windows-2022, ubuntu-22.04, macos-12 ] runs-on: ${{ matrix.os }} diff --git a/bootstrap/src/main/java/net/fabricmc/loom/bootstrap/LoomGradlePluginBootstrap.java b/bootstrap/src/main/java/net/fabricmc/loom/bootstrap/LoomGradlePluginBootstrap.java index 804f486b..c8a45de0 100644 --- a/bootstrap/src/main/java/net/fabricmc/loom/bootstrap/LoomGradlePluginBootstrap.java +++ b/bootstrap/src/main/java/net/fabricmc/loom/bootstrap/LoomGradlePluginBootstrap.java @@ -14,7 +14,7 @@ import org.gradle.util.GradleVersion; */ @SuppressWarnings("unused") public class LoomGradlePluginBootstrap implements Plugin { - private static final int MIN_SUPPORTED_MAJOR_GRADLE_VERSION = 7; + private static final String MIN_SUPPORTED_GRADLE_VERSION = "8.1"; private static final int MIN_SUPPORTED_MAJOR_JAVA_VERSION = 17; private static final int MIN_SUPPORTED_MAJOR_IDEA_VERSION = 2021; @@ -40,7 +40,7 @@ public class LoomGradlePluginBootstrap implements Plugin { List errors = new ArrayList<>(); if (!isValidGradleRuntime()) { - errors.add(String.format("You are using an outdated version of Gradle (%s). Gradle %d or higher is required.", GradleVersion.current().getVersion(), MIN_SUPPORTED_MAJOR_GRADLE_VERSION)); + errors.add(String.format("You are using an outdated version of Gradle (%s). Gradle %s or higher is required.", GradleVersion.current().getVersion(), MIN_SUPPORTED_GRADLE_VERSION)); } if (!isValidJavaRuntime()) { @@ -73,7 +73,7 @@ public class LoomGradlePluginBootstrap implements Plugin { } private static boolean isValidGradleRuntime() { - return getMajorGradleVersion() >= MIN_SUPPORTED_MAJOR_GRADLE_VERSION; + return GradleVersion.current().compareTo(GradleVersion.version(MIN_SUPPORTED_GRADLE_VERSION)) >= 0; } private static boolean isValidIdeaRuntime() { @@ -87,11 +87,6 @@ public class LoomGradlePluginBootstrap implements Plugin { return ideaYear >= MIN_SUPPORTED_MAJOR_IDEA_VERSION; } - private static int getMajorGradleVersion() { - String version = GradleVersion.current().getVersion(); - return Integer.parseInt(version.substring(0, version.indexOf("."))); - } - BootstrappedPlugin getActivePlugin() { try { return (BootstrappedPlugin) Class.forName(PLUGIN_CLASS_NAME).getConstructor().newInstance(); diff --git a/build.gradle b/build.gradle index 4b1d5815..02e6df6b 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { id 'checkstyle' id 'jacoco' id 'codenarc' - id "org.jetbrains.kotlin.jvm" version "1.6.10" // Must match the version included with gradle. + id "org.jetbrains.kotlin.jvm" version "1.8.0" // Must match the version included with gradle. id "com.diffplug.spotless" version "6.13.0" id "org.gradle.test-retry" version "1.5.1" } @@ -100,7 +100,7 @@ dependencies { } // Kapt integration - compileOnly('org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10') // Must match the version included with gradle. + compileOnly('org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0') // Must match the version included with gradle. // Testing testImplementation(gradleTestKit()) @@ -194,7 +194,7 @@ jacocoTestReport { reports { xml.required = false csv.required = false - html.destination file("${buildDir}/jacocoHtml") + html.outputLocation = file("${buildDir}/jacocoHtml") } } @@ -321,9 +321,9 @@ task downloadGradleSources() { doLast { // Awful hack to find the gradle api location def gradleApiFile = project.configurations.detachedConfiguration(dependencies.gradleApi()).files.stream() - .filter { + .find { it.name.startsWith("gradle-api") - }.findFirst().orElseThrow() + } def gradleApiSources = new File(gradleApiFile.absolutePath.replace(".jar", "-sources.jar")) def url = "https://services.gradle.org/distributions/gradle-${GradleVersion.current().getVersion()}-src.zip" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e5832..c1962a79 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 8fad3f5a..a21c6ebe 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index a69d9cb6..aeb74cbb 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -143,12 +140,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in diff --git a/gradlew.bat b/gradlew.bat index f127cfd4..93e3f59f 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% diff --git a/src/main/java/net/fabricmc/loom/task/AbstractRunTask.java b/src/main/java/net/fabricmc/loom/task/AbstractRunTask.java index 88767e70..d5ca8e2c 100644 --- a/src/main/java/net/fabricmc/loom/task/AbstractRunTask.java +++ b/src/main/java/net/fabricmc/loom/task/AbstractRunTask.java @@ -59,6 +59,8 @@ public abstract class AbstractRunTask extends JavaExec { args(config.programArgs); getMainClass().set(config.mainClass); + + getJvmArguments().addAll(getProject().provider(this::getGameJvmArgs)); } private boolean canUseArgFile() { @@ -93,9 +95,7 @@ public abstract class AbstractRunTask extends JavaExec { super.setWorkingDir(dir); } - @Override - public List getJvmArgs() { - final List superArgs = super.getJvmArgs(); + private List getGameJvmArgs() { final List args = new ArrayList<>(); if (canUseArgFile()) { @@ -113,10 +113,6 @@ public abstract class AbstractRunTask extends JavaExec { } } - if (superArgs != null) { - args.addAll(superArgs); - } - args.addAll(config.vmArgs); return args; } diff --git a/src/test/groovy/net/fabricmc/loom/test/LoomTestConstants.groovy b/src/test/groovy/net/fabricmc/loom/test/LoomTestConstants.groovy index 1c7ed660..1db061a2 100644 --- a/src/test/groovy/net/fabricmc/loom/test/LoomTestConstants.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/LoomTestConstants.groovy @@ -32,16 +32,13 @@ class LoomTestConstants { // Test against the version of Gradle being used to build loom public final static String DEFAULT_GRADLE = GradleVersion.current().getVersion() - // Test against Gradle 8 - public final static String GRADLE_8 = "8.1" // Tests that depend specifically on the nightly will run on the current version when the nightly is not available. public final static String PRE_RELEASE_GRADLE = NIGHTLY_EXISTS ? NIGHTLY_VERSION : DEFAULT_GRADLE // Randomly sorted to ensure that all versions can run with a clean gradle home. - public final static String[] STANDARD_TEST_VERSIONS = (NIGHTLY_EXISTS ? [ + public final static List STANDARD_TEST_VERSIONS = (NIGHTLY_EXISTS ? [ DEFAULT_GRADLE, - GRADLE_8, PRE_RELEASE_GRADLE - ] : [DEFAULT_GRADLE, GRADLE_8]).shuffled().toArray() + ] : [DEFAULT_GRADLE]).shuffled().toArray() public static final File TEST_DIR = new File("./.gradle/test-files") diff --git a/src/test/groovy/net/fabricmc/loom/test/integration/RunConfigTest.groovy b/src/test/groovy/net/fabricmc/loom/test/integration/RunConfigTest.groovy index 9a255b59..38438e8b 100644 --- a/src/test/groovy/net/fabricmc/loom/test/integration/RunConfigTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/integration/RunConfigTest.groovy @@ -35,10 +35,17 @@ import static org.gradle.testkit.runner.TaskOutcome.SUCCESS // This test runs a mod that exits on mod init class RunConfigTest extends Specification implements GradleProjectTestTrait { + private static List tasks = [ + "runClient", + "runServer", + "runTestmodClient", + "runTestmodServer", + "runAutoTestServer" + ] @Unroll - def "Run config #task"() { + def "Run config #task (gradle #version)"() { setup: - def gradle = gradleProject(project: "runconfigs", sharedFiles: true) + def gradle = gradleProject(project: "runconfigs", sharedFiles: true, version: version) when: def result = gradle.run(task: task) @@ -48,12 +55,8 @@ class RunConfigTest extends Specification implements GradleProjectTestTrait { result.output.contains("This contains a space") where: - task | _ - 'runClient' | _ - 'runServer' | _ - 'runTestmodClient' | _ - 'runTestmodServer' | _ - 'runAutoTestServer' | _ + version << STANDARD_TEST_VERSIONS * tasks.size() + task << tasks * STANDARD_TEST_VERSIONS.size() } @RestoreSystemProperties