mirror of
https://github.com/FabricMC/fabric-loom.git
synced 2025-09-04 11:04:03 +00:00
Update to Gradle 8.1 (#864)
* Update to Gradle 8.1 * Fix build, run RunConfigTest against all gradle versions. * Fix build
This commit is contained in:
8
.github/workflows/test-push.yml
vendored
8
.github/workflows/test-push.yml
vendored
@@ -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 }}
|
||||
|
@@ -14,7 +14,7 @@ import org.gradle.util.GradleVersion;
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class LoomGradlePluginBootstrap implements Plugin<PluginAware> {
|
||||
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<PluginAware> {
|
||||
List<String> 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<PluginAware> {
|
||||
}
|
||||
|
||||
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<PluginAware> {
|
||||
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();
|
||||
|
10
build.gradle
10
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"
|
||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -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
|
||||
|
19
gradlew
vendored
19
gradlew
vendored
@@ -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
|
||||
|
1
gradlew.bat
vendored
1
gradlew.bat
vendored
@@ -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%
|
||||
|
||||
|
@@ -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<String> getJvmArgs() {
|
||||
final List<String> superArgs = super.getJvmArgs();
|
||||
private List<String> getGameJvmArgs() {
|
||||
final List<String> 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;
|
||||
}
|
||||
|
@@ -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<String> 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")
|
||||
|
||||
|
@@ -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<String> 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
|
||||
|
Reference in New Issue
Block a user