Fix misc jar remapping issues.
parent
d40241d75a
commit
421b41ebc7
|
@ -79,14 +79,12 @@ public abstract class PrepareJarRemapTask extends AbstractLoomTask {
|
||||||
|
|
||||||
workQueue.submit(ReadInputsAction.class, params -> {
|
workQueue.submit(ReadInputsAction.class, params -> {
|
||||||
params.getTinyRemapperBuildServiceUuid().set(UnsafeWorkQueueHelper.create(getProject(), remapJarTask.getTinyRemapperService()));
|
params.getTinyRemapperBuildServiceUuid().set(UnsafeWorkQueueHelper.create(getProject(), remapJarTask.getTinyRemapperService()));
|
||||||
params.getInputTagName().set(remapJarTask.getInputTagName());
|
|
||||||
params.getInputFile().set(getInputFile());
|
params.getInputFile().set(getInputFile());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ReadInputsParams extends WorkParameters {
|
public interface ReadInputsParams extends WorkParameters {
|
||||||
Property<String> getTinyRemapperBuildServiceUuid();
|
Property<String> getTinyRemapperBuildServiceUuid();
|
||||||
Property<String> getInputTagName();
|
|
||||||
RegularFileProperty getInputFile();
|
RegularFileProperty getInputFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +100,7 @@ public abstract class PrepareJarRemapTask extends AbstractLoomTask {
|
||||||
final TinyRemapper tinyRemapper = tinyRemapperService.getTinyRemapperForInputs();
|
final TinyRemapper tinyRemapper = tinyRemapperService.getTinyRemapperForInputs();
|
||||||
final Path inputFile = getParameters().getInputFile().getAsFile().get().toPath();
|
final Path inputFile = getParameters().getInputFile().getAsFile().get().toPath();
|
||||||
|
|
||||||
tinyRemapper.readInputsAsync(tinyRemapperService.createTag(getParameters().getInputTagName().get()), inputFile);
|
tinyRemapper.readInputsAsync(tinyRemapperService.getOrCreateTag(inputFile), inputFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,6 @@ public abstract class RemapJarTask extends AbstractRemapJarTask {
|
||||||
params.getJarManifestService().set(JarManifestService.get(getProject()));
|
params.getJarManifestService().set(JarManifestService.get(getProject()));
|
||||||
params.getTinyRemapperBuildServiceUuid().set(UnsafeWorkQueueHelper.create(getProject(), tinyRemapperService.get()));
|
params.getTinyRemapperBuildServiceUuid().set(UnsafeWorkQueueHelper.create(getProject(), tinyRemapperService.get()));
|
||||||
params.getRemapClasspath().from(getClasspath());
|
params.getRemapClasspath().from(getClasspath());
|
||||||
params.getInputTagName().set(getInputTagName());
|
|
||||||
|
|
||||||
final boolean legacyMixin = extension.getMixin().getUseLegacyMixinAp().get();
|
final boolean legacyMixin = extension.getMixin().getUseLegacyMixinAp().get();
|
||||||
params.getUseMixinExtension().set(!legacyMixin);
|
params.getUseMixinExtension().set(!legacyMixin);
|
||||||
|
@ -193,7 +192,6 @@ public abstract class RemapJarTask extends AbstractRemapJarTask {
|
||||||
public interface RemapParams extends AbstractRemapParams {
|
public interface RemapParams extends AbstractRemapParams {
|
||||||
ConfigurableFileCollection getNestedJars();
|
ConfigurableFileCollection getNestedJars();
|
||||||
ConfigurableFileCollection getRemapClasspath();
|
ConfigurableFileCollection getRemapClasspath();
|
||||||
Property<String> getInputTagName();
|
|
||||||
|
|
||||||
Property<Boolean> getUseMixinExtension();
|
Property<Boolean> getUseMixinExtension();
|
||||||
|
|
||||||
|
@ -243,7 +241,7 @@ public abstract class RemapJarTask extends AbstractRemapJarTask {
|
||||||
private void remap() throws IOException {
|
private void remap() throws IOException {
|
||||||
try (OutputConsumerPath outputConsumer = new OutputConsumerPath.Builder(outputFile).build()) {
|
try (OutputConsumerPath outputConsumer = new OutputConsumerPath.Builder(outputFile).build()) {
|
||||||
outputConsumer.addNonClassFiles(inputFile);
|
outputConsumer.addNonClassFiles(inputFile);
|
||||||
tinyRemapper.apply(outputConsumer, tinyRemapperService.getTag(getParameters().getInputTagName().get()));
|
tinyRemapper.apply(outputConsumer, tinyRemapperService.getOrCreateTag(inputFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,9 +321,4 @@ public abstract class RemapJarTask extends AbstractRemapJarTask {
|
||||||
public TinyRemapperService getTinyRemapperService() {
|
public TinyRemapperService getTinyRemapperService() {
|
||||||
return tinyRemapperService.get();
|
return tinyRemapperService.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Internal
|
|
||||||
String getInputTagName() {
|
|
||||||
return getProject().getPath() + getName();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ public abstract class JarManifestService implements BuildService<JarManifestServ
|
||||||
Property<MixinVersion> getMixinVersion();
|
Property<MixinVersion> getMixinVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Provider<JarManifestService> get(Project project) {
|
public static synchronized Provider<JarManifestService> get(Project project) {
|
||||||
return project.getGradle().getSharedServices().registerIfAbsent("LoomJarManifestService:" + project.getName(), JarManifestService.class, spec -> {
|
return project.getGradle().getSharedServices().registerIfAbsent("LoomJarManifestService:" + project.getName(), JarManifestService.class, spec -> {
|
||||||
spec.parameters(params -> {
|
spec.parameters(params -> {
|
||||||
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
|
|
|
@ -52,7 +52,7 @@ public final class MixinMappingsService implements SharedService {
|
||||||
return mixinMapping;
|
return mixinMapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
static MixinMappingsService getService(SharedServiceManager sharedServiceManager) {
|
static synchronized MixinMappingsService getService(SharedServiceManager sharedServiceManager) {
|
||||||
return sharedServiceManager.getOrCreateService("MixinMappings", () -> new MixinMappingsService(sharedServiceManager));
|
return sharedServiceManager.getOrCreateService("MixinMappings", () -> new MixinMappingsService(sharedServiceManager));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,9 +109,7 @@ public final class SourceRemapperService implements SharedService {
|
||||||
|
|
||||||
private synchronized void doRemap(Path srcPath, Path dstPath, Path source) {
|
private synchronized void doRemap(Path srcPath, Path dstPath, Path source) {
|
||||||
try {
|
try {
|
||||||
synchronized (mercury) {
|
|
||||||
mercury.get().rewrite(srcPath, dstPath);
|
mercury.get().rewrite(srcPath, dstPath);
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.warn("Could not remap " + source + " fully!", e);
|
LOGGER.warn("Could not remap " + source + " fully!", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,11 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.gradle.api.Project;
|
import org.gradle.api.Project;
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ public class TinyRemapperService implements SharedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private TinyRemapper tinyRemapper;
|
private TinyRemapper tinyRemapper;
|
||||||
private final Map<String, InputTag> inputTagMap = new ConcurrentHashMap<>();
|
private final Map<String, InputTag> inputTagMap = new HashMap<>();
|
||||||
private final HashSet<Path> classpath = new HashSet<>();
|
private final HashSet<Path> classpath = new HashSet<>();
|
||||||
// Set to true once remapping has started, once set no inputs can be read.
|
// Set to true once remapping has started, once set no inputs can be read.
|
||||||
private boolean isRemapping = false;
|
private boolean isRemapping = false;
|
||||||
|
@ -92,16 +92,15 @@ public class TinyRemapperService implements SharedService {
|
||||||
tinyRemapper = builder.build();
|
tinyRemapper = builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputTag createTag(String key) {
|
public synchronized InputTag getOrCreateTag(Path file) {
|
||||||
if (inputTagMap.containsKey(key)) {
|
InputTag tag = inputTagMap.get(file.toAbsolutePath().toString());
|
||||||
throw new IllegalStateException("Input tag already exists for key: " + key);
|
|
||||||
|
if (tag == null) {
|
||||||
|
tag = tinyRemapper.createInputTag();
|
||||||
|
inputTagMap.put(file.toAbsolutePath().toString(), tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
return inputTagMap.put(key, tinyRemapper.createInputTag());
|
return tag;
|
||||||
}
|
|
||||||
|
|
||||||
public InputTag getTag(String key) {
|
|
||||||
return Objects.requireNonNull(inputTagMap.get(key), "Input tag not found for: " + key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TinyRemapper getTinyRemapperForRemapping() {
|
public TinyRemapper getTinyRemapperForRemapping() {
|
||||||
|
|
Loading…
Reference in New Issue