Update to Gradle 8.3, and update all other deps. (#946)

* Update to Gradle 8.3, and update all other deps.

* Fix tests

* Lazily download decompilers, generate version constants to ensure they are synced between the build and Gradle.

Each decompiler has a configuration, this allows the version to be changed at a later date if needed.

* Fix typo :)

* Oh so many versions
This commit is contained in:
modmuss
2023-08-24 10:18:25 +01:00
committed by GitHub
parent fc9041a071
commit 3a090917ff
26 changed files with 340 additions and 112 deletions

View File

@@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [8.1.0-jdk17]
version: [8.3.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:8.1.0-jdk17
image: gradle:8.3.0-jdk17
options: --user root
steps:
@@ -46,7 +46,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [8.1.0-jdk17]
version: [8.3.0-jdk17]
test: ${{ fromJson(needs.prepare_test_matrix.outputs.matrix) }}
runs-on: ubuntu-22.04

4
.gitignore vendored
View File

@@ -21,4 +21,6 @@
!/Jenkinsfile
!/checkstyle.xml
!/codenarc.groovy
!/bootstrap
!/bootstrap
/src/**/generated

View File

@@ -3,8 +3,10 @@ plugins {
id 'groovy'
}
sourceCompatibility = 8
targetCompatibility = 8
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"

View File

@@ -14,7 +14,7 @@ import org.gradle.util.GradleVersion;
*/
@SuppressWarnings("unused")
public class LoomGradlePluginBootstrap implements Plugin<PluginAware> {
private static final String MIN_SUPPORTED_GRADLE_VERSION = "8.1";
private static final String MIN_SUPPORTED_GRADLE_VERSION = "8.3";
private static final int MIN_SUPPORTED_MAJOR_JAVA_VERSION = 17;
private static final int MIN_SUPPORTED_MAJOR_IDEA_VERSION = 2021;

View File

@@ -9,8 +9,8 @@ plugins {
id 'jacoco'
id 'codenarc'
alias(libs.plugins.kotlin)
id "com.diffplug.spotless" version "6.18.0"
id "org.gradle.test-retry" version "1.5.2"
alias(libs.plugins.spotless)
alias(libs.plugins.retry)
}
tasks.withType(JavaCompile).configureEach {
@@ -24,7 +24,6 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
}
group = 'net.fabricmc'
archivesBaseName = project.name
def baseVersion = '1.4'
def ENV = System.getenv()
@@ -69,39 +68,35 @@ dependencies {
bootstrap project(":bootstrap")
// libraries
implementation ('commons-io:commons-io:2.11.0')
implementation ('com.google.code.gson:gson:2.10.1')
implementation ('com.fasterxml.jackson.core:jackson-databind:2.14.2')
implementation ('com.google.guava:guava:31.1-jre')
implementation ('org.ow2.asm:asm:9.5')
implementation ('org.ow2.asm:asm-analysis:9.5')
implementation ('org.ow2.asm:asm-commons:9.5')
implementation ('org.ow2.asm:asm-tree:9.5')
implementation ('org.ow2.asm:asm-util:9.5')
implementation libs.commons.io
implementation libs.gson
implementation libs.jackson
implementation libs.guava
implementation libs.bundles.asm
// game handling utils
implementation ('net.fabricmc:stitch:0.6.2') {
implementation (libs.fabric.stitch) {
exclude module: 'enigma'
}
// tinyfile management
implementation ('net.fabricmc:tiny-remapper:0.8.7')
implementation 'net.fabricmc:access-widener:2.1.0'
implementation 'net.fabricmc:mapping-io:0.2.1'
implementation libs.fabric.tiny.remapper
implementation libs.fabric.access.widener
implementation libs.fabric.mapping.io
implementation ('net.fabricmc:lorenz-tiny:4.0.2') {
implementation (libs.fabric.lorenz.tiny) {
transitive = false
}
// decompilers
implementation ('net.fabricmc:fabric-fernflower:2.0.0')
implementation ('net.fabricmc:cfr:0.2.1')
compileOnly runtimeLibs.fernflower
compileOnly runtimeLibs.cfr
// source code remapping
implementation ('net.fabricmc:mercury:0.3.0')
implementation libs.fabric.mercury
// Kotlin
implementation('org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.6.2') {
implementation(libs.kotlin.metadata) {
transitive = false
}
@@ -110,20 +105,21 @@ dependencies {
// Testing
testImplementation(gradleTestKit())
testImplementation('org.spockframework:spock-core:2.3-groovy-3.0') {
testImplementation(testLibs.spock) {
exclude module: 'groovy-all'
}
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.9.2'
testImplementation ('io.javalin:javalin:5.4.2') {
testImplementation testLibs.junit.jupiter.engine
testRuntimeOnly testLibs.junit.platform.launcher
testImplementation (testLibs.javalin) {
exclude group: 'org.jetbrains.kotlin'
}
testImplementation 'org.mockito:mockito-core:5.2.0'
testImplementation 'com.microsoft.java:com.microsoft.java.debug.core:0.46.0'
testImplementation testLibs.mockito
testImplementation testLibs.java.debug
compileOnly 'org.jetbrains:annotations:24.0.1'
testCompileOnly 'org.jetbrains:annotations:24.0.1'
compileOnly runtimeLibs.jetbrains.annotations
testCompileOnly runtimeLibs.jetbrains.annotations
testCompileOnly ('net.fabricmc:sponge-mixin:0.11.4+mixin.0.8.5') {
testCompileOnly (testLibs.mixin) {
transitive = false
}
}
@@ -136,8 +132,9 @@ jar {
from configurations.bootstrap.collect { it.isDirectory() ? it : zipTree(it) }
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
base {
archivesName = project.name
}
tasks.withType(JavaCompile).configureEach {
it.options.release = 17
@@ -145,6 +142,8 @@ tasks.withType(JavaCompile).configureEach {
java {
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
spotless {
@@ -174,11 +173,11 @@ spotless {
checkstyle {
configFile = file('checkstyle.xml')
toolVersion = '10.6.0'
toolVersion = libs.versions.checkstyle.get()
}
codenarc {
toolVersion = "3.2.0"
toolVersion = libs.versions.codenarc.get()
configFile = file("codenarc.groovy")
}
@@ -192,7 +191,7 @@ gradlePlugin {
}
jacoco {
toolVersion = "0.8.8"
toolVersion = libs.versions.jacoco.get()
}
// Run to get test coverage.
@@ -201,7 +200,7 @@ jacocoTestReport {
reports {
xml.required = false
csv.required = false
html.outputLocation = file("${buildDir}/jacocoHtml")
html.outputLocation = file("${layout.buildDirectory.get().asFile}/jacocoHtml")
}
}
@@ -234,7 +233,7 @@ publishing {
// Also publish a snapshot so people can use the latest version if they wish
snapshot(MavenPublication) { publication ->
groupId project.group
artifactId project.archivesBaseName
artifactId project.base.archivesName.get()
version baseVersion + '-SNAPSHOT'
from components.java
@@ -360,3 +359,5 @@ class PrintActionsTestName extends DefaultTask {
new File(System.getenv().GITHUB_OUTPUT) << "\ntest=$sanitised"
}
}
apply from: rootProject.file('gradle/versions.gradle')

View File

@@ -1,8 +1,54 @@
[versions]
kotlin = "1.8.10"
kotlin = "1.9.0"
asm = "9.5"
commons-io = "2.13.0"
gson = "2.10.1"
jackson = "2.15.2"
guava = "32.1.2-jre"
stitch = "0.6.2"
tiny-remapper = "0.8.9"
access-widener = "2.1.0"
mapping-io = "0.4.2"
lorenz-tiny = "4.0.2"
mercury = "0.4.0"
kotlinx-metadata = "0.7.0"
# Plugins
spotless = "6.20.0"
test-retry = "1.5.4"
checkstyle = "10.12.2"
codenarc = "3.3.0"
jacoco = "0.8.10"
[libraries]
# Loom compile libraries
asm = { module = "org.ow2.asm:asm", version.ref = "asm" }
asm-analysis = { module = "org.ow2.asm:asm-analysis", version.ref = "asm" }
asm-commons = { module = "org.ow2.asm:asm-commons", version.ref = "asm" }
asm-tree = { module = "org.ow2.asm:asm-tree", version.ref = "asm" }
asm-util = { module = "org.ow2.asm:asm-util", version.ref = "asm" }
commons-io = { module = "commons-io:commons-io", version.ref = "commons-io" }
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
jackson = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" }
guava = { module = "com.google.guava:guava", version.ref = "guava" }
fabric-stitch = { module = "net.fabricmc:stitch", version.ref = "stitch" }
fabric-tiny-remapper = { module = "net.fabricmc:tiny-remapper", version.ref = "tiny-remapper" }
fabric-access-widener = { module = "net.fabricmc:access-widener", version.ref = "access-widener" }
fabric-mapping-io = { module = "net.fabricmc:mapping-io", version.ref = "mapping-io" }
fabric-lorenz-tiny = { module = "net.fabricmc:lorenz-tiny", version.ref = "lorenz-tiny" }
fabric-mercury = { module = "net.fabricmc:mercury", version.ref = "mercury" }
# Misc
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlin-metadata = { module = "org.jetbrains.kotlinx:kotlinx-metadata-jvm", version.ref = "kotlinx-metadata" }
[plugins]
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
retry = { id = "org.gradle.test-retry", version.ref = "test-retry" }
[bundles]
asm = ["asm", "asm-analysis", "asm-commons", "asm-tree", "asm-util"]

View File

@@ -0,0 +1,23 @@
[versions]
# Decompilers
fernflower = "2.0.0"
cfr = "0.2.1"
# Runtime depedencies
mixin-compile-extensions = "0.6.0"
dev-launch-injector = "0.2.1+build.8"
terminal-console-appender = "1.2.0"
jetbrains-annotations = "24.0.1"
native-support = "1.0.1"
[libraries]
# Decompilers
fernflower = { module = "net.fabricmc:fabric-fernflower", version.ref = "fernflower" }
cfr = { module = "net.fabricmc:cfr", version.ref = "cfr" }
# Runtime depedencies
mixin-compile-extensions = { module = "net.fabricmc:fabric-mixin-compile-extensions", version.ref = "mixin-compile-extensions" }
dev-launch-injector = { module = "net.fabricmc:dev-launch-injector", version.ref = "dev-launch-injector" }
terminal-console-appender = { module = "net.minecrell:terminalconsoleappender", version.ref = "terminal-console-appender" }
jetbrains-annotations = { module = "org.jetbrains:annotations", version.ref = "jetbrains-annotations" }
native-support = { module = "net.fabricmc:fabric-loom-native-support", version.ref = "native-support" }

View File

@@ -0,0 +1,23 @@
[versions]
spock = "2.3-groovy-3.0"
junit = "5.10.0"
javalin = "5.6.2"
mockito = "5.4.0"
java-debug = "0.48.0"
mixin = "0.11.4+mixin.0.8.5"
gradle-nightly = "8.4-20230821223421+0000"
fabric-loader = "0.14.22"
fabric-installer = "0.11.1"
[libraries]
spock = { module = "org.spockframework:spock-core", version.ref = "spock" }
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" }
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" }
javalin = { module = "io.javalin:javalin", version.ref = "javalin" }
mockito = { module = "org.mockito:mockito-core", version.ref = "mockito" }
java-debug = { module = "com.microsoft.java:com.microsoft.java.debug.core", version.ref = "java-debug" }
mixin = { module = "net.fabricmc:sponge-mixin", version.ref = "mixin" }
gradle-nightly = { module = "org.gradle:dummy", version.ref = "gradle-nightly" }
fabric-loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric-loader" }
fabric-installer = { module = "net.fabricmc:fabric-installer", version.ref = "fabric-installer" }

85
gradle/versions.gradle Normal file
View File

@@ -0,0 +1,85 @@
/**
* Generates a java source file containing all of the version from the Gradle version catalog.
*/
import java.nio.file.Files
import java.time.LocalDate
generateVersionConstants(sourceSets.main, "runtimeLibs", "net/fabricmc/loom/util/LoomVersions")
generateVersionConstants(sourceSets.test, "testLibs", "net/fabricmc/loom/test/LoomTestVersions")
def generateVersionConstants(def sourceSet, def catalogName, def sourcesName) {
def versionCatalog = extensions.getByType(VersionCatalogsExtension.class).named(catalogName)
def task = tasks.register("${catalogName}GenerateConstants", GenerateVersions.class) {
versionCatalog.getLibraryAliases().forEach {
def lib = versionCatalog.findLibrary(it).get().get()
getVersions().put(it, lib.toString())
}
className = sourcesName
headerFile = file("HEADER")
outputDir = file("src/${sourceSet.name}/generated")
}
sourceSet.java.srcDir task
spotlessGroovyGradle.dependsOn task // Not quite sure why this is needed, but it fixes a warning.
compileKotlin.dependsOn task
sourcesJar.dependsOn task
}
abstract class GenerateVersions extends DefaultTask {
@Input
abstract MapProperty<String, String> getVersions()
@Input
abstract Property<String> getClassName()
@InputFile
abstract RegularFileProperty getHeaderFile()
@OutputDirectory
abstract DirectoryProperty getOutputDir()
@TaskAction
def run() {
def output = outputDir.get().asFile.toPath()
output.deleteDir()
def className = getClassName().get()
def si = className.lastIndexOf("/")
def packageName = className.substring(0, si)
def packagePath = output.resolve(packageName)
def sourceName = className.substring(si + 1, className.length())
def sourcePath = packagePath.resolve(sourceName + ".java")
Files.createDirectories(packagePath)
def constants = getVersions().get().collect { entry ->
def split = entry.value.split(":")
if (split.length != 3) return ""
"\tpublic static final ${sourceName} ${toSnakeCase(entry.key)} = new ${sourceName}(\"${split[0]}\", \"${split[1]}\", \"${split[2]}\");"
}.findAll { !it.blank }.join("\n")
def header = headerFile.get().getAsFile().text.replace("\$YEAR", "${LocalDate.now().year}").trim()
sourcePath.write(
"""${header}
package ${packageName.replace("/", ".")};
/**
* Auto generated class, do not edit.
*/
public record ${sourceName}(String group, String module, String version) {
${constants}
public String mavenNotation() {
return "%s:%s:%s".formatted(group, module, version);
}
}
""")
}
static def toSnakeCase(String input) {
return input.trim().replaceAll(/[^a-zA-Z0-9]+/, '_').toUpperCase()
}
}

Binary file not shown.

View File

@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

8
gradlew vendored
View File

@@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# 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
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -130,10 +131,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.

View File

@@ -1,3 +1,14 @@
rootProject.name = name
dependencyResolutionManagement {
versionCatalogs {
testLibs {
from(files("gradle/test.libs.versions.toml"))
}
runtimeLibs {
from(files("gradle/runtime.libs.versions.toml"))
}
}
}
include "bootstrap"

View File

@@ -47,6 +47,7 @@ import net.fabricmc.loom.configuration.providers.minecraft.MinecraftSourceSets;
import net.fabricmc.loom.extension.MixinExtension;
import net.fabricmc.loom.task.PrepareJarRemapTask;
import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.LoomVersions;
/**
* Normally javac invokes annotation processors, but when the scala or kapt plugin are installed they will want to invoke
@@ -147,7 +148,7 @@ public abstract class AnnotationProcessorInvoker<T extends Task> {
// Add Mixin and mixin extensions (fabric-mixin-compile-extensions pulls mixin itself too)
project.getDependencies().add(processorConfig.getName(),
Constants.Dependencies.MIXIN_COMPILE_EXTENSIONS + Constants.Dependencies.Versions.MIXIN_COMPILE_EXTENSIONS);
LoomVersions.MIXIN_COMPILE_EXTENSIONS.mavenNotation());
}
}

View File

@@ -35,6 +35,7 @@ import org.gradle.api.plugins.JavaPlugin;
import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.LoomVersions;
import net.fabricmc.loom.util.gradle.SourceSetHelper;
public abstract class LoomConfigurations implements Runnable {
@@ -104,10 +105,10 @@ public abstract class LoomConfigurations implements Runnable {
extendsFrom(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME, Constants.Configurations.MINECRAFT_RUNTIME_LIBRARIES);
// Add the dev time dependencies
getDependencies().add(Constants.Configurations.LOOM_DEVELOPMENT_DEPENDENCIES, Constants.Dependencies.DEV_LAUNCH_INJECTOR + Constants.Dependencies.Versions.DEV_LAUNCH_INJECTOR);
getDependencies().add(Constants.Configurations.LOOM_DEVELOPMENT_DEPENDENCIES, Constants.Dependencies.TERMINAL_CONSOLE_APPENDER + Constants.Dependencies.Versions.TERMINAL_CONSOLE_APPENDER);
getDependencies().add(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, Constants.Dependencies.JETBRAINS_ANNOTATIONS + Constants.Dependencies.Versions.JETBRAINS_ANNOTATIONS);
getDependencies().add(JavaPlugin.TEST_COMPILE_ONLY_CONFIGURATION_NAME, Constants.Dependencies.JETBRAINS_ANNOTATIONS + Constants.Dependencies.Versions.JETBRAINS_ANNOTATIONS);
getDependencies().add(Constants.Configurations.LOOM_DEVELOPMENT_DEPENDENCIES, LoomVersions.DEV_LAUNCH_INJECTOR.mavenNotation());
getDependencies().add(Constants.Configurations.LOOM_DEVELOPMENT_DEPENDENCIES, LoomVersions.TERMINAL_CONSOLE_APPENDER.mavenNotation());
getDependencies().add(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, LoomVersions.JETBRAINS_ANNOTATIONS.mavenNotation());
getDependencies().add(JavaPlugin.TEST_COMPILE_ONLY_CONFIGURATION_NAME, LoomVersions.JETBRAINS_ANNOTATIONS.mavenNotation());
}
private NamedDomainObjectProvider<Configuration> register(String name, Role role) {

View File

@@ -30,7 +30,7 @@ import java.util.function.Predicate;
import net.fabricmc.loom.configuration.providers.minecraft.library.Library;
import net.fabricmc.loom.configuration.providers.minecraft.library.LibraryContext;
import net.fabricmc.loom.configuration.providers.minecraft.library.LibraryProcessor;
import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.LoomVersions;
import net.fabricmc.loom.util.Platform;
public class LoomNativeSupportLibraryProcessor extends LibraryProcessor {
@@ -56,7 +56,7 @@ public class LoomNativeSupportLibraryProcessor extends LibraryProcessor {
@Override
public Predicate<Library> apply(Consumer<Library> dependencyConsumer) {
dependencyConsumer.accept(Library.fromMaven(Constants.Dependencies.NATIVE_SUPPORT + Constants.Dependencies.Versions.NATIVE_SUPPORT_VERSION, Library.Target.LOCAL_MOD));
dependencyConsumer.accept(Library.fromMaven(LoomVersions.NATIVE_SUPPORT.mavenNotation(), Library.Target.LOCAL_MOD));
return ALLOW_ALL;
}
}

View File

@@ -1,7 +1,7 @@
/*
* This file is part of fabric-loom, licensed under the MIT License (MIT).
*
* Copyright (c) 2018-2020 FabricMC
* Copyright (c) 2018-2023 FabricMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,12 +26,15 @@ package net.fabricmc.loom.decompilers;
import javax.inject.Inject;
import org.gradle.api.NamedDomainObjectProvider;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.api.decompilers.LoomDecompiler;
import net.fabricmc.loom.decompilers.cfr.LoomCFRDecompiler;
import net.fabricmc.loom.decompilers.fernflower.FabricFernFlowerDecompiler;
import net.fabricmc.loom.util.LoomVersions;
public abstract class DecompilerConfiguration implements Runnable {
@Inject
@@ -39,11 +42,24 @@ public abstract class DecompilerConfiguration implements Runnable {
@Override
public void run() {
registerDecompiler(getProject(), "fernFlower", FabricFernFlowerDecompiler.class);
registerDecompiler(getProject(), "cfr", LoomCFRDecompiler.class);
var fernflowerConfiguration = createConfiguration("fernflower", LoomVersions.FERNFLOWER);
var cfrConfiguration = createConfiguration("cfr", LoomVersions.CFR);
registerDecompiler(getProject(), "fernFlower", FabricFernFlowerDecompiler.class, fernflowerConfiguration);
registerDecompiler(getProject(), "cfr", LoomCFRDecompiler.class, cfrConfiguration);
}
private void registerDecompiler(Project project, String name, Class<? extends LoomDecompiler> decompilerClass) {
LoomGradleExtension.get(project).getDecompilerOptions().register(name, options -> options.getDecompilerClassName().set(decompilerClass.getName()));
private NamedDomainObjectProvider<Configuration> createConfiguration(String name, LoomVersions version) {
final String configurationName = name + "DecompilerClasspath";
NamedDomainObjectProvider<Configuration> configuration = getProject().getConfigurations().register(configurationName);
getProject().getDependencies().add(configurationName, version.mavenNotation());
return configuration;
}
private void registerDecompiler(Project project, String name, Class<? extends LoomDecompiler> decompilerClass, NamedDomainObjectProvider<Configuration> configuration) {
LoomGradleExtension.get(project).getDecompilerOptions().register(name, options -> {
options.getDecompilerClassName().set(decompilerClass.getName());
options.getClasspath().from(configuration);
});
}
}

View File

@@ -0,0 +1,37 @@
/*
* This file is part of fabric-loom, licensed under the MIT License (MIT).
*
* Copyright (c) 2023 FabricMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.fabricmc.loom.kotlin.remapping;
import kotlin.Metadata;
import kotlinx.metadata.jvm.KotlinClassMetadata;
/**
* Similar story to JvmExtensionWrapper, lets abuse the fact that Java can call "internal" Kotlin APIs without reflection :).
*/
public record KotlinClassMetadataWrapper(KotlinClassMetadata metadata) {
public Metadata getAnnotationData() {
return metadata.getAnnotationData$kotlinx_metadata_jvm();
}
}

View File

@@ -42,6 +42,7 @@ import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.LoomGradlePlugin;
import net.fabricmc.loom.configuration.InstallerData;
import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.LoomVersions;
import net.fabricmc.tinyremapper.TinyRemapper;
public abstract class JarManifestService implements BuildService<JarManifestService.Params> {
@@ -63,7 +64,7 @@ public abstract class JarManifestService implements BuildService<JarManifestServ
params.getGradleVersion().set(GradleVersion.current().getVersion());
params.getLoomVersion().set(LoomGradlePlugin.LOOM_VERSION);
params.getMCEVersion().set(Constants.Dependencies.Versions.MIXIN_COMPILE_EXTENSIONS);
params.getMCEVersion().set(LoomVersions.MIXIN_COMPILE_EXTENSIONS.version());
params.getMinecraftVersion().set(project.provider(() -> extension.getMinecraftProvider().minecraftVersion()));
params.getTinyRemapperVersion().set(tinyRemapperVersion.orElse("unknown"));
params.getFabricLoaderVersion().set(project.provider(() -> Optional.ofNullable(extension.getInstallerData()).map(InstallerData::version).orElse("unknown")));

View File

@@ -84,34 +84,6 @@ public class Constants {
}
}
/**
* Constants related to dependencies.
*/
public static final class Dependencies {
public static final String MIXIN_COMPILE_EXTENSIONS = "net.fabricmc:fabric-mixin-compile-extensions:";
public static final String DEV_LAUNCH_INJECTOR = "net.fabricmc:dev-launch-injector:";
public static final String TERMINAL_CONSOLE_APPENDER = "net.minecrell:terminalconsoleappender:";
public static final String JETBRAINS_ANNOTATIONS = "org.jetbrains:annotations:";
public static final String NATIVE_SUPPORT = "net.fabricmc:fabric-loom-native-support:";
private Dependencies() {
}
/**
* Constants for versions of dependencies.
*/
public static final class Versions {
public static final String MIXIN_COMPILE_EXTENSIONS = "0.6.0";
public static final String DEV_LAUNCH_INJECTOR = "0.2.1+build.8";
public static final String TERMINAL_CONSOLE_APPENDER = "1.2.0";
public static final String JETBRAINS_ANNOTATIONS = "24.0.1";
public static final String NATIVE_SUPPORT_VERSION = "1.0.1";
private Versions() {
}
}
}
public static final class MixinArguments {
public static final String IN_MAP_FILE_NAMED_INTERMEDIARY = "inMapFileNamedIntermediary";
public static final String OUT_MAP_FILE_NAMED_INTERMEDIARY = "outMapFileNamedIntermediary";

View File

@@ -192,7 +192,7 @@ public class SourceRemapper {
}
Set<File> files = project.getConfigurations()
.detachedConfiguration(project.getDependencies().create(Constants.Dependencies.JETBRAINS_ANNOTATIONS + Constants.Dependencies.Versions.JETBRAINS_ANNOTATIONS))
.detachedConfiguration(project.getDependencies().create(LoomVersions.JETBRAINS_ANNOTATIONS.mavenNotation()))
.resolve();
for (File file : files) {

View File

@@ -58,18 +58,18 @@ class KotlinClassMetadataRemappingAnnotationVisitor(private val remapper: Remapp
when (val metadata = KotlinClassMetadata.read(header)) {
is KotlinClassMetadata.Class -> {
var klass = metadata.toKmClass()
var klass = metadata.kmClass
klass = KotlinClassRemapper(remapper).remap(klass)
val remapped = KotlinClassMetadata.writeClass(klass, header.metadataVersion, header.extraInt).annotationData
val remapped = KotlinClassMetadata.writeClass(klass, header.metadataVersion, header.extraInt)
writeClassHeader(remapped)
validateKotlinClassHeader(remapped, header)
}
is KotlinClassMetadata.SyntheticClass -> {
var klambda = metadata.toKmLambda()
var klambda = metadata.kmLambda
if (klambda != null) {
klambda = KotlinClassRemapper(remapper).remap(klambda)
val remapped = KotlinClassMetadata.writeLambda(klambda, header.metadataVersion, header.extraInt).annotationData
val remapped = KotlinClassMetadata.writeLambda(klambda, header.metadataVersion, header.extraInt)
writeClassHeader(remapped)
validateKotlinClassHeader(remapped, header)
} else {
@@ -77,20 +77,21 @@ class KotlinClassMetadataRemappingAnnotationVisitor(private val remapper: Remapp
}
}
is KotlinClassMetadata.FileFacade -> {
var kpackage = metadata.toKmPackage()
var kpackage = metadata.kmPackage
kpackage = KotlinClassRemapper(remapper).remap(kpackage)
val remapped = KotlinClassMetadata.writeFileFacade(kpackage, header.metadataVersion, header.extraInt).annotationData
val remapped = KotlinClassMetadata.writeFileFacade(kpackage, header.metadataVersion, header.extraInt)
writeClassHeader(remapped)
validateKotlinClassHeader(remapped, header)
}
is KotlinClassMetadata.MultiFileClassPart -> {
var kpackage = metadata.toKmPackage()
var kpackage = metadata.kmPackage
kpackage = KotlinClassRemapper(remapper).remap(kpackage)
val remapped = KotlinClassMetadata.writeMultiFileClassPart(kpackage, metadata.facadeClassName, metadata.annotationData.metadataVersion, metadata.annotationData.extraInt).annotationData
val wrapper = KotlinClassMetadataWrapper(metadata)
val remapped = KotlinClassMetadata.writeMultiFileClassPart(kpackage, metadata.facadeClassName, wrapper.annotationData.metadataVersion, wrapper.annotationData.extraInt)
writeClassHeader(remapped)
validateKotlinClassHeader(remapped, header)
}
is KotlinClassMetadata.MultiFileClassFacade, is KotlinClassMetadata.Unknown, null -> {
is KotlinClassMetadata.MultiFileClassFacade, is KotlinClassMetadata.Unknown -> {
// do nothing
accept(next)
}

View File

@@ -49,10 +49,10 @@ import kotlinx.metadata.internal.extensions.KmTypeAliasExtension
import kotlinx.metadata.internal.extensions.KmTypeExtension
import kotlinx.metadata.internal.extensions.KmTypeParameterExtension
import kotlinx.metadata.internal.extensions.KmValueParameterExtension
import kotlinx.metadata.isLocal
import kotlinx.metadata.isLocalClassName
import kotlinx.metadata.jvm.JvmFieldSignature
import kotlinx.metadata.jvm.JvmMethodSignature
import kotlinx.metadata.jvm.jvmInternalName
import kotlinx.metadata.jvm.toJvmInternalName
import org.objectweb.asm.commons.Remapper
@OptIn(ExperimentalContextReceivers::class)
@@ -86,8 +86,8 @@ class KotlinClassRemapper(private val remapper: Remapper) {
}
private fun remap(name: ClassName): ClassName {
val local = name.isLocal
val remapped = remapper.map(name.jvmInternalName).replace('$', '.')
val local = name.isLocalClassName()
val remapped = remapper.map(name.toJvmInternalName()).replace('$', '.')
if (local) {
return ".$remapped"
@@ -241,10 +241,10 @@ class KotlinClassRemapper(private val remapper: Remapper) {
}
private fun remap(signature: JvmMethodSignature): JvmMethodSignature {
return JvmMethodSignature(signature.name, remapper.mapMethodDesc(signature.desc))
return JvmMethodSignature(signature.name, remapper.mapMethodDesc(signature.descriptor))
}
private fun remap(signature: JvmFieldSignature): JvmFieldSignature {
return JvmFieldSignature(signature.name, remapper.mapDesc(signature.desc))
return JvmFieldSignature(signature.name, remapper.mapDesc(signature.descriptor))
}
}

View File

@@ -27,7 +27,7 @@ package net.fabricmc.loom.test
import org.gradle.util.GradleVersion
class LoomTestConstants {
private final static String NIGHTLY_VERSION = "8.3-20230702222859+0000"
private final static String NIGHTLY_VERSION = LoomTestVersions.GRADLE_NIGHTLY.version()
private final static boolean NIGHTLY_EXISTS = nightlyExists(NIGHTLY_VERSION)
// Test against the version of Gradle being used to build loom

View File

@@ -45,7 +45,7 @@ class FabricAPITest extends Specification implements GradleProjectTestTrait {
setup:
def gradle = gradleProject(
repo: "https://github.com/FabricMC/fabric.git",
commit: "1ac061308b9d70fa6aad5db3dcc5580cb6ac71cb",
commit: "f091af96c53963fadf9dbc391c67bb40e5678a96",
version: version,
patch: "fabric_api"
)
@@ -55,7 +55,7 @@ class FabricAPITest extends Specification implements GradleProjectTestTrait {
// Set the version to something constant
gradle.buildGradle.text = gradle.buildGradle.text.replace('project.version + "+" + (ENV.GITHUB_RUN_NUMBER ? "" : "local-") + getBranch()', "\"$API_VERSION\"")
def server = ServerRunner.create(gradle.projectDir, "1.20.1")
def server = ServerRunner.create(gradle.projectDir, "23w33a")
.withMod(gradle.getOutputFile("fabric-api-${API_VERSION}.jar"))
when:
def result = gradle.run(tasks: [
@@ -77,8 +77,8 @@ class FabricAPITest extends Specification implements GradleProjectTestTrait {
result.task(":build").outcome == SUCCESS
result.task(":prepareRemapJar").outcome == SUCCESS
new File(gradle.mavenLocalDir, "net/fabricmc/fabric-api/fabric-biome-api-v1/13.0.10/fabric-biome-api-v1-13.0.10.jar").exists()
new File(gradle.mavenLocalDir, "net/fabricmc/fabric-api/fabric-biome-api-v1/13.0.10/fabric-biome-api-v1-13.0.10-sources.jar").exists()
new File(gradle.mavenLocalDir, "net/fabricmc/fabric-api/fabric-biome-api-v1/13.0.11/fabric-biome-api-v1-13.0.11.jar").exists()
new File(gradle.mavenLocalDir, "net/fabricmc/fabric-api/fabric-biome-api-v1/13.0.11/fabric-biome-api-v1-13.0.11-sources.jar").exists()
serverResult.successful()
serverResult.output.contains("- fabric-api $API_VERSION")

View File

@@ -28,11 +28,12 @@ import java.util.concurrent.TimeUnit
import groovy.transform.Immutable
import net.fabricmc.loom.test.LoomTestVersions
import net.fabricmc.loom.util.download.Download
class ServerRunner {
static final String LOADER_VERSION = "0.14.21"
static final String INSTALLER_VERSION = "0.11.1"
static final String LOADER_VERSION = LoomTestVersions.FABRIC_LOADER.version()
static final String INSTALLER_VERSION = LoomTestVersions.FABRIC_INSTALLER.version()
static final Map<String, String> FABRIC_API_URLS = [
"1.16.5": "https://github.com/FabricMC/fabric/releases/download/0.37.1%2B1.16/fabric-api-0.37.1+1.16.jar",
"1.17.1": "https://github.com/FabricMC/fabric/releases/download/0.37.1%2B1.17/fabric-api-0.37.1+1.17.jar"