getDuplicatesStrategy

open override fun getDuplicatesStrategy(): DuplicatesStrategy

Returns the strategy to use when trying to copy more than one file to the same destination.

This global strategy can be overridden for individual files by using filesMatching.

The default value is EXCLUDE. Different strategies will lead to different results for foo/bar files in the JARs to be merged:

  • EXCLUDE: The first foo/bar file will be included in the final JAR.

  • FAIL: Fail the build with a DuplicateFileCopyingException if there are duplicate foo/bar files.

  • INCLUDE: Duplicate foo/bar entries will be included in the final JAR.

  • INHERIT: Fail the build with an exception like Entry .* is a duplicate but no duplicate handling strategy has been set.

  • WARN: Warn about duplicates in the build log, this behaves exactly as INHERIT otherwise.

NOTE: The strategy takes precedence over transforming and relocating. Some ResourceTransformers like ServiceFileTransformer will not work as expected with setting the strategy to EXCLUDE (the default), as the duplicate resource files fed for them are excluded beforehand. Want ResourceTransformers and the strategy to work together? See more details in the Handling Duplicates Strategy section.

See also

AbstractCopyTask.eachFile
AbstractCopyTask.filesMatching
AbstractCopyTask.filesNotMatching
DuplicatesStrategy
CopySpec.getDuplicatesStrategy