mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 05:27:43 -05:00
Merge remote-tracking branch 'FabricMC/dev/0.10' into dev/0.10.0
# Conflicts: # src/main/java/net/fabricmc/loom/api/LoomGradleExtensionAPI.java # src/main/java/net/fabricmc/loom/extension/MinecraftGradleExtension.java
This commit is contained in:
@@ -106,8 +106,7 @@ public interface LoomGradleExtension extends LoomGradleExtensionAPI {
|
||||
}
|
||||
|
||||
default String getIntermediaryUrl(String minecraftVersion) {
|
||||
// TODO reimplement a way to change this, was never really supported api anyway
|
||||
return String.format("https://maven.fabricmc.net/net/fabricmc/intermediary/%1$s/intermediary-%1$s-v2.jar", minecraftVersion);
|
||||
return String.format(this.getIntermediaryUrl().get(), minecraftVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -217,6 +217,13 @@ public interface LoomGradleExtensionAPI {
|
||||
*/
|
||||
Property<Boolean> getEnableTransitiveAccessWideners();
|
||||
|
||||
/**
|
||||
* Use "%1$s" as a placeholder for the minecraft version.
|
||||
*
|
||||
* @return the intermediary url template
|
||||
*/
|
||||
Property<String> getIntermediaryUrl();
|
||||
|
||||
// ===================
|
||||
// Architectury Loom
|
||||
// ===================
|
||||
|
||||
@@ -26,8 +26,9 @@ package net.fabricmc.loom.api.decompilers;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import net.fabricmc.loom.util.IOStringConsumer;
|
||||
|
||||
public record DecompilationMetadata(int numberOfThreads, Path javaDocs, Collection<Path> libraries, IOStringConsumer logger) {
|
||||
public record DecompilationMetadata(int numberOfThreads, Path javaDocs, Collection<Path> libraries, IOStringConsumer logger, Map<String, String> options) {
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -126,6 +127,10 @@ public class CFRObfuscationMapping extends NullMapping {
|
||||
}
|
||||
}
|
||||
|
||||
if (comment != null && !recordComponentDocs.isEmpty()) {
|
||||
print(" * ");
|
||||
}
|
||||
|
||||
for (String componentDoc : recordComponentDocs) {
|
||||
print(" * ").print(componentDoc).newln();
|
||||
}
|
||||
@@ -154,13 +159,23 @@ public class CFRObfuscationMapping extends NullMapping {
|
||||
lines.addAll(Arrays.asList(comment.split("\\R")));
|
||||
}
|
||||
|
||||
for (MappingTree.MethodArgMapping arg : mapping.getArgs()) {
|
||||
final Collection<? extends MappingTree.MethodArgMapping> methodArgs = mapping.getArgs();
|
||||
final List<String> params = new ArrayList<>();
|
||||
|
||||
for (MappingTree.MethodArgMapping arg : methodArgs) {
|
||||
String argComment = arg.getComment();
|
||||
|
||||
if (argComment != null) {
|
||||
lines.addAll(Arrays.asList(("@param " + arg.getSrcName() + " " + argComment).split("\\R")));
|
||||
params.addAll(Arrays.asList(("@param " + arg.getSrcName() + " " + argComment).split("\\R")));
|
||||
}
|
||||
}
|
||||
|
||||
// Add a blank line between params and the comment.
|
||||
if (!lines.isEmpty() && !params.isEmpty()) {
|
||||
lines.add("");
|
||||
}
|
||||
|
||||
lines.addAll(params);
|
||||
}
|
||||
|
||||
if (!lines.isEmpty()) {
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarOutputStream;
|
||||
@@ -64,7 +65,10 @@ public class LoomCFRDecompiler implements LoomDecompiler {
|
||||
@Override
|
||||
public void decompile(Path compiledJar, Path sourcesDestination, Path linemapDestination, DecompilationMetadata metaData) {
|
||||
final String path = compiledJar.toAbsolutePath().toString();
|
||||
final Options options = OptionsImpl.getFactory().create(DECOMPILE_OPTIONS);
|
||||
final Map<String, String> allOptions = new HashMap<>(DECOMPILE_OPTIONS);
|
||||
allOptions.putAll(metaData.options());
|
||||
|
||||
final Options options = OptionsImpl.getFactory().create(allOptions);
|
||||
|
||||
ClassFileSourceImpl classFileSource = new ClassFileSourceImpl(options);
|
||||
|
||||
@@ -138,7 +142,7 @@ public class LoomCFRDecompiler implements LoomDecompiler {
|
||||
decompiler.decompile(Paths.get("input.jar"),
|
||||
Paths.get("output-sources.jar"),
|
||||
lineMap,
|
||||
new DecompilationMetadata(4, null, Collections.emptyList(), null)
|
||||
new DecompilationMetadata(4, null, Collections.emptyList(), null, Collections.emptyMap())
|
||||
);
|
||||
|
||||
LineNumberRemapper lineNumberRemapper = new LineNumberRemapper();
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
package net.fabricmc.loom.decompilers.fernflower;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jetbrains.java.decompiler.main.Fernflower;
|
||||
@@ -38,21 +39,25 @@ import net.fabricmc.loom.api.decompilers.LoomDecompiler;
|
||||
public final class FabricFernFlowerDecompiler implements LoomDecompiler {
|
||||
@Override
|
||||
public String name() {
|
||||
return "FabricFlower"; // Or something else?
|
||||
return "FernFlower";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decompile(Path compiledJar, Path sourcesDestination, Path linemapDestination, DecompilationMetadata metaData) {
|
||||
Map<String, Object> options = Map.of(
|
||||
IFernflowerPreferences.DECOMPILE_GENERIC_SIGNATURES, "1",
|
||||
IFernflowerPreferences.BYTECODE_SOURCE_MAPPING, "1",
|
||||
IFernflowerPreferences.REMOVE_SYNTHETIC, "1",
|
||||
IFernflowerPreferences.LOG_LEVEL, "trace",
|
||||
IFernflowerPreferences.THREADS, String.valueOf(metaData.numberOfThreads()),
|
||||
IFernflowerPreferences.INDENT_STRING, "\t",
|
||||
IFabricJavadocProvider.PROPERTY_NAME, new TinyJavadocProvider(metaData.javaDocs().toFile())
|
||||
final Map<String, Object> options = new HashMap<>(
|
||||
Map.of(
|
||||
IFernflowerPreferences.DECOMPILE_GENERIC_SIGNATURES, "1",
|
||||
IFernflowerPreferences.BYTECODE_SOURCE_MAPPING, "1",
|
||||
IFernflowerPreferences.REMOVE_SYNTHETIC, "1",
|
||||
IFernflowerPreferences.LOG_LEVEL, "trace",
|
||||
IFernflowerPreferences.THREADS, String.valueOf(metaData.numberOfThreads()),
|
||||
IFernflowerPreferences.INDENT_STRING, "\t",
|
||||
IFabricJavadocProvider.PROPERTY_NAME, new TinyJavadocProvider(metaData.javaDocs().toFile())
|
||||
)
|
||||
);
|
||||
|
||||
options.putAll(metaData.options());
|
||||
|
||||
IResultSaver saver = new ThreadSafeResultSaver(sourcesDestination::toFile, linemapDestination::toFile);
|
||||
Fernflower ff = new Fernflower(FernFlowerUtils::getBytecode, saver, options, new FernflowerLogger(metaData.logger()));
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ public abstract class LoomGradleExtensionApiImpl implements LoomGradleExtensionA
|
||||
protected final Property<String> customManifest;
|
||||
protected final Property<Boolean> setupRemappedVariants;
|
||||
protected final Property<Boolean> transitiveAccessWideners;
|
||||
protected final Property<String> intermediary;
|
||||
|
||||
private final ModVersionParser versionParser;
|
||||
|
||||
@@ -111,6 +112,8 @@ public abstract class LoomGradleExtensionApiImpl implements LoomGradleExtensionA
|
||||
this.transitiveAccessWideners = project.getObjects().property(Boolean.class)
|
||||
.convention(true);
|
||||
this.transitiveAccessWideners.finalizeValueOnRead();
|
||||
this.intermediary = project.getObjects().property(String.class)
|
||||
.convention("https://maven.fabricmc.net/net/fabricmc/intermediary/%1$s/intermediary-%1$s-v2.jar");
|
||||
|
||||
this.versionParser = new ModVersionParser(project);
|
||||
|
||||
@@ -219,6 +222,11 @@ public abstract class LoomGradleExtensionApiImpl implements LoomGradleExtensionA
|
||||
|
||||
protected abstract LoomFiles getFiles();
|
||||
|
||||
@Override
|
||||
public Property<String> getIntermediaryUrl() {
|
||||
return intermediary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableDeprecatedPomGeneration(MavenPublication publication) {
|
||||
net.fabricmc.loom.configuration.MavenPublication.excludePublication(publication);
|
||||
|
||||
@@ -165,6 +165,12 @@ public class MinecraftGradleExtension implements LoomGradleExtensionAPI {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property<String> getIntermediaryUrl() {
|
||||
reportDeprecation();
|
||||
return parent.getIntermediaryUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void silentMojangMappingsLicense() {
|
||||
reportDeprecation();
|
||||
|
||||
@@ -44,6 +44,7 @@ import javax.inject.Inject;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.file.ConfigurableFileCollection;
|
||||
import org.gradle.api.file.RegularFileProperty;
|
||||
import org.gradle.api.provider.MapProperty;
|
||||
import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.InputFile;
|
||||
@@ -84,6 +85,9 @@ public abstract class GenerateSourcesTask extends AbstractLoomTask {
|
||||
@Input
|
||||
public abstract Property<Long> getMaxMemory();
|
||||
|
||||
@Input
|
||||
public abstract MapProperty<String, String> getOptions();
|
||||
|
||||
@Inject
|
||||
public abstract WorkerExecutor getWorkerExecutor();
|
||||
|
||||
@@ -99,6 +103,7 @@ public abstract class GenerateSourcesTask extends AbstractLoomTask {
|
||||
|
||||
getOutputs().upToDateWhen((o) -> false);
|
||||
getMaxMemory().convention(4096L).finalizeValueOnRead();
|
||||
getOptions().finalizeValueOnRead();
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
@@ -135,6 +140,8 @@ public abstract class GenerateSourcesTask extends AbstractLoomTask {
|
||||
workQueue.submit(DecompileAction.class, params -> {
|
||||
params.getDecompilerClass().set(decompiler.getClass().getCanonicalName());
|
||||
|
||||
params.getOptions().set(getOptions());
|
||||
|
||||
params.getInputJar().set(getInputJar());
|
||||
params.getRuntimeJar().set(getExtension().getMappingsProvider().mappedProvider.getMappedJar());
|
||||
params.getSourcesDestinationJar().set(getMappedJarFileWithSuffix("-sources.jar"));
|
||||
@@ -183,6 +190,8 @@ public abstract class GenerateSourcesTask extends AbstractLoomTask {
|
||||
public interface DecompileParams extends WorkParameters {
|
||||
Property<String> getDecompilerClass();
|
||||
|
||||
MapProperty<String, String> getOptions();
|
||||
|
||||
RegularFileProperty getInputJar();
|
||||
RegularFileProperty getRuntimeJar();
|
||||
RegularFileProperty getSourcesDestinationJar();
|
||||
@@ -232,7 +241,8 @@ public abstract class GenerateSourcesTask extends AbstractLoomTask {
|
||||
Runtime.getRuntime().availableProcessors(),
|
||||
getParameters().getMappings().get().getAsFile().toPath(),
|
||||
getLibraries(),
|
||||
logger
|
||||
logger,
|
||||
getParameters().getOptions().get()
|
||||
);
|
||||
|
||||
decompiler.decompile(
|
||||
|
||||
@@ -37,7 +37,6 @@ import net.fabricmc.loom.api.decompilers.LoomDecompiler;
|
||||
import net.fabricmc.loom.configuration.ide.RunConfigSettings;
|
||||
import net.fabricmc.loom.configuration.ide.SetupIntelijRunConfigs;
|
||||
import net.fabricmc.loom.configuration.providers.mappings.MappingsProviderImpl;
|
||||
import net.fabricmc.loom.decompilers.fernflower.FabricFernFlowerDecompiler;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
|
||||
public final class LoomTasks {
|
||||
@@ -157,7 +156,7 @@ public final class LoomTasks {
|
||||
return;
|
||||
}
|
||||
|
||||
File inputJar = mappingsProvider.mappedProvider.getMappedJar();
|
||||
File mappedJar = mappingsProvider.mappedProvider.getMappedJar();
|
||||
|
||||
if (mappingsProvider.hasUnpickDefinitions()) {
|
||||
File outputJar = mappingsProvider.mappedProvider.getUnpickedJar();
|
||||
@@ -168,21 +167,33 @@ public final class LoomTasks {
|
||||
unpickJarTask.getOutputJar().set(outputJar);
|
||||
});
|
||||
|
||||
inputJar = outputJar;
|
||||
mappedJar = outputJar;
|
||||
}
|
||||
|
||||
final File inputJar = mappedJar;
|
||||
|
||||
extension.getGameDecompilers().finalizeValue();
|
||||
|
||||
for (LoomDecompiler decompiler : extension.getGameDecompilers().get()) {
|
||||
String taskName = decompiler instanceof FabricFernFlowerDecompiler ? "genSources" : "genSourcesWith" + decompiler.name();
|
||||
// decompiler will be passed to the constructor of GenerateSourcesTask
|
||||
GenerateSourcesTask generateSourcesTask = tasks.register(taskName, GenerateSourcesTask.class, decompiler).get();
|
||||
generateSourcesTask.getInputJar().set(inputJar);
|
||||
String taskName = "genSourcesWith" + decompiler.name();
|
||||
// Decompiler will be passed to the constructor of GenerateSourcesTask
|
||||
tasks.register(taskName, GenerateSourcesTask.class, decompiler).configure(task -> {
|
||||
task.setDescription("Decompile minecraft using %s.".formatted(decompiler.name()));
|
||||
task.setGroup(Constants.TaskGroup.FABRIC);
|
||||
task.getInputJar().set(inputJar);
|
||||
|
||||
if (mappingsProvider.hasUnpickDefinitions()) {
|
||||
generateSourcesTask.dependsOn(tasks.getByName("unpickJar"));
|
||||
}
|
||||
if (mappingsProvider.hasUnpickDefinitions()) {
|
||||
task.dependsOn(tasks.getByName("unpickJar"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
tasks.register("genSources", task -> {
|
||||
task.setDescription("Decompile minecraft using the default decompiler.");
|
||||
task.setGroup(Constants.TaskGroup.FABRIC);
|
||||
|
||||
task.dependsOn(project.getTasks().getByName("genSourcesWithCfr"));
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user