diff options
author | modmuss50 <modmuss50@gmail.com> | 2020-12-21 20:42:23 +0000 |
---|---|---|
committer | modmuss50 <modmuss50@gmail.com> | 2020-12-21 20:42:23 +0000 |
commit | e20993daf86a4716b8b28d1c51806ddffcae71d0 (patch) | |
tree | 406f1a352f90f97cbd1244a160f4c4a1774d3ee6 /src | |
parent | 36954809ece363c690c9baebf9266ebe2f71876a (diff) | |
download | architectury-loom-e20993daf86a4716b8b28d1c51806ddffcae71d0.tar.gz architectury-loom-e20993daf86a4716b8b28d1c51806ddffcae71d0.tar.bz2 architectury-loom-e20993daf86a4716b8b28d1c51806ddffcae71d0.zip |
Allow setting the RemapJarTask classpath. Closes #307
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/net/fabricmc/loom/task/RemapJarTask.java | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/src/main/java/net/fabricmc/loom/task/RemapJarTask.java b/src/main/java/net/fabricmc/loom/task/RemapJarTask.java index af0e5031..3a8b271e 100644 --- a/src/main/java/net/fabricmc/loom/task/RemapJarTask.java +++ b/src/main/java/net/fabricmc/loom/task/RemapJarTask.java @@ -29,11 +29,10 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.LinkedHashSet; -import java.util.Set; import com.google.common.base.Preconditions; import org.gradle.api.Project; +import org.gradle.api.file.FileCollection; import org.gradle.api.file.RegularFileProperty; import org.gradle.api.provider.Property; import org.gradle.api.tasks.Input; @@ -61,6 +60,7 @@ public class RemapJarTask extends Jar { private final Property<Boolean> addNestedDependencies; private final Property<Boolean> remapAccessWidener; public JarRemapper jarRemapper; + private FileCollection classpath; public RemapJarTask() { super(); @@ -95,10 +95,7 @@ public class RemapJarTask extends Jar { String fromM = "named"; String toM = "intermediary"; - Set<File> classpathFiles = new LinkedHashSet<>( - project.getConfigurations().getByName("compileClasspath").getFiles() - ); - Path[] classpath = classpathFiles.stream().map(File::toPath).filter((p) -> !input.equals(p) && Files.exists(p)).toArray(Path[]::new); + Path[] classpath = getRemapClasspath(); TinyRemapper.Builder remapperBuilder = TinyRemapper.newRemapper(); @@ -173,16 +170,7 @@ public class RemapJarTask extends Jar { String toM = "intermediary"; if (extension.isRootProject()) { - Set<File> classpathFiles = new LinkedHashSet<>( - project.getConfigurations().getByName("compileClasspath").getFiles() - ); - - Path[] classpath = classpathFiles.stream() - .map(File::toPath) - .filter(Files::exists) - .toArray(Path[]::new); - - jarRemapper.addToClasspath(classpath); + jarRemapper.addToClasspath(getRemapClasspath()); jarRemapper.addMappings(TinyRemapperMappingsHelper.create(mappingsProvider.getMappings(), fromM, toM, false)); } @@ -235,6 +223,19 @@ public class RemapJarTask extends Jar { }); } + private Path[] getRemapClasspath() { + FileCollection files = this.classpath; + + if (files == null) { + files = getProject().getConfigurations().getByName("compileClasspath"); + } + + return files.getFiles().stream() + .map(File::toPath) + .filter(Files::exists) + .toArray(Path[]::new); + } + @InputFile public RegularFileProperty getInput() { return input; @@ -249,4 +250,14 @@ public class RemapJarTask extends Jar { public Property<Boolean> getRemapAccessWidener() { return remapAccessWidener; } + + public RemapJarTask classpath(FileCollection collection) { + if (this.classpath == null) { + this.classpath = collection; + } else { + this.classpath = this.classpath.plus(collection); + } + + return this; + } } |