From 87b36f6707cc763d90e9029064a268062f3358a8 Mon Sep 17 00:00:00 2001 From: zml Date: Mon, 30 Aug 2021 22:49:25 -0700 Subject: [PATCH 1/4] Adjust modularity build configuration to avoid duplicate sources This allows the shadow task to apply its own merging logic for resources that are validly duplicated, in this case service files The checkstyle exclusion for module-info is moved from the buildscript to checkstyle.xml, for application within IDEs, not just Gradle. A small fix to PrettyPrinter is included as well, based on a line incorrectly converted from log4j2. --- build.gradle | 46 +++++++++++-------- checkstyle.xml | 3 ++ .../spongepowered/asm/util/PrettyPrinter.java | 2 +- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/build.gradle b/build.gradle index 042851f9..2a36f6be 100644 --- a/build.gradle +++ b/build.gradle @@ -44,6 +44,7 @@ ext.legacyForgeAsmVersion = project.hasProperty("legacyForgeAsmVersion") ? asmVe ext.doSignJar = project.hasProperty("keyStorePath") java { + modularity.inferModulePath = false toolchain.languageVersion = JavaLanguageVersion.of(ciSystem == 'unknown' ? 16 : 8) } @@ -97,6 +98,7 @@ sourceSets { compileClasspath += main.output ext.languageVersion = 8 ext.compatibility = '1.6' + ext.modularityExcluded = true } agent { compileClasspath += main.output @@ -107,10 +109,15 @@ sourceSets { compileClasspath += main.output ext.languageVersion = 8 ext.compatibility = '1.8' + ext.modularityExcluded = true } example { compileClasspath += main.output compileClasspath += ap.output + ext.modularityExcluded = true + } + test { + ext.modularityExcluded = true } launchwrapper { compileClasspath += main.output @@ -135,14 +142,7 @@ sourceSets { } modularity { ext.languageVersion = 16 - java.srcDirs += [ - sourceSets.legacy.java.srcDirs, - sourceSets.main.java.srcDirs, - sourceSets.ap.java.srcDirs, - sourceSets.agent.java.srcDirs, - sourceSets.modlauncher.java.srcDirs, - sourceSets.modlauncher9.java.srcDirs - ] + ext.modularityExcluded = true // don't add ourselves } } @@ -205,14 +205,6 @@ dependencies { modularityCompileOnly 'org.apache.logging.log4j:log4j-core:2.11.2' } -compileModularityJava { - doFirst { - options.compilerArgs = [ - '--module-path', classpath.asPath - ] - } -} - javadoc { exclude '**/throwables' classpath += sourceSets.legacy.output @@ -285,7 +277,6 @@ checkstyle { ] configFile = file("checkstyle.xml") toolVersion = '8.43' - sourceSets -= project.sourceSets['modularity'] } // Source compiler configuration @@ -295,6 +286,8 @@ tasks.withType(JavaCompile) { options.encoding = 'utf8' } +def modularityInputs = objects.fileCollection() + project.sourceSets.each { set -> { if (set.ext.has("languageVersion")) { project.tasks[set.compileJavaTaskName].javaCompiler = javaToolchains.compilerFor { @@ -305,8 +298,25 @@ project.sourceSets.each { set -> { project.tasks[set.compileJavaTaskName].sourceCompatibility = set.ext.compatibility project.tasks[set.compileJavaTaskName].targetCompatibility = set.ext.compatibility } + def modularityExcluded = set.ext.has("modularityExcluded") && set.ext.modularityExcluded + if (!modularityExcluded) { + project.sourceSets.modularity { + compileClasspath += set.output + } + modularityInputs.from set.output + } }} +compileModularityJava { + inputs.files(modularityInputs) + doFirst { + options.compilerArgs = [ + '--module-path', classpath.asPath, + '--patch-module', "org.spongepowered.mixin=${modularityInputs.collect { it.absolutePath }.join(File.pathSeparator)}" + ] + } +} + if (JavaVersion.current().isJava8Compatible()) { tasks.withType(Javadoc) { // disable the crazy super-strict doclint tool in Java 8 @@ -318,8 +328,6 @@ task stagingJar(type: ShadowJar) { sourceSets.findAll { !(it.name =~ /example|test/) }.each { from it.output } - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - configurations = [project.configurations.stagingJar] // JAR manifest configuration diff --git a/checkstyle.xml b/checkstyle.xml index 62145c03..1109c4ac 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -11,6 +11,9 @@ + + + diff --git a/src/main/java/org/spongepowered/asm/util/PrettyPrinter.java b/src/main/java/org/spongepowered/asm/util/PrettyPrinter.java index db52660b..14592d23 100644 --- a/src/main/java/org/spongepowered/asm/util/PrettyPrinter.java +++ b/src/main/java/org/spongepowered/asm/util/PrettyPrinter.java @@ -1147,7 +1147,7 @@ public class PrettyPrinter { private void logString(ILogger logger, Level level, String line) { if (line != null) { - logger.log(level, "/* {} */", String.format("%-" + this.width, line)); + logger.log(level, "/* {} */", String.format("%-" + this.width + "s", line)); } } From e10ac704e1ad40ecd539b05b711cf2de582b6e03 Mon Sep 17 00:00:00 2001 From: Mumfrey Date: Mon, 6 Sep 2021 18:27:02 +0100 Subject: [PATCH 2/4] Numbers are hard, typing version numbers doubly so... apparently. --- src/main/java/org/spongepowered/asm/mixin/MixinEnvironment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/spongepowered/asm/mixin/MixinEnvironment.java b/src/main/java/org/spongepowered/asm/mixin/MixinEnvironment.java index 2dc938ce..0eb13c9c 100644 --- a/src/main/java/org/spongepowered/asm/mixin/MixinEnvironment.java +++ b/src/main/java/org/spongepowered/asm/mixin/MixinEnvironment.java @@ -626,7 +626,7 @@ public final class MixinEnvironment implements ITokenProvider { @Override boolean isSupported() { - return JavaVersion.current() >= JavaVersion.JAVA_8 && ASM.isAtLeastVersion(6); + return JavaVersion.current() >= JavaVersion.JAVA_9 && ASM.isAtLeastVersion(6); } }, From c9586f548e82f069f5b77f5086aa36eb6c5e01e1 Mon Sep 17 00:00:00 2001 From: Mumfrey Date: Mon, 6 Sep 2021 18:27:28 +0100 Subject: [PATCH 3/4] Use static module requires because JPMS is just awful --- src/modularity/java/module-info.java | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/modularity/java/module-info.java b/src/modularity/java/module-info.java index b638dd2a..72755f95 100644 --- a/src/modularity/java/module-info.java +++ b/src/modularity/java/module-info.java @@ -26,18 +26,14 @@ /** * Mixin module declaration */ -@SuppressWarnings("module") // Suppress the warnings about gson and gson below +@SuppressWarnings("module") // Suppress the warnings about gson and gson below. Damn gsons, you ruined gson! module org.spongepowered.mixin { // // Actual modules we depend on // - requires transitive cpw.mods.modlauncher; - requires cpw.mods.securejarhandler; requires transitive java.compiler; requires transitive java.instrument; - requires transitive org.apache.logging.log4j; - requires org.apache.logging.log4j.core; requires transitive org.objectweb.asm; requires transitive org.objectweb.asm.commons; requires transitive org.objectweb.asm.tree; @@ -46,11 +42,19 @@ module org.spongepowered.mixin { requires java.logging; // - // Automatic modules we depend on + // Modules we require for compilation but don't necessarily need at runtime // - requires jopt.simple; - requires guava; - requires gson; + requires static org.apache.logging.log4j.core; + requires static transitive cpw.mods.modlauncher; + requires static cpw.mods.securejarhandler; + requires static transitive org.apache.logging.log4j; + + // + // Automatic modules we depend on, using static to avoid the forward compatibility mess + // + requires static jopt.simple; + requires static guava; + requires static gson; // // Exports From 2accda5000f7602229606b39437565542cc6fba4 Mon Sep 17 00:00:00 2001 From: Mumfrey Date: Tue, 7 Sep 2021 18:49:11 +0100 Subject: [PATCH 4/4] Mixin 0.8.4 RELEASE --- gradle.properties | 2 +- .../tools/obfuscation/fg3/ObfuscationServiceFG3.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 5ddd8c4c..0f92b25d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ description=Mixin url=https://www.spongepowered.org organization=SpongePowered buildVersion=0.8.4 -buildType=SNAPSHOT +buildType=RELEASE asmVersion=9.2 legacyForgeAsmVersion=5.0.3 modlauncherAsmVersion=9.1 diff --git a/src/ap/java/org/spongepowered/tools/obfuscation/fg3/ObfuscationServiceFG3.java b/src/ap/java/org/spongepowered/tools/obfuscation/fg3/ObfuscationServiceFG3.java index 87f5e526..c645e551 100644 --- a/src/ap/java/org/spongepowered/tools/obfuscation/fg3/ObfuscationServiceFG3.java +++ b/src/ap/java/org/spongepowered/tools/obfuscation/fg3/ObfuscationServiceFG3.java @@ -52,6 +52,7 @@ public class ObfuscationServiceFG3 implements IObfuscationService { public Set getSupportedOptions() { return ImmutableSet.of( ObfuscationServiceFG3.REOBF_TSRG_FILE, + ObfuscationServiceFG3.REOBF_EXTRA_TSRG_FILES, ObfuscationServiceFG3.OUT_TSRG_SRG_FILE, ObfuscationServiceFG3.TSRG_OUTPUT_BEHAVIOUR );