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/build/mixin/AnnotationProcessorInvoker.java b/src/main/java/net/fabricmc/loom/build/mixin/AnnotationProcessorInvoker.java index 3415f7bd..7c10f695 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); }); // Ensure that all of the mixin mappings have been generated before we create the mixin mappings. 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; 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..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 @@ -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. @@ -198,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. @@ -217,6 +220,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 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 4b493875..50c811bd 100644 --- a/src/main/java/net/fabricmc/loom/util/gradle/SourceSetHelper.java +++ b/src/main/java/net/fabricmc/loom/util/gradle/SourceSetHelper.java @@ -28,12 +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.Objects; +import java.util.Set; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathExpressionException; @@ -41,13 +40,10 @@ 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.SourceSetContainer; 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; @@ -97,8 +93,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()); @@ -107,53 +102,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 b08f8b8e..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-20221005221811+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()