PreserveFirstFoundResourceTransformer

open class PreserveFirstFoundResourceTransformer(val objectFactory: ObjectFactory, patternSet: PatternSet) : PatternFilterableResourceTransformer

A resource processor that preserves the first resource matched and excludes all others.

This is useful when you set shadowJar.duplicatesStrategy = DuplicatesStrategy.INCLUDE (the default behavior) and want to ensure that only the first found resource is included in the final JAR. If there are multiple resources with the same path in a project and its dependencies, the first one found should be the project's.

This transformer deduplicates included resources based on the path name. See DeduplicatingResourceTransformer for a transformer that deduplicates based on the paths and contents of the resources.

Warning Do not combine DeduplicatingResourceTransformer with this transformer, as they handle duplicates differently and combining them would lead to redundant or unexpected behavior.

See also

Constructors

Link copied to clipboard
constructor(objectFactory: ObjectFactory, patternSet: PatternSet)
@Inject
constructor(objectFactory: ObjectFactory)

Properties

Link copied to clipboard
@get:Input
open override val excludes: MutableSet<String>
Link copied to clipboard
@get:Input
open override val includes: MutableSet<String>
Link copied to clipboard
@get:Internal
open override val name: String
Link copied to clipboard
override val objectFactory: ObjectFactory

This is used for creating Gradle's lazy properties in the subclass, Shadow's build-in transformers that depend on this have been injected via ObjectFactory.newInstance. Custom transformers should implement or inject this property if they need to access it.

Link copied to clipboard
@Internal
val patternSet: PatternSet
Link copied to clipboard
@get:Input
open val resources: SetProperty<String>

Functions

Link copied to clipboard
open override fun canTransformResource(element: FileTreeElement): Boolean
Link copied to clipboard
open override fun exclude(excludeSpec: Closure<*>): PatternFilterable
open override fun exclude(vararg excludes: String): PatternFilterable
open override fun exclude(excludes: Iterable<String>): PatternFilterable
open override fun exclude(excludeSpec: Spec<FileTreeElement>): PatternFilterable
Link copied to clipboard
@Input
open override fun getExcludes(): MutableSet<String>
Link copied to clipboard
@Input
open override fun getIncludes(): MutableSet<String>
Link copied to clipboard
@Internal
open override fun getName(): String
Link copied to clipboard
open override fun hasTransformedResource(): Boolean
Link copied to clipboard
open override fun include(includeSpec: Closure<*>): PatternFilterable
open override fun include(vararg includes: String): PatternFilterable
open override fun include(includes: Iterable<String>): PatternFilterable
open override fun include(includeSpec: Spec<FileTreeElement>): PatternFilterable
Link copied to clipboard
open override fun modifyOutputStream(os: ZipOutputStream, preserveFileTimestamps: Boolean)
Link copied to clipboard
open override fun setExcludes(excludes: Iterable<String>): PatternFilterable
Link copied to clipboard
open override fun setIncludes(includes: Iterable<String>): PatternFilterable
Link copied to clipboard
open override fun transform(context: TransformerContext)