Slightly ugly but works
dev/0.11
modmuss50 2020-09-04 19:12:04 +01:00
parent 8b1268abe7
commit 545b0c946b
1 changed files with 16 additions and 3 deletions

View File

@ -29,6 +29,7 @@ import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
@ -99,14 +100,20 @@ public class NestedJars {
private static List<File> getContainedJars(Project project) {
List<File> fileList = new ArrayList<>();
ResolvedConfiguration configuration = project.getConfigurations().getByName(Constants.INCLUDE).getResolvedConfiguration();
Set<ResolvedDependency> dependencies = configuration.getFirstLevelModuleDependencies();
Configuration configuration = project.getConfigurations().getByName(Constants.INCLUDE);
ResolvedConfiguration resolvedConfiguration = configuration.getResolvedConfiguration();
Set<ResolvedDependency> dependencies = resolvedConfiguration.getFirstLevelModuleDependencies();
for (ResolvedDependency dependency : dependencies) {
// Bit ugly doing this, id guess there is a better way but this works.
Set<String> projectDeps = new HashSet<>();
for (Dependency dependency : configuration.getDependencies()) {
if (dependency instanceof ProjectDependency) {
ProjectDependency projectDependency = (ProjectDependency) dependency;
Project dependencyProject = projectDependency.getDependencyProject();
projectDeps.add(dependency.getGroup() + ":" + dependency.getName() + ":" + dependency.getVersion());
// TODO change this to allow just normal jar tasks, so a project can have a none loom sub project
Collection<Task> remapJarTasks = dependencyProject.getTasksByName("remapJar", false);
Collection<Task> jarTasks = dependencyProject.getTasksByName("jar", false);
@ -118,6 +125,12 @@ public class NestedJars {
fileList.add(((AbstractArchiveTask) task).getArchivePath());
}
}
}
}
for (ResolvedDependency dependency : dependencies) {
if (projectDeps.contains(dependency.getModuleGroup() + ":" + dependency.getModuleName() + ":" + dependency.getModuleVersion())) {
continue;
} else {
fileList.addAll(prepareForNesting(
dependency