Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that there are no duplicate files across projects. #4301

Merged
merged 3 commits into from
Dec 16, 2024
Merged
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
39 changes: 31 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -744,19 +744,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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a Copy too, but I guess this saves some disk space since the files aren't even used

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it could be a Sync, However I think Zip is likely best, if I had to guess zip is likely faster than dealing with 1000s of small files. In the end it doesnt really matter.

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")
Expand Down