Skip to content

Commit 8464ed0

Browse files
authored
Note the mixed usages of ResourceTransformer and DuplicatesStrategy (#1349)
1 parent d872d45 commit 8464ed0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

docs/configuration/merging/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,3 +397,30 @@ Different strategies will lead to different results for `foo/bar` files in the J
397397
- `INCLUDE`: The **last** `foo/bar` file will be included in the final JAR (the default behavior).
398398
- `INHERIT`: **Fail** the build with an exception like `Entry .* is a duplicate but no duplicate handling strategy has been set`.
399399
- `WARN`: The **last** `foo/bar` file will be included in the final JAR, and a warning message will be logged.
400+
401+
**NOTE:** The `duplicatesStrategy` takes precedence over transforming and relocating. If you mix the usages of
402+
`duplicatesStrategy` and `ResourceTransformer` like below:
403+
404+
=== "Kotlin"
405+
406+
```kotlin
407+
tasks.shadowJar {
408+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
409+
mergeServiceFiles()
410+
}
411+
```
412+
413+
=== "Groovy"
414+
415+
```groovy
416+
tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
417+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
418+
mergeServiceFiles()
419+
}
420+
```
421+
422+
The `ServiceFileTransformer` will not work as expected because the `duplicatesStrategy` will exclude the duplicated
423+
service files beforehand. However, this behavior might be what you expected for duplicated `foo/bar` files, preventing
424+
them from being included.
425+
Want `ResourceTransformer`s and `duplicatesStrategy` to work together? There is a way to achieve this, leave the
426+
`duplicatesStrategy` as `INCLUDE` and declare a custom `ResourceTransformer` to handle the duplicated files.

0 commit comments

Comments
 (0)