You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/changes/README.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,10 @@
6
6
### Changed
7
7
8
8
- Improve the error message for empty `mainClassName`. ([#1601](https://github.com/GradleUp/shadow/pull/1601))
9
+
- Default `duplicatesStrategy` back to `EXCLUDE`. ([#1617](https://github.com/GradleUp/shadow/pull/1617))
10
+
- This strategy is consistent with 8.x series behavior, which is more compatible for most users upgrading.
11
+
- For most `ResourceTransformer` users, you need to override the strategy to `INCLUDE` to make them work.
12
+
- See more details about the strategies at [Handling Duplicates Strategy](https://gradleup.com/shadow/configuration/merging/#handling-duplicates-strategy).
duplicatesStrategy = DuplicatesStrategy.EXCLUDE // Or something else.
45
+
duplicatesStrategy = DuplicatesStrategy.INCLUDE // Or something else.
47
46
}
48
47
```
49
48
50
49
Different strategies will lead to different results for `foo/bar` files in the JARs to be merged:
51
50
52
51
-`EXCLUDE`: The **first**`foo/bar` file will be included in the final JAR.
53
52
-`FAIL`: **Fail** the build with a `DuplicateFileCopyingException` if there are duplicate `foo/bar` files.
54
-
-`INCLUDE`: Duplicate `foo/bar` entries will be included in the final JAR.
53
+
-`INCLUDE`: **Duplicate**`foo/bar` entries will be included in the final JAR.
55
54
-`INHERIT`: **Fail** the build with an exception like
56
55
`Entry .* is a duplicate but no duplicate handling strategy has been set`.
57
56
-`WARN`: **Warn** about duplicates in the build log, this behaves exactly as `INHERIT` otherwise.
@@ -78,17 +77,18 @@ Different strategies will lead to different results for `foo/bar` files in the J
78
77
```
79
78
80
79
The [`ResourceTransformer`][ResourceTransformer]s like [`ServiceFileTransformer`][ServiceFileTransformer] will not work
81
-
as expected because the `duplicatesStrategy` will exclude the duplicate service files beforehand. However, this behavior might be what you expected for duplicate
82
-
`foo/bar` files, preventing them from being included.
80
+
as expected as the duplicate resource files fed for them are excluded beforehand. However, this behavior might be what you expected for duplicate `foo/bar` files, preventing them from being included.
83
81
84
-
Want [`ResourceTransformer`][ResourceTransformer]s and `duplicatesStrategy` to work together? There are several ways to
85
-
do it:
82
+
Want [`ResourceTransformer`][ResourceTransformer]s and `duplicatesStrategy` to work together? There are several steps
83
+
to take:
86
84
87
-
- Use [`filesMatching`][Jar.filesMatching] to override the strategy for specific files.
88
-
- Keep `duplicatesStrategy = INCLUDE` and write your own [`ResourceTransformer`][ResourceTransformer] to handle duplicates.
89
-
90
-
If you just want to keep the current behavior and preserve the first found resources, there is a simple built-in one
91
-
called [`PreserveFirstFoundResourceTransformer`][PreserveFirstFoundResourceTransformer].
85
+
1. Set the strategy to `INCLUDE` or `WARN`.
86
+
2. Apply your [`ResourceTransformer`][ResourceTransformer]s.
87
+
3. Remove duplicate entries by
88
+
- overriding the default strategy for specific files using [`filesMatching`][Jar.filesMatching]
Copy file name to clipboardExpand all lines: src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ServiceFileTransformerTest.kt
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -230,6 +230,7 @@ class ServiceFileTransformerTest : BaseTransformerTest() {
0 commit comments