diff --git a/build.gradle b/build.gradle index 219fb790ab..9d35401302 100644 --- a/build.gradle +++ b/build.gradle @@ -753,19 +753,42 @@ dependencies { } } -remapJar { - afterEvaluate { - subprojects.each { - if (it.name in devOnlyModules || metaProjects.contains(it.name)) { - return - } +configurations { + nestedJars { + transitive = false + } +} - // Include the signed or none signed jar from the sub project. - nestedJars.from project("${it.path}").tasks.getByName("signRemapJar") +dependencies { + subprojects.each { + if (it.name in devOnlyModules || metaProjects.contains(it.name)) { + return } + + nestedJars project("${it.path}") + } +} + +remapJar { + nestedJars.from configurations.nestedJars +} + +// Attempt to create a single jar with all files from all nested jars, this will fail if there are duplicate files. +tasks.register("checkNoDuplicateFiles", Zip) { + inputs.files configurations.nestedJars + destinationDirectory = layout.buildDirectory.dir("test") + + from { + configurations.nestedJars.files.collect { zipTree(it) } } + + // We expect these files to be duplicated, so exclude them. + exclude 'META-INF/**' + exclude 'fabric.mod.json' } +check.dependsOn "checkNoDuplicateFiles" + publishMods { file = signRemapJar.output changelog = providers.environmentVariable("CHANGELOG").getOrElse("No changelog provided")