Revert "Fix DependencyDownloader to not include two versions of the same dependency"

This reverts commit 44c58b70c3.
This commit is contained in:
shedaniel
2022-03-02 20:44:57 +08:00
parent ba4d0609fc
commit a4a61aaf70
2 changed files with 11 additions and 17 deletions

View File

@@ -303,7 +303,7 @@ public class ForgeUserdevProvider extends DependencyProvider {
}
private Set<File> minecraftClasspath() {
return DependencyDownloader.resolveFiles(getProject(), getProject().getConfigurations().getByName(Constants.Configurations.FORGE_RUNTIME_LIBRARY), true);
return DependencyDownloader.resolveFiles(getProject().getConfigurations().getByName(Constants.Configurations.FORGE_RUNTIME_LIBRARY), true);
}
public File getUserdevJar() {

View File

@@ -25,8 +25,7 @@
package net.fabricmc.loom.util;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.LinkedHashSet;
import java.util.Set;
import org.gradle.api.Project;
@@ -70,21 +69,16 @@ public final class DependencyDownloader {
return files;
}
private static List<Dependency> collectDependencies(Configuration configuration) {
List<Dependency> dependencies = new ArrayList<>();
private static Set<File> resolve(Configuration configuration, boolean transitive) {
Configuration copy = configuration.copy();
copy.setTransitive(transitive);
Set<File> files = new LinkedHashSet<>(copy.resolve());
for (Configuration extendsFrom : configuration.getExtendsFrom()) {
dependencies.addAll(collectDependencies(extendsFrom));
for (Configuration extendsForm : configuration.getExtendsFrom()) {
files.addAll(resolve(extendsForm, transitive));
}
dependencies.addAll(configuration.getDependencies());
return dependencies;
}
private static Configuration copyWith(Project project, Configuration configuration, boolean transitive) {
Configuration copy = project.getConfigurations().detachedConfiguration(collectDependencies(configuration).toArray(new Dependency[0]));
copy.setTransitive(transitive);
return copy;
return files;
}
/**
@@ -97,7 +91,7 @@ public final class DependencyDownloader {
* @param transitive true if transitive dependencies should be included, false otherwise
* @return a mutable set containing the resolved files of the configuration
*/
public static Set<File> resolveFiles(Project project, Configuration configuration, boolean transitive) {
return copyWith(project, configuration, transitive).resolve();
public static Set<File> resolveFiles(Configuration configuration, boolean transitive) {
return resolve(configuration, transitive);
}
}