Suresh Vadlamudi
10/10/2025, 7:50 PMMike Wacker
10/10/2025, 9:07 PMinstallDist tasks in a Gradle multi-project build. The sub-projects were hierarchically organized, but JAR names default to project names. E.g., :thing1:api and :thing2:api both produce a JAR named api.jar.
In my case, the "strategy" was to add this to my convention plugin (i.e., buildSrc/src/main/kotlin/buildlogic.java-conventions.gradle.kts):
tasks.withType<Jar> {
archiveBaseName = "${rootProject.name}-${project.path.substring(1).replace(':', '-')}"
}
That ensured that each sub-project has a unique JAR name.
But it's hard to say what the best solution is in your case without more context as to the source of the duplicates.Suresh Vadlamudi
10/10/2025, 9:36 PMVampire
10/11/2025, 12:27 PMNot sure what is the hesitation to add OVERWRITE duplicate strategy. i guess this will help a lot.
Just a wild guess, but probably for archive tasks this is checked on-the-fly, so the contents of the first file are already written to the archive and overwrite would no longer work. But anyway, I've yet to see any valid use-case for a valid duplicate strategy besides
FAIL. All cases I had so far where Gradle complained about missing duplicates strategy setting one would just have been symptom treatment. And it is especially problematic because you can only set it for all files, not for single files, so if you set it now due to this file, future problems like this will resolved the same way which might not be correct. Instead fix where the problem is coming from and make sure there are no duplicates, for example by proper excludes.