From 4fe19028cf4194e3982adb28d7c51ddb27fed28b Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Thu, 27 Jan 2022 17:08:17 +0000 Subject: [PATCH] Add option to isolate the tiny remapper instance between sub-projects. (#588) --- .../fabricmc/loom/task/AbstractRemapJarTask.java | 7 +++++++ .../loom/task/service/TinyRemapperService.java | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/fabricmc/loom/task/AbstractRemapJarTask.java b/src/main/java/net/fabricmc/loom/task/AbstractRemapJarTask.java index af022a8..e23460f 100644 --- a/src/main/java/net/fabricmc/loom/task/AbstractRemapJarTask.java +++ b/src/main/java/net/fabricmc/loom/task/AbstractRemapJarTask.java @@ -58,6 +58,12 @@ public abstract class AbstractRemapJarTask extends Jar { @Input public abstract Property getTargetNamespace(); + /** + * When enabled the TinyRemapperService will not be shared across sub projects. + */ + @Input + public abstract Property getRemapperIsolation(); + @Inject protected abstract WorkerExecutor getWorkerExecutor(); @@ -65,6 +71,7 @@ public abstract class AbstractRemapJarTask extends Jar { public AbstractRemapJarTask() { getSourceNamespace().convention(MappingsNamespace.NAMED.toString()).finalizeValueOnRead(); getTargetNamespace().convention(MappingsNamespace.INTERMEDIARY.toString()).finalizeValueOnRead(); + getRemapperIsolation().convention(false).finalizeValueOnRead(); } public final

void submitWork(Class> workAction, Action

action) { diff --git a/src/main/java/net/fabricmc/loom/task/service/TinyRemapperService.java b/src/main/java/net/fabricmc/loom/task/service/TinyRemapperService.java index 9e05d65..54d974a 100644 --- a/src/main/java/net/fabricmc/loom/task/service/TinyRemapperService.java +++ b/src/main/java/net/fabricmc/loom/task/service/TinyRemapperService.java @@ -33,6 +33,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.StringJoiner; import org.gradle.api.Project; @@ -56,7 +57,19 @@ public class TinyRemapperService implements SharedService { final boolean useKotlinExtension = project.getPluginManager().hasPlugin("org.jetbrains.kotlin.jvm"); // Generates an id that is used to share the remapper across projects. This tasks in the remap jar task name to handle custom remap jar tasks separately. - final String id = extension.getMappingsProvider().getBuildServiceName("remapJarService", from, to) + ":" + remapJarTask.getName() + (useKotlinExtension ? ":kotlin" : ""); + final var joiner = new StringJoiner(":"); + joiner.add(extension.getMappingsProvider().getBuildServiceName("remapJarService", from, to)); + joiner.add(remapJarTask.getName()); + + if (useKotlinExtension) { + joiner.add("kotlin"); + } + + if (remapJarTask.getRemapperIsolation().get()) { + joiner.add(project.getPath()); + } + + final String id = joiner.toString(); TinyRemapperService service = sharedServiceManager.getOrCreateService(id, () -> { List mappings = new ArrayList<>();