Make RemapSourcesJarTask use properties (#459)
This commit is contained in:
		
							parent
							
								
									2f4cf35abf
								
							
						
					
					
						commit
						f9a06cbd41
					
				
					 2 changed files with 20 additions and 39 deletions
				
			
		|  | @ -139,8 +139,8 @@ public class RemapConfiguration { | ||||||
| 
 | 
 | ||||||
| 			RemapSourcesJarTask remapSourcesJarTask = (RemapSourcesJarTask) project.getTasks().findByName(remapSourcesJarTaskName); | 			RemapSourcesJarTask remapSourcesJarTask = (RemapSourcesJarTask) project.getTasks().findByName(remapSourcesJarTaskName); | ||||||
| 			Preconditions.checkNotNull(remapSourcesJarTask, "Could not find " + remapSourcesJarTaskName + " in " + project.getName()); | 			Preconditions.checkNotNull(remapSourcesJarTask, "Could not find " + remapSourcesJarTaskName + " in " + project.getName()); | ||||||
| 			remapSourcesJarTask.setInput(sourcesTask.getArchivePath()); | 			remapSourcesJarTask.getInput().set(sourcesTask.getArchiveFile()); | ||||||
| 			remapSourcesJarTask.setOutput(sourcesTask.getArchivePath()); | 			remapSourcesJarTask.getOutput().set(sourcesTask.getArchiveFile()); | ||||||
| 			remapSourcesJarTask.dependsOn(project.getTasks().getByName(sourcesJarTaskName)); | 			remapSourcesJarTask.dependsOn(project.getTasks().getByName(sourcesJarTaskName)); | ||||||
| 
 | 
 | ||||||
| 			if (isDefaultRemap) { | 			if (isDefaultRemap) { | ||||||
|  |  | ||||||
|  | @ -24,8 +24,8 @@ | ||||||
| 
 | 
 | ||||||
| package net.fabricmc.loom.task; | package net.fabricmc.loom.task; | ||||||
| 
 | 
 | ||||||
| import java.io.File; | import org.gradle.api.file.RegularFileProperty; | ||||||
| 
 | import org.gradle.api.provider.Property; | ||||||
| import org.gradle.api.tasks.Input; | import org.gradle.api.tasks.Input; | ||||||
| import org.gradle.api.tasks.InputFile; | import org.gradle.api.tasks.InputFile; | ||||||
| import org.gradle.api.tasks.Internal; | import org.gradle.api.tasks.Internal; | ||||||
|  | @ -35,12 +35,12 @@ import org.gradle.api.tasks.TaskAction; | ||||||
| import net.fabricmc.loom.util.SourceRemapper; | import net.fabricmc.loom.util.SourceRemapper; | ||||||
| 
 | 
 | ||||||
| public class RemapSourcesJarTask extends AbstractLoomTask { | public class RemapSourcesJarTask extends AbstractLoomTask { | ||||||
| 	private Object input; | 	private final RegularFileProperty input = getProject().getObjects().fileProperty(); | ||||||
| 	private Object output; | 	private final RegularFileProperty output = getProject().getObjects().fileProperty().convention(input); | ||||||
| 	private String direction = "intermediary"; | 	private final Property<String> targetNamespace = getProject().getObjects().property(String.class).convention("intermediary"); | ||||||
| 	private SourceRemapper sourceRemapper = null; | 	private SourceRemapper sourceRemapper = null; | ||||||
| 	private boolean preserveFileTimestamps = true; | 	private final Property<Boolean> preserveFileTimestamps = getProject().getObjects().property(Boolean.class).convention(true); | ||||||
| 	private boolean reproducibleFileOrder = false; | 	private final Property<Boolean> reproducibleFileOrder = getProject().getObjects().property(Boolean.class).convention(false); | ||||||
| 
 | 
 | ||||||
| 	public RemapSourcesJarTask() { | 	public RemapSourcesJarTask() { | ||||||
| 	} | 	} | ||||||
|  | @ -48,9 +48,10 @@ public class RemapSourcesJarTask extends AbstractLoomTask { | ||||||
| 	@TaskAction | 	@TaskAction | ||||||
| 	public void remap() throws Exception { | 	public void remap() throws Exception { | ||||||
| 		if (sourceRemapper == null) { | 		if (sourceRemapper == null) { | ||||||
| 			SourceRemapper.remapSources(getProject(), getInput(), getOutput(), direction.equals("named"), reproducibleFileOrder, preserveFileTimestamps); | 			String direction = targetNamespace.get(); | ||||||
|  | 			SourceRemapper.remapSources(getProject(), input.get().getAsFile(), output.get().getAsFile(), direction.equals("named"), reproducibleFileOrder.get(), preserveFileTimestamps.get()); | ||||||
| 		} else { | 		} else { | ||||||
| 			sourceRemapper.scheduleRemapSources(getInput(), getOutput(), reproducibleFileOrder, preserveFileTimestamps); | 			sourceRemapper.scheduleRemapSources(input.get().getAsFile(), output.get().getAsFile(), reproducibleFileOrder.get(), preserveFileTimestamps.get()); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -65,47 +66,27 @@ public class RemapSourcesJarTask extends AbstractLoomTask { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@InputFile | 	@InputFile | ||||||
| 	public File getInput() { | 	public RegularFileProperty getInput() { | ||||||
| 		return getProject().file(input); | 		return input; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@OutputFile | 	@OutputFile | ||||||
| 	public File getOutput() { | 	public RegularFileProperty getOutput() { | ||||||
| 		return getProject().file(output == null ? input : output); | 		return output; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@Input | 	@Input | ||||||
| 	public String getTargetNamespace() { | 	public Property<String> getTargetNamespace() { | ||||||
| 		return direction; | 		return targetNamespace; | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	public void setInput(Object input) { |  | ||||||
| 		this.input = input; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	public void setOutput(Object output) { |  | ||||||
| 		this.output = output; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	public void setTargetNamespace(String value) { |  | ||||||
| 		this.direction = value; |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@Input | 	@Input | ||||||
| 	public boolean isPreserveFileTimestamps() { | 	public Property<Boolean> getPreserveFileTimestamps() { | ||||||
| 		return preserveFileTimestamps; | 		return preserveFileTimestamps; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public void setPreserveFileTimestamps(boolean preserveFileTimestamps) { |  | ||||||
| 		this.preserveFileTimestamps = preserveFileTimestamps; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@Input | 	@Input | ||||||
| 	public boolean isReproducibleFileOrder() { | 	public Property<Boolean> getReproducibleFileOrder() { | ||||||
| 		return reproducibleFileOrder; | 		return reproducibleFileOrder; | ||||||
| 	} | 	} | ||||||
| 
 |  | ||||||
| 	public void setReproducibleFileOrder(boolean reproducibleFileOrder) { |  | ||||||
| 		this.reproducibleFileOrder = reproducibleFileOrder; |  | ||||||
| 	} |  | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue