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
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.
83
+
84
+
Want [`ResourceTransformer`][ResourceTransformer]s and `duplicatesStrategy` to work together? There are several ways to
85
+
do it:
86
+
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].
92
+
17
93
## Basic ResourceTransformer Usage
18
94
19
95
For simpler use cases, you can create a basic transformer:
@@ -360,81 +436,6 @@ It must be added using the [`transform`][ShadowJar.transform] methods.
360
436
}
361
437
```
362
438
363
-
## Handling Duplicates Strategy
364
-
365
-
`ShadowJar` is a subclass of [`org.gradle.api.tasks.AbstractCopyTask`][AbstractCopyTask], which means it honors the
366
-
`duplicatesStrategy` property as its parent classes do. There are several strategies to handle:
367
-
368
-
-`EXCLUDE`: Do not allow duplicates by ignoring subsequent items to be created at the same path.
369
-
-`FAIL`: Throw a `DuplicateFileCopyingException` when subsequent items are to be created at the same path.
370
-
-`INCLUDE`: Do not attempt to prevent duplicates.
371
-
-`INHERIT`: Uses the same strategy as the parent copy specification.
372
-
-`WARN`: Do not attempt to prevent duplicates, but log a warning message when multiple items are to be created at the
373
-
same path.
374
-
375
-
see more details about them in [`DuplicatesStrategy`][DuplicatesStrategy].
376
-
377
-
`ShadowJar` recognizes `DuplicatesStrategy.INCLUDE` as the default, if you want to change the strategy, you can
378
-
override it like:
379
-
380
-
=== "Kotlin"
381
-
382
-
```kotlin
383
-
tasks.shadowJar {
384
-
duplicatesStrategy = DuplicatesStrategy.EXCLUDE // Or something else.
The [`ResourceTransformer`][ResourceTransformer]s like [`ServiceFileTransformer`][ServiceFileTransformer] will not work
427
-
as expected because the `duplicatesStrategy` will exclude the duplicate service files beforehand. However, this behavior might be what you expected for duplicate
428
-
`foo/bar` files, preventing them from being included.
429
-
430
-
Want [`ResourceTransformer`][ResourceTransformer]s and `duplicatesStrategy` to work together? There are several ways to
431
-
do it:
432
-
433
-
- Use [`filesMatching`][Jar.filesMatching] to override the strategy for specific files.
434
-
- Keep `duplicatesStrategy = INCLUDE` and write your own [`ResourceTransformer`][ResourceTransformer] to handle duplicates.
435
-
436
-
If you just want to keep the current behavior and preserve the first found resources, there is a simple built-in one
437
-
called [`PreserveFirstFoundResourceTransformer`][PreserveFirstFoundResourceTransformer].
0 commit comments