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