mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-03-30 21:05:58 -05:00
Skip remapping in AbstractRemapJarTasks when source and target namespaces match (#985)
* Skip remapping in `AbstractRemapJarTask`s when source and target namespaces match The "remap jar" tasks have much more functionality than simply remapping jars at this point, such as adding namespace metadata, nesting jars, ensuring reproducible builds, etc. Some custom build logic may want to take advantage of these features without the full overhead of no-op remapping with TinyRemapper/Mercury. * Add test
This commit is contained in:
@@ -26,6 +26,7 @@ package net.fabricmc.loom.task;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -35,6 +36,7 @@ import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.provider.Provider;
|
||||
import org.gradle.api.tasks.SourceSet;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -57,7 +59,9 @@ public abstract class RemapSourcesJarTask extends AbstractRemapJarTask {
|
||||
@TaskAction
|
||||
public void run() {
|
||||
submitWork(RemapSourcesAction.class, params -> {
|
||||
params.getSourcesRemapperServiceUuid().set(UnsafeWorkQueueHelper.create(SourceRemapperService.create(serviceManagerProvider.get().get(), this)));
|
||||
if (!params.namespacesMatch()) {
|
||||
params.getSourcesRemapperServiceUuid().set(UnsafeWorkQueueHelper.create(SourceRemapperService.create(serviceManagerProvider.get().get(), this)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -75,18 +79,24 @@ public abstract class RemapSourcesJarTask extends AbstractRemapJarTask {
|
||||
public abstract static class RemapSourcesAction extends AbstractRemapAction<RemapSourcesParams> {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RemapSourcesAction.class);
|
||||
|
||||
private final SourceRemapperService sourceRemapperService;
|
||||
private final @Nullable SourceRemapperService sourceRemapperService;
|
||||
|
||||
public RemapSourcesAction() {
|
||||
super();
|
||||
|
||||
sourceRemapperService = UnsafeWorkQueueHelper.get(getParameters().getSourcesRemapperServiceUuid(), SourceRemapperService.class);
|
||||
sourceRemapperService = getParameters().getSourcesRemapperServiceUuid().isPresent()
|
||||
? UnsafeWorkQueueHelper.get(getParameters().getSourcesRemapperServiceUuid(), SourceRemapperService.class)
|
||||
: null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
sourceRemapperService.remapSourcesJar(inputFile, outputFile);
|
||||
if (sourceRemapperService != null) {
|
||||
sourceRemapperService.remapSourcesJar(inputFile, outputFile);
|
||||
} else {
|
||||
Files.copy(inputFile, outputFile, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
|
||||
modifyJarManifest();
|
||||
rewriteJar();
|
||||
|
||||
Reference in New Issue
Block a user