ITADN

Multiproject merge of service files fails

#1914OpenRobert-Brune 创建于 2026-01-28
bug
R
Robert-Brunecommented
### Expected and Results ## Problem In a multi-project it seems, that the resources of two subprojects just override each other, even if `mergeServiceFiles()` is called. This results to that only the service(s) of the first dependency becomes declared in the final service file, of the produced shadow JAR. When run with `DuplicatesStrategy.WARN` this becomes obvious: ``` zip entry 'root-project/pluginB/build/libs/pluginB.jar!META-INF/services/test' will be copied to 'META-INF/services/test', overwriting zip entry 'root-project/pluginA/build/libs/pluginA.jar!META-INF/services/test', which has already been copied there. ``` ## Expected Behavior Subprojects are handled equally to external dependencies as stated in the docs (https://gradleup.com/shadow/multi-project/), so the service files can be merged (on demand). ### Related environment and versions 'com.gradleup.shadow': "9.3.1" ------------------------------------------------------------ Gradle 9.1.0 ------------------------------------------------------------ Build time: 2025-09-18 13:05:56 UTC Revision: e45a8dbf2470c2e2474ccc25be9f49331406a07e Kotlin: 2.2.0 Groovy: 4.0.28 Ant: Apache Ant(TM) version 1.10.15 compiled on August 25 2024 Launcher JVM: 25.0.2 (Homebrew 25.0.2) OS: Mac OS X 26.2 aarch64 ### Reproduction steps ``` - root.project - build.gradle - pluginA - build.gradle (java-library) - src/main/ressources/META-INF/services/test (content:`test.A`) - pluginB - build.gradle (java-library) - src/main/ressources/META-INF/services/test (content: `test.B`) ``` (java-library): ``` plugins { id 'java-library' } ``` settings.gradle ``` rootProject.name = 'root.project' include("pluginA") include("pluginB") ``` build.gradle: ``` plugins { id 'com.gradleup.shadow' version "9.3.1" id 'java-library' } dependencies { runtimeOnly project(":pluginA") runtimeOnly project(":pluginB") } shadowJar { duplicatesStrategy = DuplicatesStrategy.WARN mergeServiceFiles() } ``` ``` gradle shadowJar ``` The final `build/libs/root-project-all.jar` only contains the service of pluginA, but not the one of pluginB. When the dependency of `pluginA` gets removed in `build.gradle` the service file of `pluginB` appears in the jar. There doesn't seem to be any merging at all, as the transformer only receives one of the service files. Compare warning when run with `DuplicatesStrategy.WARN`. ### Anything else? _No response_
0 条评论