mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 21:47:42 -05:00
Merge remote-tracking branch 'FabricMC/future/dev' into dev/future
# Conflicts: # .github/workflows/publish.yml # .github/workflows/test-push.yml # build.gradle # src/main/java/net/fabricmc/loom/util/Constants.java # src/test/groovy/net/fabricmc/loom/test/util/ProjectTestTrait.groovy
This commit is contained in:
@@ -27,9 +27,6 @@ package net.fabricmc.loom.configuration;
|
||||
import org.gradle.api.artifacts.ConfigurationContainer;
|
||||
import org.gradle.api.plugins.JavaPlugin;
|
||||
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.gradle.GradleSupport;
|
||||
|
||||
public class RemappedConfigurationEntry {
|
||||
private final String sourceConfiguration;
|
||||
private final String targetConfiguration;
|
||||
@@ -65,7 +62,7 @@ public class RemappedConfigurationEntry {
|
||||
|
||||
public String getTargetConfiguration(ConfigurationContainer container) {
|
||||
if (container.findByName(targetConfiguration) == null) {
|
||||
return GradleSupport.IS_GRADLE_7_OR_NEWER ? JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME : Constants.Configurations.COMPILE;
|
||||
return JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME;
|
||||
}
|
||||
|
||||
return targetConfiguration;
|
||||
|
||||
@@ -107,7 +107,7 @@ public class RemapJarTask extends Jar {
|
||||
|
||||
public RemapJarTask() {
|
||||
super();
|
||||
input = GradleSupport.getfileProperty(getProject());
|
||||
input = getProject().getObjects().fileProperty();
|
||||
addNestedDependencies = getProject().getObjects().property(Boolean.class);
|
||||
addDefaultNestedDependencies = getProject().getObjects().property(Boolean.class);
|
||||
remapAccessWidener = getProject().getObjects().property(Boolean.class);
|
||||
|
||||
@@ -31,7 +31,6 @@ import org.gradle.api.plugins.JavaPlugin;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import net.fabricmc.loom.configuration.RemappedConfigurationEntry;
|
||||
import net.fabricmc.loom.util.gradle.GradleSupport;
|
||||
|
||||
public class Constants {
|
||||
public static final String PLUGIN_ID = "dev.architectury.loom";
|
||||
@@ -44,23 +43,13 @@ public class Constants {
|
||||
|
||||
public static final int ASM_VERSION = Opcodes.ASM9;
|
||||
|
||||
private static final List<RemappedConfigurationEntry> LEGACY_MOD_COMPILE_ENTRIES = ImmutableList.of(
|
||||
new RemappedConfigurationEntry("modCompile", Configurations.COMPILE, true, "compile"),
|
||||
public static final List<RemappedConfigurationEntry> MOD_COMPILE_ENTRIES = ImmutableList.of(
|
||||
new RemappedConfigurationEntry("modApi", JavaPlugin.API_CONFIGURATION_NAME, true, "compile"),
|
||||
new RemappedConfigurationEntry("modImplementation", JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME, true, "runtime"),
|
||||
new RemappedConfigurationEntry("modRuntime", JavaPlugin.RUNTIME_ONLY_CONFIGURATION_NAME, false, ""),
|
||||
new RemappedConfigurationEntry("modCompileOnly", JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, true, "")
|
||||
);
|
||||
|
||||
private static final List<RemappedConfigurationEntry> MODERN_MOD_COMPILE_ENTRIES = ImmutableList.of(
|
||||
new RemappedConfigurationEntry("modApi", JavaPlugin.API_CONFIGURATION_NAME, true, "compile"),
|
||||
new RemappedConfigurationEntry("modImplementation", JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME, true, "runtime"),
|
||||
new RemappedConfigurationEntry("modRuntime", JavaPlugin.RUNTIME_ONLY_CONFIGURATION_NAME, false, ""),
|
||||
new RemappedConfigurationEntry("modCompileOnly", JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, true, "")
|
||||
);
|
||||
|
||||
public static final List<RemappedConfigurationEntry> MOD_COMPILE_ENTRIES = GradleSupport.IS_GRADLE_7_OR_NEWER ? MODERN_MOD_COMPILE_ENTRIES : LEGACY_MOD_COMPILE_ENTRIES;
|
||||
|
||||
private Constants() {
|
||||
}
|
||||
|
||||
@@ -86,8 +75,6 @@ public class Constants {
|
||||
public static final String FORGE_INSTALLER = "forgeInstaller";
|
||||
public static final String FORGE_UNIVERSAL = "forgeUniversal";
|
||||
public static final String FORGE_DEPENDENCIES = "forgeDependencies";
|
||||
@Deprecated // Not to be used in gradle 7+
|
||||
public static final String COMPILE = "compile";
|
||||
public static final String MAPPING_CONSTANTS = "mappingsConstants";
|
||||
public static final String UNPICK_CLASSPATH = "unpick";
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ import java.util.stream.Stream;
|
||||
import groovy.util.Node;
|
||||
import groovy.xml.QName;
|
||||
|
||||
import net.fabricmc.loom.util.gradle.GradleSupport;
|
||||
|
||||
public final class GroovyXmlUtil {
|
||||
private GroovyXmlUtil() { }
|
||||
|
||||
@@ -66,18 +64,13 @@ public final class GroovyXmlUtil {
|
||||
}
|
||||
|
||||
// New groovy 3 (gradle 7) class
|
||||
if (GradleSupport.IS_GRADLE_7_OR_NEWER && nodeName.getClass().getName().equals("groovy.namespace.QName")) {
|
||||
return isSameNameGroovy3(nodeName, givenName);
|
||||
if (nodeName instanceof groovy.namespace.QName) {
|
||||
return ((groovy.namespace.QName) nodeName).matches(givenName);
|
||||
}
|
||||
|
||||
throw new UnsupportedOperationException("Cannot determine if " + nodeName.getClass() + " is the same as a String");
|
||||
}
|
||||
|
||||
// TODO Move out of its own method when requiring gradle 7
|
||||
private static boolean isSameNameGroovy3(Object nodeName, String givenName) {
|
||||
return ((groovy.namespace.QName) nodeName).matches(givenName);
|
||||
}
|
||||
|
||||
public static Stream<Node> childrenNodesStream(Node node) {
|
||||
//noinspection unchecked
|
||||
return (Stream<Node>) (Stream) (((List<Object>) node.children()).stream().filter((i) -> i instanceof Node));
|
||||
|
||||
@@ -24,45 +24,12 @@
|
||||
|
||||
package net.fabricmc.loom.util.gradle;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.file.RegularFileProperty;
|
||||
import org.gradle.util.GradleVersion;
|
||||
|
||||
// This is used to bridge the gap over large gradle api changes.
|
||||
public class GradleSupport {
|
||||
public static final boolean IS_GRADLE_7_OR_NEWER = isIsGradle7OrNewer();
|
||||
|
||||
public static RegularFileProperty getfileProperty(Project project) {
|
||||
try {
|
||||
// First try the new method, if that fails fall back.
|
||||
return getfilePropertyModern(project);
|
||||
} catch (Exception e) {
|
||||
// Nope
|
||||
}
|
||||
|
||||
try {
|
||||
return getfilePropertyLegacy(project);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to find file property", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static RegularFileProperty getfilePropertyModern(Project project) throws Exception {
|
||||
return getfilePropertyLegacyFromObject(project.getObjects());
|
||||
}
|
||||
|
||||
private static RegularFileProperty getfilePropertyLegacy(Project project) throws Exception {
|
||||
return getfilePropertyLegacyFromObject(project.getLayout());
|
||||
}
|
||||
|
||||
private static RegularFileProperty getfilePropertyLegacyFromObject(Object object) throws Exception {
|
||||
Method method = object.getClass().getDeclaredMethod("fileProperty");
|
||||
method.setAccessible(true);
|
||||
return (RegularFileProperty) method.invoke(object);
|
||||
}
|
||||
|
||||
public static boolean isIsGradle7OrNewer() {
|
||||
String version = GradleVersion.current().getVersion();
|
||||
return Integer.parseInt(version.substring(0, version.indexOf("."))) >= 7;
|
||||
|
||||
Reference in New Issue
Block a user