mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-03-28 04:07:01 -05:00
Fix project deps (#1437)
This commit is contained in:
@@ -24,6 +24,8 @@
|
||||
|
||||
package net.fabricmc.loom.configuration.processors.speccontext;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.file.ConfigurableFileCollection;
|
||||
@@ -32,6 +34,8 @@ import org.gradle.api.file.FileCollection;
|
||||
public interface DeobfProjectView extends ProjectView {
|
||||
FileCollection getDependencies(DebofConfiguration debofConfiguration, DebofConfiguration.TargetSourceSet targetSourceSet);
|
||||
|
||||
Stream<Project> getProjectDependencies(DebofConfiguration debofConfiguration);
|
||||
|
||||
FileCollection getFullClasspath();
|
||||
|
||||
class Impl extends AbstractProjectView implements DeobfProjectView {
|
||||
@@ -44,6 +48,12 @@ public interface DeobfProjectView extends ProjectView {
|
||||
return debofConfiguration.getConfiguration(project, targetSourceSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Project> getProjectDependencies(DebofConfiguration debofConfiguration) {
|
||||
return debofConfiguration.getConfigurations(project).stream()
|
||||
.flatMap(configuration -> getLoomProjectDependencies(configuration.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileCollection getFullClasspath() {
|
||||
ConfigurableFileCollection classpath = project.files();
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -36,6 +37,7 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.file.FileCollection;
|
||||
@@ -89,10 +91,16 @@ public record DeobfSpecContext(List<FabricModJson> modDependencies,
|
||||
clientTransformingModIds = Set.of();
|
||||
}
|
||||
|
||||
// All dependency mods that are on both the compile and runtime classpath
|
||||
List<FabricModJson> modDependenciesCompileRuntime = new ArrayList<>(getMods(mods, combine(mainTransformingModIds, clientTransformingModIds)));
|
||||
|
||||
// Add all of the project depedencies that are on both the compile and runtime classpath
|
||||
modDependenciesCompileRuntime.addAll(getCompileRuntimeProjectMods(projectView, fmjCache));
|
||||
|
||||
return new DeobfSpecContext(
|
||||
dependentMods,
|
||||
projectView.getMods(),
|
||||
getMods(mods, combine(mainTransformingModIds, clientTransformingModIds)),
|
||||
modDependenciesCompileRuntime,
|
||||
getMods(mods, onlyInLeft(clientTransformingModIds, mainTransformingModIds))
|
||||
);
|
||||
}
|
||||
@@ -157,6 +165,34 @@ public record DeobfSpecContext(List<FabricModJson> modDependencies,
|
||||
return result;
|
||||
}
|
||||
|
||||
// Returns a list of mods that are on both to compile and runtime classpath
|
||||
private static List<FabricModJson> getCompileRuntimeProjectMods(DeobfProjectView projectView, AsyncCache<List<FabricModJson>> fmjCache) {
|
||||
var mods = new ArrayList<FabricModJson>();
|
||||
|
||||
for (Project dependentProject : getCompileRuntimeProjectDependencies(projectView).toList()) {
|
||||
List<FabricModJson> projectMods = fmjCache.getBlocking(dependentProject.getPath(), () -> {
|
||||
return FabricModJsonHelpers.getModsInProject(dependentProject);
|
||||
});
|
||||
|
||||
mods.addAll(projectMods);
|
||||
}
|
||||
|
||||
return Collections.unmodifiableList(mods);
|
||||
}
|
||||
|
||||
// Returns a list of Loom Projects found in both the runtime and compile classpath
|
||||
private static Stream<Project> getCompileRuntimeProjectDependencies(DeobfProjectView projectView) {
|
||||
if (projectView.disableProjectDependantMods()) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
final Stream<Project> runtimeProjects = projectView.getProjectDependencies(DebofConfiguration.RUNTIME);
|
||||
final List<Project> compileProjects = projectView.getProjectDependencies(DebofConfiguration.COMPILE).toList();
|
||||
|
||||
return runtimeProjects
|
||||
.filter(compileProjects::contains); // Use the intersection of the two configurations.
|
||||
}
|
||||
|
||||
private static Set<String> common(Set<String> a, Set<String> b) {
|
||||
Set<String> copy = new HashSet<>(a);
|
||||
copy.retainAll(b);
|
||||
|
||||
Reference in New Issue
Block a user