diff options
author | shedaniel <daniel@shedaniel.me> | 2021-08-31 18:24:42 +0800 |
---|---|---|
committer | shedaniel <daniel@shedaniel.me> | 2021-08-31 18:24:42 +0800 |
commit | aaacd23c8bdd2c52c727ab7119afd8dd968f762a (patch) | |
tree | 8cfad403ff32150495a77abd122fde59c6b3296c /src/main/java/net/fabricmc/loom/util/srg | |
parent | 9366d42baa22b53b16ad8b21b843576ec8c964c7 (diff) | |
download | architectury-loom-aaacd23c8bdd2c52c727ab7119afd8dd968f762a.tar.gz architectury-loom-aaacd23c8bdd2c52c727ab7119afd8dd968f762a.tar.bz2 architectury-loom-aaacd23c8bdd2c52c727ab7119afd8dd968f762a.zip |
Make it work
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'src/main/java/net/fabricmc/loom/util/srg')
-rw-r--r-- | src/main/java/net/fabricmc/loom/util/srg/SpecialSourceExecutor.java | 93 |
1 files changed, 68 insertions, 25 deletions
diff --git a/src/main/java/net/fabricmc/loom/util/srg/SpecialSourceExecutor.java b/src/main/java/net/fabricmc/loom/util/srg/SpecialSourceExecutor.java index 327825d3..b3a0e4c3 100644 --- a/src/main/java/net/fabricmc/loom/util/srg/SpecialSourceExecutor.java +++ b/src/main/java/net/fabricmc/loom/util/srg/SpecialSourceExecutor.java @@ -24,11 +24,14 @@ package net.fabricmc.loom.util.srg; +import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.Set; import java.util.jar.JarOutputStream; import java.util.stream.Collectors; @@ -45,9 +48,9 @@ import org.zeroturnaround.zip.ZipUtil; import net.fabricmc.loom.LoomGradleExtension; public class SpecialSourceExecutor { - public static Path produceSrgJar(Project project, String side, FileCollection specialSourceCp, Path officialJar, Path srgPath) + public static Path produceSrgJar(boolean specialSource, Project project, String side, FileCollection classpath, Set<File> mcLibs, Path officialJar, Path mappings) throws Exception { - Set<String> filter = Files.readAllLines(srgPath, StandardCharsets.UTF_8).stream() + Set<String> filter = Files.readAllLines(mappings, StandardCharsets.UTF_8).stream() .filter(s -> !s.startsWith("\t")) .map(s -> s.split(" ")[0] + ".class") .collect(Collectors.toSet()); @@ -68,35 +71,75 @@ public class SpecialSourceExecutor { Path output = extension.getFiles().getProjectBuildCache().toPath().resolve(officialJar.getFileName().toString().substring(0, officialJar.getFileName().toString().length() - 4) + "-srg-output.jar"); Files.deleteIfExists(output); - String[] args = new String[] { - "--in-jar", - stripped.toAbsolutePath().toString(), - "--out-jar", - output.toAbsolutePath().toString(), - "--srg-in", - srgPath.toAbsolutePath().toString() - }; + if (specialSource) { + String[] args = new String[] { + "--in-jar", + stripped.toAbsolutePath().toString(), + "--out-jar", + output.toAbsolutePath().toString(), + "--srg-in", + mappings.toAbsolutePath().toString() + }; - project.getLogger().lifecycle(":remapping minecraft (SpecialSource, " + side + ", official -> srg)"); + project.getLogger().lifecycle(":remapping minecraft (SpecialSource, " + side + ", official -> srg)"); - Path workingDir = tmpDir(); + Path workingDir = tmpDir(); - project.javaexec(spec -> { - spec.setArgs(Arrays.asList(args)); - spec.setClasspath(specialSourceCp); - spec.workingDir(workingDir.toFile()); - spec.setMain("net.md_5.specialsource.SpecialSource"); + project.javaexec(spec -> { + spec.setArgs(Arrays.asList(args)); + spec.setClasspath(classpath); + spec.workingDir(workingDir.toFile()); + spec.setMain("net.md_5.specialsource.SpecialSource"); - // if running with INFO or DEBUG logging - if (project.getGradle().getStartParameter().getShowStacktrace() != ShowStacktrace.INTERNAL_EXCEPTIONS + // if running with INFO or DEBUG logging + if (project.getGradle().getStartParameter().getShowStacktrace() != ShowStacktrace.INTERNAL_EXCEPTIONS || project.getGradle().getStartParameter().getLogLevel().compareTo(LogLevel.LIFECYCLE) < 0) { - spec.setStandardOutput(System.out); - spec.setErrorOutput(System.err); - } else { - spec.setStandardOutput(NullOutputStream.NULL_OUTPUT_STREAM); - spec.setErrorOutput(NullOutputStream.NULL_OUTPUT_STREAM); + spec.setStandardOutput(System.out); + spec.setErrorOutput(System.err); + } else { + spec.setStandardOutput(NullOutputStream.NULL_OUTPUT_STREAM); + spec.setErrorOutput(NullOutputStream.NULL_OUTPUT_STREAM); + } + }).rethrowFailure().assertNormalExitValue(); + } else { + List<String> args = new ArrayList<>(Arrays.asList( + "--jar-in", + stripped.toAbsolutePath().toString(), + "--jar-out", + output.toAbsolutePath().toString(), + "--mapping-format", + "tsrg2", + "--mappings", + mappings.toAbsolutePath().toString(), + "--create-inits", + "--fix-param-annotations" + )); + + for (File file : mcLibs) { + args.add("-e=" + file.getAbsolutePath()); } - }).rethrowFailure().assertNormalExitValue(); + + project.getLogger().lifecycle(":remapping minecraft (Vignette, " + side + ", official -> mojang)"); + + Path workingDir = tmpDir(); + + project.javaexec(spec -> { + spec.setArgs(args); + spec.setClasspath(classpath); + spec.workingDir(workingDir.toFile()); + spec.setMain("org.cadixdev.vignette.VignetteMain"); + + // if running with INFO or DEBUG logging + if (project.getGradle().getStartParameter().getShowStacktrace() != ShowStacktrace.INTERNAL_EXCEPTIONS + || project.getGradle().getStartParameter().getLogLevel().compareTo(LogLevel.LIFECYCLE) < 0) { + spec.setStandardOutput(System.out); + spec.setErrorOutput(System.err); + } else { + spec.setStandardOutput(NullOutputStream.NULL_OUTPUT_STREAM); + spec.setErrorOutput(NullOutputStream.NULL_OUTPUT_STREAM); + } + }).rethrowFailure().assertNormalExitValue(); + } Files.deleteIfExists(stripped); |