aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorzml <zml@aoeu.xyz>2020-08-26 11:32:34 -0700
committerGitHub <noreply@github.com>2020-08-26 19:32:34 +0100
commit032c815d195b27066b94174e4160183ad402ebde (patch)
tree230431ff4330d39e9b7b15a02ee9845bf486c2a3 /src/main
parent2a1aca87cc396973f6930ea39cf4bdc7d1f38275 (diff)
downloadarchitectury-loom-032c815d195b27066b94174e4160183ad402ebde.tar.gz
architectury-loom-032c815d195b27066b94174e4160183ad402ebde.tar.bz2
architectury-loom-032c815d195b27066b94174e4160183ad402ebde.zip
Fix non-mod project dependencies (#263)
This resolves issues in ex. a composite build
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/net/fabricmc/loom/util/ModCompileRemapper.java37
1 files changed, 14 insertions, 23 deletions
diff --git a/src/main/java/net/fabricmc/loom/util/ModCompileRemapper.java b/src/main/java/net/fabricmc/loom/util/ModCompileRemapper.java
index 37626517..640dd459 100644
--- a/src/main/java/net/fabricmc/loom/util/ModCompileRemapper.java
+++ b/src/main/java/net/fabricmc/loom/util/ModCompileRemapper.java
@@ -35,7 +35,6 @@ import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.artifacts.ModuleDependency;
import org.gradle.api.artifacts.ResolvedArtifact;
-import org.gradle.api.artifacts.component.ModuleComponentIdentifier;
import org.gradle.api.artifacts.dsl.DependencyHandler;
import org.gradle.api.artifacts.query.ArtifactResolutionQuery;
import org.gradle.api.artifacts.result.ArtifactResult;
@@ -66,25 +65,16 @@ public class ModCompileRemapper {
List<ModDependencyInfo> modDependencies = new ArrayList<>();
for (ResolvedArtifact artifact : sourceConfig.getResolvedConfiguration().getResolvedArtifacts()) {
- String group;
- String name;
- String version;
+ // TODO: This collection doesn't appear to include FileCollection dependencies
+ // Might have to go based on the dependencies, rather than their resolved form?
+ // File dependencies use SelfResolvingDependency, which appears to be handled differently
+ String group = artifact.getModuleVersion().getId().getGroup();
+ String name = artifact.getModuleVersion().getId().getName();
+ String version = artifact.getModuleVersion().getId().getVersion();
String classifierSuffix = artifact.getClassifier() == null ? "" : (":" + artifact.getClassifier());
- if (artifact.getId().getComponentIdentifier() instanceof ModuleComponentIdentifier) {
- group = ((ModuleComponentIdentifier) artifact.getId().getComponentIdentifier()).getGroup();
- name = ((ModuleComponentIdentifier) artifact.getId().getComponentIdentifier()).getModule();
- version = ((ModuleComponentIdentifier) artifact.getId().getComponentIdentifier()).getVersion();
- } else {
- group = "net.fabricmc.synthetic";
- name = artifact.getId().getComponentIdentifier().getDisplayName().replace('.', '-').replace(" :", "-");
- version = "0.1.0";
- }
-
- final String notation = group + ":" + name + ":" + version + classifierSuffix;
-
- if (!isFabricMod(logger, artifact, notation)) {
- addToRegularCompile(project, regularConfig, notation);
+ if (!isFabricMod(logger, artifact)) {
+ addToRegularCompile(project, regularConfig, artifact);
continue;
}
@@ -122,12 +112,12 @@ public class ModCompileRemapper {
/**
* Checks if an artifact is a fabric mod, according to the presence of a fabric.mod.json.
*/
- private static boolean isFabricMod(Logger logger, ResolvedArtifact artifact, String notation) {
+ private static boolean isFabricMod(Logger logger, ResolvedArtifact artifact) {
File input = artifact.getFile();
try (ZipFile zipFile = new ZipFile(input)) {
if (zipFile.getEntry("fabric.mod.json") != null) {
- logger.info("Found Fabric mod in modCompile: {}", notation);
+ logger.info("Found Fabric mod in modCompile: {}", artifact.getId());
return true;
}
@@ -137,10 +127,11 @@ public class ModCompileRemapper {
}
}
- private static void addToRegularCompile(Project project, Configuration regularCompile, String notation) {
- project.getLogger().info(":providing " + notation);
+ private static void addToRegularCompile(Project project, Configuration regularCompile, ResolvedArtifact artifact) {
+ project.getLogger().info(":providing " + artifact);
DependencyHandler dependencies = project.getDependencies();
- Dependency dep = dependencies.module(notation);
+ Dependency dep = dependencies.module(artifact.getModuleVersion().toString()
+ + (artifact.getClassifier() == null ? "" : ':' + artifact.getClassifier())); // the owning module of the artifact
if (dep instanceof ModuleDependency) {
((ModuleDependency) dep).setTransitive(false);