mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-03-30 13:05:27 -05:00
Merge remote-tracking branch 'origin/dev/1.0' into fmj_2
# Conflicts: # src/main/java/net/fabricmc/loom/util/gradle/SourceSetHelper.java # src/test/groovy/net/fabricmc/loom/test/LoomTestConstants.groovy
This commit is contained in:
@@ -108,7 +108,7 @@ public abstract class AnnotationProcessorInvoker<T extends Task> {
|
||||
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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
* <p>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<? extends DefaultSourceSetOutput> 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<? /*DirectoryContribution*/> 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<? extends Task> dependencies = sourceSetOutput.getBuildDependencies().getDependencies(null);
|
||||
Iterator<? extends Task> it = dependencies.iterator();
|
||||
return it.hasNext() ? it.next().getProject() : null;
|
||||
}
|
||||
|
||||
public static List<File> getClasspath(ModSettings modSettings, Project project) {
|
||||
|
||||
Reference in New Issue
Block a user