diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 940a8751a..dc1402b62 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,7 +6,7 @@ gson = "2.10.1" guava = "33.0.0-jre" stitch = "0.6.2" -tiny-remapper = "0.10.3" +tiny-remapper = "0.10.4" access-widener = "2.1.0" mapping-io = "0.6.1" lorenz-tiny = "4.0.2" diff --git a/gradle/runtime.libs.versions.toml b/gradle/runtime.libs.versions.toml index 2a0692292..e35da821b 100644 --- a/gradle/runtime.libs.versions.toml +++ b/gradle/runtime.libs.versions.toml @@ -8,7 +8,7 @@ vineflower = "1.10.1" mixin-compile-extensions = "0.6.0" dev-launch-injector = "0.2.1+build.8" terminal-console-appender = "1.3.0" -jetbrains-annotations = "24.1.0" +jetbrains-annotations = "25.0.0" native-support = "1.0.1" [libraries] diff --git a/gradle/test.libs.versions.toml b/gradle/test.libs.versions.toml index 1dfbf9354..c3c92e8bf 100644 --- a/gradle/test.libs.versions.toml +++ b/gradle/test.libs.versions.toml @@ -1,13 +1,13 @@ [versions] spock = "2.3-groovy-3.0" -junit = "5.10.2" -javalin = "6.1.6" -mockito = "5.12.0" +junit = "5.11.1" +javalin = "6.3.0" +mockito = "5.13.0" java-debug = "0.52.0" -mixin = "0.12.5+mixin.0.8.5" +mixin = "0.15.3+mixin.0.8.7" -gradle-nightly = "8.11-20240814172604+0000" -fabric-loader = "0.15.11" +gradle-nightly = "8.11-20240926001708+0000" +fabric-loader = "0.16.5" fabric-installer = "1.0.1" [libraries] diff --git a/src/main/java/net/fabricmc/loom/LoomGradleExtension.java b/src/main/java/net/fabricmc/loom/LoomGradleExtension.java index 3c50c9761..b21de99a9 100644 --- a/src/main/java/net/fabricmc/loom/LoomGradleExtension.java +++ b/src/main/java/net/fabricmc/loom/LoomGradleExtension.java @@ -46,7 +46,6 @@ import net.fabricmc.loom.configuration.providers.minecraft.mapped.IntermediaryMinecraftProvider; import net.fabricmc.loom.configuration.providers.minecraft.mapped.NamedMinecraftProvider; import net.fabricmc.loom.extension.LoomFiles; -import net.fabricmc.loom.extension.LoomProblemReporter; import net.fabricmc.loom.extension.MixinExtension; import net.fabricmc.loom.extension.RemapperExtensionHolder; import net.fabricmc.loom.util.download.DownloadBuilder; @@ -116,7 +115,5 @@ default List getMinecraftJars(MappingsNamespace mappingsNamespace) { Collection getLayeredMappingFactories(); - LoomProblemReporter getProblemReporter(); - boolean isConfigurationCacheActive(); } diff --git a/src/main/java/net/fabricmc/loom/configuration/DependencyInfo.java b/src/main/java/net/fabricmc/loom/configuration/DependencyInfo.java index bef7b5265..3ded75b14 100644 --- a/src/main/java/net/fabricmc/loom/configuration/DependencyInfo.java +++ b/src/main/java/net/fabricmc/loom/configuration/DependencyInfo.java @@ -37,9 +37,6 @@ import org.gradle.api.artifacts.component.ComponentIdentifier; import org.gradle.api.artifacts.component.ModuleComponentIdentifier; -import net.fabricmc.loom.LoomGradleExtension; -import net.fabricmc.loom.util.gradle.SelfResolvingDependencyUtils; - public class DependencyInfo { final Project project; final Dependency dependency; @@ -66,10 +63,7 @@ public static DependencyInfo create(Project project, Configuration configuration } public static DependencyInfo create(Project project, Dependency dependency, Configuration sourceConfiguration) { - if (SelfResolvingDependencyUtils.isExplicitSRD(dependency)) { - LoomGradleExtension.get(project).getProblemReporter().reportSelfResolvingDependencyUsage(); - return FileDependencyInfo.createForDeprecatedSRD(project, dependency, sourceConfiguration); - } else if (dependency instanceof FileCollectionDependency fileCollectionDependency) { + if (dependency instanceof FileCollectionDependency fileCollectionDependency) { return new FileDependencyInfo(project, fileCollectionDependency, sourceConfiguration); } else { return new DependencyInfo(project, dependency, sourceConfiguration); diff --git a/src/main/java/net/fabricmc/loom/configuration/FileDependencyInfo.java b/src/main/java/net/fabricmc/loom/configuration/FileDependencyInfo.java index 73bbc878d..603b4c636 100644 --- a/src/main/java/net/fabricmc/loom/configuration/FileDependencyInfo.java +++ b/src/main/java/net/fabricmc/loom/configuration/FileDependencyInfo.java @@ -46,7 +46,6 @@ import org.gradle.api.artifacts.FileCollectionDependency; import net.fabricmc.loom.util.ZipUtils; -import net.fabricmc.loom.util.gradle.SelfResolvingDependencyUtils; public class FileDependencyInfo extends DependencyInfo { protected final Map classifierToFile = new HashMap<>(); @@ -131,15 +130,6 @@ private FileDependencyInfo(Project project, Dependency dependency, Configuration } } - @Deprecated // Remove in Gradle 9 - public static FileDependencyInfo createForDeprecatedSRD(Project project, Dependency dependency, Configuration configuration) { - if (!SelfResolvingDependencyUtils.isExplicitSRD(dependency)) { - throw new IllegalArgumentException("Dependency is a FileCollectionDependency"); - } - - return new FileDependencyInfo(project, dependency, configuration, SelfResolvingDependencyUtils.resolve(dependency)); - } - @Override public String getResolvedVersion() { return version; diff --git a/src/main/java/net/fabricmc/loom/configuration/processors/SpecContextImpl.java b/src/main/java/net/fabricmc/loom/configuration/processors/SpecContextImpl.java index 97e96a47e..188263465 100644 --- a/src/main/java/net/fabricmc/loom/configuration/processors/SpecContextImpl.java +++ b/src/main/java/net/fabricmc/loom/configuration/processors/SpecContextImpl.java @@ -166,7 +166,7 @@ private static Stream getLoomProjectDependencies(Configuration configur return configuration.getAllDependencies() .withType(ProjectDependency.class) .stream() - .map(ProjectDependency::getDependencyProject) + .map(GradleUtils::getDependencyProject) .filter(GradleUtils::isLoomProject); } diff --git a/src/main/java/net/fabricmc/loom/configuration/providers/mappings/utils/DependencyFileSpec.java b/src/main/java/net/fabricmc/loom/configuration/providers/mappings/utils/DependencyFileSpec.java index 0eac2fe5e..5cd959c7e 100644 --- a/src/main/java/net/fabricmc/loom/configuration/providers/mappings/utils/DependencyFileSpec.java +++ b/src/main/java/net/fabricmc/loom/configuration/providers/mappings/utils/DependencyFileSpec.java @@ -34,27 +34,11 @@ import net.fabricmc.loom.api.mappings.layered.MappingContext; import net.fabricmc.loom.api.mappings.layered.spec.FileSpec; -import net.fabricmc.loom.configuration.providers.mappings.GradleMappingContext; -import net.fabricmc.loom.util.gradle.SelfResolvingDependencyUtils; public record DependencyFileSpec(Dependency dependency) implements FileSpec { @Override public Path get(MappingContext context) { - if (SelfResolvingDependencyUtils.isExplicitSRD(dependency)) { - if (context instanceof GradleMappingContext gradleMappingContext) { - gradleMappingContext.getExtension().getProblemReporter().reportSelfResolvingDependencyUsage(); - } - - Set files = SelfResolvingDependencyUtils.resolve(dependency); - - if (files.isEmpty()) { - throw new RuntimeException("SelfResolvingDependency (%s) resolved no files".formatted(dependency.toString())); - } else if (files.size() > 1) { - throw new RuntimeException("SelfResolvingDependency (%s) resolved too many files (%d) only 1 is expected".formatted(dependency.toString(), files.size())); - } - - return files.iterator().next().toPath(); - } else if (dependency instanceof FileCollectionDependency fileCollectionDependency) { + if (dependency instanceof FileCollectionDependency fileCollectionDependency) { Set files = fileCollectionDependency.getFiles().getFiles(); if (files.isEmpty()) { diff --git a/src/main/java/net/fabricmc/loom/extension/LoomGradleExtensionImpl.java b/src/main/java/net/fabricmc/loom/extension/LoomGradleExtensionImpl.java index c32c472e9..6e419f99c 100644 --- a/src/main/java/net/fabricmc/loom/extension/LoomGradleExtensionImpl.java +++ b/src/main/java/net/fabricmc/loom/extension/LoomGradleExtensionImpl.java @@ -73,7 +73,6 @@ public abstract class LoomGradleExtensionImpl extends LoomGradleExtensionApiImpl private InstallerData installerData; private boolean refreshDeps; private final ListProperty libraryProcessorFactories; - private final LoomProblemReporter problemReporter; private final boolean configurationCacheActive; private final boolean isolatedProjectsActive; @@ -113,8 +112,6 @@ public LoomGradleExtensionImpl(Project project, LoomFiles files) { if (refreshDeps) { project.getLogger().lifecycle("Refresh dependencies is in use, loom will be significantly slower."); } - - problemReporter = project.getObjects().newInstance(LoomProblemReporter.class); } @Override @@ -288,11 +285,6 @@ protected void configureIntermediateMap provider.getIsLegacyMinecraft().disallowChanges(); } - @Override - public LoomProblemReporter getProblemReporter() { - return problemReporter; - } - @Override public boolean isConfigurationCacheActive() { return configurationCacheActive; diff --git a/src/main/java/net/fabricmc/loom/extension/LoomProblemReporter.java b/src/main/java/net/fabricmc/loom/extension/LoomProblemReporter.java deleted file mode 100644 index 92aa6bc62..000000000 --- a/src/main/java/net/fabricmc/loom/extension/LoomProblemReporter.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file is part of fabric-loom, licensed under the MIT License (MIT). - * - * Copyright (c) 2024 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.extension; - -import javax.inject.Inject; - -import org.gradle.api.problems.ProblemReporter; -import org.gradle.api.problems.Problems; -import org.gradle.api.problems.Severity; - -public abstract class LoomProblemReporter { - private final ProblemReporter problemReporter; - - @Inject - public LoomProblemReporter(Problems problems) { - this.problemReporter = problems.forNamespace("net.fabricmc.loom"); - } - - public void reportSelfResolvingDependencyUsage() { - problemReporter.reporting(spec -> spec - .id("loom-deprecated-selfresolvingdependency", "SelfResolvingDependency is deprecated") - .details("SelfResolvingDependency has been deprecated for removal in Gradle 9") - .solution("Please replace usages of SelfResolvingDependency") - .documentedAt("https://github.com/gradle/gradle/pull/27420") - .severity(Severity.WARNING) - .stackLocation() - ); - } -} diff --git a/src/main/java/net/fabricmc/loom/util/gradle/GradleUtils.java b/src/main/java/net/fabricmc/loom/util/gradle/GradleUtils.java index 1166bc217..e700a870d 100644 --- a/src/main/java/net/fabricmc/loom/util/gradle/GradleUtils.java +++ b/src/main/java/net/fabricmc/loom/util/gradle/GradleUtils.java @@ -25,10 +25,13 @@ package net.fabricmc.loom.util.gradle; import java.io.File; +import java.lang.reflect.Field; import java.util.function.Consumer; import org.gradle.api.Project; +import org.gradle.api.artifacts.ProjectDependency; import org.gradle.api.file.RegularFileProperty; +import org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency; import org.gradle.api.invocation.Gradle; import org.gradle.api.provider.Provider; @@ -88,4 +91,18 @@ public static File configurationInputFile(Project project, File file) { property.set(file); return property.getAsFile().get(); } + + // Get the project from the field with reflection to suppress the deprecation warning. + // If you hate it find a solution yourself and make a PR, I'm getting a bit tired of chasing Gradle updates + public static Project getDependencyProject(ProjectDependency projectDependency) { + try { + final Class clazz = DefaultProjectDependency.class; + final Field dependencyProject = clazz.getDeclaredField("dependencyProject"); + dependencyProject.setAccessible(true); + return (Project) dependencyProject.get(projectDependency); + } catch (NoSuchFieldException | IllegalAccessException ignored) { + // Just fallback and trigger the warning, this will break in Gradle 9 + return projectDependency.getDependencyProject(); + } + } } diff --git a/src/main/java/net/fabricmc/loom/util/gradle/SelfResolvingDependencyUtils.java b/src/main/java/net/fabricmc/loom/util/gradle/SelfResolvingDependencyUtils.java deleted file mode 100644 index cfbddd98b..000000000 --- a/src/main/java/net/fabricmc/loom/util/gradle/SelfResolvingDependencyUtils.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * This file is part of fabric-loom, licensed under the MIT License (MIT). - * - * Copyright (c) 2024 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.util.gradle; - -import java.io.File; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Set; - -import javax.annotation.Nullable; - -import org.gradle.api.artifacts.Dependency; -import org.gradle.api.artifacts.FileCollectionDependency; -import org.gradle.api.artifacts.ProjectDependency; - -// SelfResolvingDependency is deprecated for removal, use reflection to ensure backwards compat. -@Deprecated -public class SelfResolvingDependencyUtils { - // Set this system prop to disable SRD support before Gradle does. - public static final boolean DISABLE_SRD_SUPPORT = System.getProperty("fabric.loom.disable.srd") != null; - - private static final String SELF_RESOLVING_DEPENDENCY_CLASS_NAME = "org.gradle.api.artifacts.SelfResolvingDependency"; - @Nullable - private static final Class SELF_RESOLVING_DEPENDENCY_CLASS = getSelfResolvingDependencyOrNull(); - @Nullable - private static final Method RESOLVE_METHOD = getResolveMethod(SELF_RESOLVING_DEPENDENCY_CLASS); - - /** - * @return true when dependency is a SelfResolvingDependency but NOT a FileCollectionDependency. - */ - public static boolean isExplicitSRD(Dependency dependency) { - // FileCollectionDependency is usually the replacement for SelfResolvingDependency - if (dependency instanceof FileCollectionDependency) { - return false; - } else if (dependency instanceof ProjectDependency) { - return false; - } - - return isSRD(dependency); - } - - private static boolean isSRD(Dependency dependency) { - if (SELF_RESOLVING_DEPENDENCY_CLASS == null) { - return false; - } - - return dependency.getClass().isAssignableFrom(SELF_RESOLVING_DEPENDENCY_CLASS); - } - - public static Set resolve(Dependency dependency) { - if (!isSRD(dependency)) { - throw new IllegalStateException("dependency is not a SelfResolvingDependency"); - } - - try { - return (Set) RESOLVE_METHOD.invoke(dependency); - } catch (IllegalAccessException | InvocationTargetException e) { - throw new RuntimeException("Failed to resolve SelfResolvingDependency", e); - } - } - - @Nullable - private static Class getSelfResolvingDependencyOrNull() { - if (DISABLE_SRD_SUPPORT) { - // Lets pretend SRD doesnt exist. - return null; - } - - try { - return Class.forName(SELF_RESOLVING_DEPENDENCY_CLASS_NAME); - } catch (ClassNotFoundException e) { - // Gradle 9+ - return null; - } - } - - @Nullable - private static Method getResolveMethod(Class clazz) { - if (clazz == null) { - // Gradle 9+ - return null; - } - - try { - var method = clazz.getDeclaredMethod("resolve"); - method.setAccessible(true); - return method; - } catch (NoSuchMethodException e) { - throw new IllegalStateException("Failed to get SelfResolvingDependency.resolve() method", e); - } - } -}