Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions LEGACY.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@ obfuscation {

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

## Remapping mod dependencies
## Remapping Mod Dependencies
As published mods are using intermediary mappings, you must remap them to official mappings before being able to use them as a dependencies.
ModDevGradle creates configurations that will automatically remap dependencies added to them from SRG mappings to official mappings.
ModDevGradle creates configurations that will automatically remap dependencies added to them from SRG mappings to official mappings.

**IMPORTANT:** These configurations are not transitive, you will have to manually add transitive dependencies of the mods you are adding.

The following configurations are created automatically and are children of the configurations without the `mod` prefix:
- `modImplementation`
- `modRuntimeOnly`
Expand Down
4 changes: 1 addition & 3 deletions legacytest/forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ java {
}

dependencies {
modCompileOnly('mezz.jei:jei-1.20.1-forge:15.17.0.76') {
transitive = false // JEI publishes dependencies on its subprojects that are already included in this Jar
}
modCompileOnly('mezz.jei:jei-1.20.1-forge:15.17.0.76')
modRuntimeOnly('curse.maven:mekanism-268560:5662583')
modImplementation('curse.maven:applied-energistics-2-223794:5641282')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,22 @@ public Configuration createRemappingConfiguration(Configuration parent) {
spec.attributes(attributeContainer -> {
attributeContainer.attribute(LegacyForgeModDevPlugin.REMAPPED, true);
});
spec.setCanBeConsumed(false);
spec.setCanBeResolved(false);
spec.setTransitive(false);

// Unfortunately, if we simply try to make the parent extend this config, transformations will not run because the parent doesn't request remapped deps
// If the parent were to request remapped deps, we'd be remapping everything in it.
// Therefore we use a slight "hack" that imposes a constraint over all dependencies in this configuration: to be remapped
// Therefore, we use a slight "hack" that imposes a constraint over all dependencies in this configuration: to be remapped.
// Additionally, we force dependencies to be non-transitive since we cannot apply the attribute hack to transitive dependencies.
spec.withDependencies(dependencies -> dependencies.forEach(dep -> {
if (dep instanceof ExternalModuleDependency externalModuleDependency) {
project.getDependencies().constraints(constraints -> {
constraints.add(parent.getName(), externalModuleDependency.getGroup() + ":" + externalModuleDependency.getName() + ":" + externalModuleDependency.getVersion(), c -> {
c.attributes(a -> a.attribute(LegacyForgeModDevPlugin.REMAPPED, true));
});
});
externalModuleDependency.setTransitive(false);
} else if (dep instanceof FileCollectionDependency fileCollectionDependency) {
project.getDependencies().constraints(constraints -> {
constraints.add(parent.getName(), fileCollectionDependency.getFiles(), c -> {
Expand All @@ -131,6 +136,7 @@ public Configuration createRemappingConfiguration(Configuration parent) {
c.attributes(a -> a.attribute(LegacyForgeModDevPlugin.REMAPPED, true));
});
});
projectDependency.setTransitive(false);
}
}));
});
Expand Down
Loading