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:
shedaniel
2021-05-05 02:20:20 +08:00
17 changed files with 38 additions and 95 deletions

View File

@@ -13,10 +13,10 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Set up JDK 1.8
- name: Set up JDK 16
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 16
- name: Upload to Maven
run: ./gradlew publish --stacktrace
env:

View File

@@ -17,6 +17,15 @@ plugins {
sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = 8
}
}
group = "dev.architectury"
archivesBaseName = project.name
def baseVersion = '0.7.1'
@@ -54,9 +63,6 @@ repositories {
dependencies {
implementation gradleApi()
// Compile against groovy 3 to aid with gradle 7 support. Remove when updating to gradle 7
compileOnly 'org.codehaus.groovy:groovy:3.0.7'
// libraries
implementation ('commons-io:commons-io:2.8.0')
implementation ('org.zeroturnaround:zt-zip:1.14')
@@ -95,7 +101,7 @@ dependencies {
implementation ('org.cadixdev:mercury:0.2.9-architectury')
// Kapt integration
compileOnly('org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21')
compileOnly('org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32')
// Forge patches
implementation ('net.minecraftforge:binarypatcher:1.1.1')
@@ -115,7 +121,7 @@ dependencies {
// Testing
testImplementation(gradleTestKit())
testImplementation('org.spockframework:spock-core:1.3-groovy-2.4') {
testImplementation('org.spockframework:spock-core:2.0-M5-groovy-3.0') {
exclude module: 'groovy-all'
}
testImplementation 'io.javalin:javalin:3.13.4'
@@ -149,12 +155,12 @@ task mainJar(type: Jar, dependsOn: jar) {
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
@@ -170,7 +176,7 @@ license {
checkstyle {
configFile = file('checkstyle.xml')
toolVersion = '8.39'
toolVersion = '8.41.1'
}
codenarc {
@@ -205,6 +211,7 @@ jacocoTestReport {
test {
maxHeapSize = "4096m"
useJUnitPlatform()
}
import org.w3c.dom.Document

Binary file not shown.

View File

@@ -1,6 +1,5 @@
#Mon Jun 24 11:09:08 BST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-rc-2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip

2
gradlew vendored
View File

@@ -28,7 +28,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

2
gradlew.bat vendored
View File

@@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m"
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

View File

@@ -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;

View File

@@ -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);

View File

@@ -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";

View File

@@ -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));

View File

@@ -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;

View File

@@ -47,7 +47,6 @@ class DecompileTest extends Specification implements ProjectTestTrait {
where:
decompiler | task | gradle
'fernflower' | "genSources" | DEFAULT_GRADLE
'fernflower' | "genSources" | LEGACY_GRADLE
'fernflower' | "genSources" | PRE_RELEASE_GRADLE
'cfr' | "genSourcesWithExperimentalCfr" | DEFAULT_GRADLE
}

View File

@@ -25,11 +25,13 @@
package net.fabricmc.loom.test.integration
import net.fabricmc.loom.test.util.ProjectTestTrait
import spock.lang.IgnoreIf
import spock.lang.Specification
import spock.lang.Unroll
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS
@IgnoreIf({ jvm.java16Compatible }) // Fails on J16 > due to https://youtrack.jetbrains.com/issue/KT-45566
class KotlinTest extends Specification implements ProjectTestTrait {
@Override
String name() {

View File

@@ -40,7 +40,7 @@ class LegacyProjectTest extends Specification implements ProjectTestTrait {
@Unroll
def "build"() {
when:
def result = create("build", LEGACY_GRADLE)
def result = create("build", DEFAULT_GRADLE)
then:
result.task(":build").outcome == SUCCESS
}

View File

@@ -48,9 +48,9 @@ class ReproducibleBuildTest extends Specification implements ProjectTestTrait {
getOutputHash("fabric-example-mod-1.0.0.jar") == modHash
getOutputHash("fabric-example-mod-1.0.0-sources.jar") in sourceHash // Done for different line endings.
where:
gradle | modHash | sourceHash
'6.8.3' | "6132ffb4117adb7e258f663110552952" | ["be31766e6cafbe4ae3bca9e35ba63169", "7348b0bd87d36d7ec6f3bca9c2b66062"]
'7.0-rc-1' | "6132ffb4117adb7e258f663110552952" | ["be31766e6cafbe4ae3bca9e35ba63169", "7348b0bd87d36d7ec6f3bca9c2b66062"]
gradle | modHash | sourceHash
DEFAULT_GRADLE | "6132ffb4117adb7e258f663110552952" | ["be31766e6cafbe4ae3bca9e35ba63169", "7348b0bd87d36d7ec6f3bca9c2b66062"]
PRE_RELEASE_GRADLE | "6132ffb4117adb7e258f663110552952" | ["be31766e6cafbe4ae3bca9e35ba63169", "7348b0bd87d36d7ec6f3bca9c2b66062"]
}
String getOutputHash(String name) {

View File

@@ -28,8 +28,7 @@ import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.GradleRunner
trait ProjectTestTrait {
final static String LEGACY_GRADLE = "4.9"
final static String DEFAULT_GRADLE = "6.8.3"
final static String DEFAULT_GRADLE = "7.0-rc-2"
final static String PRE_RELEASE_GRADLE = "7.0"
static File gradleHome = File.createTempDir()
@@ -95,10 +94,6 @@ trait ProjectTestTrait {
}
String warningMode(String gradleVersion) {
if (gradleVersion == LEGACY_GRADLE) {
return "all"
}
'fail'
}

View File

@@ -19,23 +19,20 @@ dependencies {
processResources {
inputs.property "version", project.version
from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
filesMatching("fabric.mod.json") {
expand "version": project.version
}
from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
}
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}
jar {