From 5ae24af98bc1af2f67133e5a266e07d40c3c0332 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sat, 24 Sep 2022 21:02:49 +0100 Subject: [PATCH 1/4] Fix incorrect Mixin message argument key. --- .../fabricmc/loom/build/mixin/AnnotationProcessorInvoker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/fabricmc/loom/build/mixin/AnnotationProcessorInvoker.java b/src/main/java/net/fabricmc/loom/build/mixin/AnnotationProcessorInvoker.java index 0a79dab8..759e118c 100644 --- a/src/main/java/net/fabricmc/loom/build/mixin/AnnotationProcessorInvoker.java +++ b/src/main/java/net/fabricmc/loom/build/mixin/AnnotationProcessorInvoker.java @@ -108,7 +108,7 @@ public abstract class AnnotationProcessorInvoker { checkPattern(key, MSG_KEY_PATTERN); checkPattern(value, MSG_VALUE_PATTERN); - args.put("AMSG_" + key, value); + args.put("MSG_" + key, value); }); project.getLogger().debug("Outputting refmap to dir: " + getRefmapDestinationDir(task) + " for compile task: " + task); From 559ead49e12241a4c32a104289c1c73bddcf8607 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sat, 1 Oct 2022 09:55:03 +0100 Subject: [PATCH 2/4] Search for injected interfaces in the client sourceset by default. (#731) --- .../configuration/providers/minecraft/MinecraftSourceSets.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftSourceSets.java b/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftSourceSets.java index 7d058ea6..39df1463 100644 --- a/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftSourceSets.java +++ b/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftSourceSets.java @@ -157,6 +157,7 @@ public abstract sealed class MinecraftSourceSets permits MinecraftSourceSets.Sin // Called during evaluation, when the loom extension method is called. private void evaluate(Project project) { + final LoomGradleExtension extension = LoomGradleExtension.get(project); createSourceSets(project); // Combined extends from the 2 environments. @@ -217,6 +218,8 @@ public abstract sealed class MinecraftSourceSets permits MinecraftSourceSets.Sin // The client only sources to the combined sources jar. jar.from(clientOnlySourceSet.getAllSource()); }); + + extension.getInterfaceInjection().getInterfaceInjectionSourceSets().add(clientOnlySourceSet); } @Override From f221101477789d8064cc3478796596cd783d9872 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sat, 1 Oct 2022 16:20:08 +0100 Subject: [PATCH 3/4] Inherit environment variables. Fixes #730 (#733) --- .../net/fabricmc/loom/configuration/ide/RunConfigSettings.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/net/fabricmc/loom/configuration/ide/RunConfigSettings.java b/src/main/java/net/fabricmc/loom/configuration/ide/RunConfigSettings.java index f369794e..babeca89 100644 --- a/src/main/java/net/fabricmc/loom/configuration/ide/RunConfigSettings.java +++ b/src/main/java/net/fabricmc/loom/configuration/ide/RunConfigSettings.java @@ -293,6 +293,7 @@ public final class RunConfigSettings implements Named { public void inherit(RunConfigSettings parent) { vmArgs.addAll(0, parent.vmArgs); programArgs.addAll(0, parent.programArgs); + environmentVariables.putAll(parent.environmentVariables); environment = parent.environment; name = parent.name; From 57b5f05c57307fc1b7accfcd7c3d258bee5320b9 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sun, 2 Oct 2022 16:28:55 +0100 Subject: [PATCH 4/4] Fix support for latest Gradle 8.0 nightly. (#732) * Fix support for Gradle 8.0. * Cleanup * Fix another gradle 8 issue? --- build.gradle | 7 ++- .../minecraft/MinecraftSourceSets.java | 2 + .../loom/util/gradle/SourceSetHelper.java | 60 +++---------------- .../loom/test/LoomTestConstants.groovy | 2 +- 4 files changed, 15 insertions(+), 56 deletions(-) diff --git a/build.gradle b/build.gradle index 7e9be933..9c18bf1f 100644 --- a/build.gradle +++ b/build.gradle @@ -200,8 +200,11 @@ test { systemProperty "fabric.loom.test.homeDir", System.getProperty("fabric.loom.test.homeDir") } - retry { - maxRetries = 3 + + if (ENV.CI) { + retry { + maxRetries = 3 + } } } diff --git a/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftSourceSets.java b/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftSourceSets.java index 39df1463..c1ba3920 100644 --- a/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftSourceSets.java +++ b/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftSourceSets.java @@ -199,6 +199,8 @@ public abstract sealed class MinecraftSourceSets permits MinecraftSourceSets.Sin project.getTasks().named(mainSourceSet.getJarTaskName(), Jar.class).configure(jar -> { jar.from(clientOnlySourceSet.getOutput().getClassesDirs()); jar.from(clientOnlySourceSet.getOutput().getResourcesDir()); + + jar.dependsOn(project.getTasks().named(clientOnlySourceSet.getProcessResourcesTaskName())); }); // Remap with the client compile classpath. diff --git a/src/main/java/net/fabricmc/loom/util/gradle/SourceSetHelper.java b/src/main/java/net/fabricmc/loom/util/gradle/SourceSetHelper.java index aec6bc63..156437dd 100644 --- a/src/main/java/net/fabricmc/loom/util/gradle/SourceSetHelper.java +++ b/src/main/java/net/fabricmc/loom/util/gradle/SourceSetHelper.java @@ -28,11 +28,11 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.UncheckedIOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; +import java.util.Iterator; import java.util.List; +import java.util.Set; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathExpressionException; @@ -40,12 +40,9 @@ import javax.xml.xpath.XPathFactory; import org.gradle.api.Project; import org.gradle.api.Task; -import org.gradle.api.internal.tasks.DefaultSourceSetOutput; -import org.gradle.api.internal.tasks.DefaultTaskDependency; import org.gradle.api.plugins.JavaPluginExtension; import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSetOutput; -import org.gradle.api.tasks.TaskProvider; import org.intellij.lang.annotations.Language; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.VisibleForTesting; @@ -93,8 +90,7 @@ public final class SourceSetHelper { *

A bit of a hack, would be nice for this to be added to the Gradle API. */ public static Project getSourceSetProject(SourceSet sourceSet) { - final DefaultSourceSetOutput sourceSetOutput = (DefaultSourceSetOutput) sourceSet.getOutput(); - final Project project = getProjectFromSourceSetOutput(sourceSetOutput); + final Project project = getProjectFromSourceSetOutput(sourceSet.getOutput()); if (project == null) { throw new NullPointerException("Unable to determine owning project for SourceSet: " + sourceSet.getName()); @@ -103,53 +99,11 @@ public final class SourceSetHelper { return project; } + @Nullable private static Project getProjectFromSourceSetOutput(SourceSetOutput sourceSetOutput) { - final Class clazz = DefaultSourceSetOutput.class; - - try { - final Method getClassesContributorsMethod = clazz.getMethod("getClassesContributors"); - final Object classesContributors = getClassesContributorsMethod.invoke(sourceSetOutput); - - if (classesContributors instanceof List list) { - // Gradle 7.7 - return getProjectFromDirectoryContributions(list); - } else if (classesContributors instanceof DefaultTaskDependency taskDependency) { - // Pre Gradle 7.7 - return getProjectFromTaskDependency(taskDependency); - } else { - throw new UnsupportedOperationException(); - } - } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - - // Pre Gradle 7.7 - private static Project getProjectFromTaskDependency(DefaultTaskDependency taskDependency) { - for (Object object : taskDependency.getMutableValues()) { - if (object instanceof Task task) { - return task.getProject(); - } else if (object instanceof TaskProvider provider) { - return provider.get().getProject(); - } - } - - return null; - } - - // Gradle 7.7: https://github.com/gradle/gradle/commit/2797942dc71f0e0e186b7d0c5ba3e09eceea4507#diff-b19ce8fbc4aa4ebaeea74e39609636d65e385bce6990fd42d68581dd829f29b3L153 - private static Project getProjectFromDirectoryContributions(List classesContributions) { - for (Object classesContribution : classesContributions) { - try { - final Method getTask = classesContribution.getClass().getMethod("getTask"); - final TaskProvider taskProvider = (TaskProvider) getTask.invoke(classesContribution); - return taskProvider.get().getProject(); - } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - - return null; + Set dependencies = sourceSetOutput.getBuildDependencies().getDependencies(null); + Iterator it = dependencies.iterator(); + return it.hasNext() ? it.next().getProject() : null; } public static List getClasspath(ModSettings modSettings, Project project) { diff --git a/src/test/groovy/net/fabricmc/loom/test/LoomTestConstants.groovy b/src/test/groovy/net/fabricmc/loom/test/LoomTestConstants.groovy index 448effa9..8f43a6d9 100644 --- a/src/test/groovy/net/fabricmc/loom/test/LoomTestConstants.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/LoomTestConstants.groovy @@ -27,7 +27,7 @@ package net.fabricmc.loom.test import org.gradle.util.GradleVersion class LoomTestConstants { - private final static String NIGHTLY_VERSION = "8.0-20220911113203+0000" + private final static String NIGHTLY_VERSION = "8.0-20221001011953+0000" private final static boolean NIGHTLY_EXISTS = nightlyExists(NIGHTLY_VERSION) public final static String DEFAULT_GRADLE = GradleVersion.current().getVersion()