Skip to content

Commit 1965fc8

Browse files
authored
Make the remapping mod configurations non-transitive (#192)
1 parent 610a6a1 commit 1965fc8

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

LEGACY.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,12 @@ obfuscation {
6868

6969
When reobfuscating a jar, it will be replaced in publications with the obfuscated version to avoid publishing jars that aren't mapped to SRG.
7070

71-
## Remapping mod dependencies
71+
## Remapping Mod Dependencies
7272
As published mods are using intermediary mappings, you must remap them to official mappings before being able to use them as a dependencies.
73-
ModDevGradle creates configurations that will automatically remap dependencies added to them from SRG mappings to official mappings.
73+
ModDevGradle creates configurations that will automatically remap dependencies added to them from SRG mappings to official mappings.
74+
75+
**IMPORTANT:** These configurations are not transitive, you will have to manually add transitive dependencies of the mods you are adding.
76+
7477
The following configurations are created automatically and are children of the configurations without the `mod` prefix:
7578
- `modImplementation`
7679
- `modRuntimeOnly`

legacytest/forge/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ java {
2525
}
2626

2727
dependencies {
28-
modCompileOnly('mezz.jei:jei-1.20.1-forge:15.17.0.76') {
29-
transitive = false // JEI publishes dependencies on its subprojects that are already included in this Jar
30-
}
28+
modCompileOnly('mezz.jei:jei-1.20.1-forge:15.17.0.76')
3129
modRuntimeOnly('curse.maven:mekanism-268560:5662583')
3230
modImplementation('curse.maven:applied-energistics-2-223794:5641282')
3331
}

src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/Obfuscation.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,22 @@ public Configuration createRemappingConfiguration(Configuration parent) {
108108
spec.attributes(attributeContainer -> {
109109
attributeContainer.attribute(LegacyForgeModDevPlugin.REMAPPED, true);
110110
});
111+
spec.setCanBeConsumed(false);
112+
spec.setCanBeResolved(false);
113+
spec.setTransitive(false);
111114

112115
// Unfortunately, if we simply try to make the parent extend this config, transformations will not run because the parent doesn't request remapped deps
113116
// If the parent were to request remapped deps, we'd be remapping everything in it.
114-
// Therefore we use a slight "hack" that imposes a constraint over all dependencies in this configuration: to be remapped
117+
// Therefore, we use a slight "hack" that imposes a constraint over all dependencies in this configuration: to be remapped.
118+
// Additionally, we force dependencies to be non-transitive since we cannot apply the attribute hack to transitive dependencies.
115119
spec.withDependencies(dependencies -> dependencies.forEach(dep -> {
116120
if (dep instanceof ExternalModuleDependency externalModuleDependency) {
117121
project.getDependencies().constraints(constraints -> {
118122
constraints.add(parent.getName(), externalModuleDependency.getGroup() + ":" + externalModuleDependency.getName() + ":" + externalModuleDependency.getVersion(), c -> {
119123
c.attributes(a -> a.attribute(LegacyForgeModDevPlugin.REMAPPED, true));
120124
});
121125
});
126+
externalModuleDependency.setTransitive(false);
122127
} else if (dep instanceof FileCollectionDependency fileCollectionDependency) {
123128
project.getDependencies().constraints(constraints -> {
124129
constraints.add(parent.getName(), fileCollectionDependency.getFiles(), c -> {
@@ -131,6 +136,7 @@ public Configuration createRemappingConfiguration(Configuration parent) {
131136
c.attributes(a -> a.attribute(LegacyForgeModDevPlugin.REMAPPED, true));
132137
});
133138
});
139+
projectDependency.setTransitive(false);
134140
}
135141
}));
136142
});

0 commit comments

Comments
 (0)