diff --git a/api/shadow.api b/api/shadow.api index c73a61e14..e9bb98b26 100644 --- a/api/shadow.api +++ b/api/shadow.api @@ -83,7 +83,7 @@ public class com/github/jengelman/gradle/plugins/shadow/ShadowStats { } public class com/github/jengelman/gradle/plugins/shadow/impl/RelocatorRemapper : org/objectweb/asm/commons/Remapper { - public fun (Ljava/util/List;Lcom/github/jengelman/gradle/plugins/shadow/ShadowStats;)V + public fun (Ljava/util/Set;Lcom/github/jengelman/gradle/plugins/shadow/ShadowStats;)V public fun hasRelocators ()Z public fun map (Ljava/lang/String;)Ljava/lang/String; public fun mapPath (Lcom/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction$RelativeArchivePath;)Ljava/lang/String; @@ -245,7 +245,7 @@ public final class com/github/jengelman/gradle/plugins/shadow/tasks/KnowsTask$Co public class com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction : org/gradle/api/internal/file/copy/CopyAction { public static final field Companion Lcom/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction$Companion; - public fun (Ljava/io/File;Lcom/github/jengelman/gradle/plugins/shadow/internal/ZipCompressor;Lorg/gradle/api/internal/DocumentationRegistry;Ljava/lang/String;Ljava/util/List;Ljava/util/List;Lorg/gradle/api/tasks/util/PatternSet;Lcom/github/jengelman/gradle/plugins/shadow/ShadowStats;ZZ)V + public fun (Ljava/io/File;Lcom/github/jengelman/gradle/plugins/shadow/internal/ZipCompressor;Lorg/gradle/api/internal/DocumentationRegistry;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;Lorg/gradle/api/tasks/util/PatternSet;Lcom/github/jengelman/gradle/plugins/shadow/ShadowStats;ZZ)V public fun execute (Lorg/gradle/api/internal/file/copy/CopyActionProcessingStream;)Lorg/gradle/api/tasks/WorkResult; } @@ -302,7 +302,7 @@ public abstract class com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar public fun dependencies (Lorg/gradle/api/Action;)Lcom/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar; public synthetic fun dependencies (Lorg/gradle/api/Action;)Lcom/github/jengelman/gradle/plugins/shadow/tasks/ShadowSpec; public fun getApiJars ()Lorg/gradle/api/file/ConfigurableFileCollection; - public fun getConfigurations ()Lorg/gradle/api/provider/ListProperty; + public fun getConfigurations ()Lorg/gradle/api/provider/SetProperty; public fun getDependencyFilter ()Lorg/gradle/api/provider/Property; public fun getEnableRelocation ()Lorg/gradle/api/provider/Property; public fun getIncludedDependencies ()Lorg/gradle/api/file/ConfigurableFileCollection; @@ -311,12 +311,12 @@ public abstract class com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar public synthetic fun getManifest ()Lorg/gradle/api/java/archives/Manifest; public fun getMinimizeJar ()Lorg/gradle/api/provider/Property; public fun getRelocationPrefix ()Lorg/gradle/api/provider/Property; - public fun getRelocators ()Lorg/gradle/api/provider/ListProperty; + public fun getRelocators ()Lorg/gradle/api/provider/SetProperty; protected fun getRootPatternSet ()Lorg/gradle/api/tasks/util/PatternSet; public fun getSourceSetsClassesDirs ()Lorg/gradle/api/file/ConfigurableFileCollection; public fun getStats ()Lcom/github/jengelman/gradle/plugins/shadow/ShadowStats; public fun getToMinimize ()Lorg/gradle/api/file/ConfigurableFileCollection; - public fun getTransformers ()Lorg/gradle/api/provider/ListProperty; + public fun getTransformers ()Lorg/gradle/api/provider/SetProperty; public fun mergeGroovyExtensionModules ()Lcom/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar; public synthetic fun mergeGroovyExtensionModules ()Lcom/github/jengelman/gradle/plugins/shadow/tasks/ShadowSpec; public fun mergeServiceFiles ()Lcom/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar; @@ -465,7 +465,7 @@ public class com/github/jengelman/gradle/plugins/shadow/transformers/ManifestApp public fun (Lorg/gradle/api/model/ObjectFactory;)V public fun append (Ljava/lang/String;Ljava/lang/Comparable;)Lcom/github/jengelman/gradle/plugins/shadow/transformers/ManifestAppenderTransformer; public fun canTransformResource (Lorg/gradle/api/file/FileTreeElement;)Z - public fun getAttributes ()Lorg/gradle/api/provider/ListProperty; + public fun getAttributes ()Lorg/gradle/api/provider/SetProperty; public final fun getObjectFactory ()Lorg/gradle/api/model/ObjectFactory; public fun hasTransformedResource ()Z public fun modifyOutputStream (Lorg/apache/tools/zip/ZipOutputStream;Z)V @@ -501,7 +501,7 @@ public class com/github/jengelman/gradle/plugins/shadow/transformers/PropertiesF public fun getMergeSeparator ()Lorg/gradle/api/provider/Property; public fun getMergeStrategy ()Lorg/gradle/api/provider/Property; public final fun getObjectFactory ()Lorg/gradle/api/model/ObjectFactory; - public fun getPaths ()Lorg/gradle/api/provider/ListProperty; + public fun getPaths ()Lorg/gradle/api/provider/SetProperty; public fun hasTransformedResource ()Z public fun modifyOutputStream (Lorg/apache/tools/zip/ZipOutputStream;Z)V public fun transform (Lcom/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext;)V @@ -574,21 +574,21 @@ public final class com/github/jengelman/gradle/plugins/shadow/transformers/Trans public final class com/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext { public static final field Companion Lcom/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext$Companion; public fun (Ljava/lang/String;Ljava/io/InputStream;)V - public fun (Ljava/lang/String;Ljava/io/InputStream;Ljava/util/List;)V - public fun (Ljava/lang/String;Ljava/io/InputStream;Ljava/util/List;Lcom/github/jengelman/gradle/plugins/shadow/ShadowStats;)V - public synthetic fun (Ljava/lang/String;Ljava/io/InputStream;Ljava/util/List;Lcom/github/jengelman/gradle/plugins/shadow/ShadowStats;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ljava/lang/String;Ljava/io/InputStream;Ljava/util/Set;)V + public fun (Ljava/lang/String;Ljava/io/InputStream;Ljava/util/Set;Lcom/github/jengelman/gradle/plugins/shadow/ShadowStats;)V + public synthetic fun (Ljava/lang/String;Ljava/io/InputStream;Ljava/util/Set;Lcom/github/jengelman/gradle/plugins/shadow/ShadowStats;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public static final fun builder ()Lcom/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext$Builder; public final fun component1 ()Ljava/lang/String; public final fun component2 ()Ljava/io/InputStream; - public final fun component3 ()Ljava/util/List; + public final fun component3 ()Ljava/util/Set; public final fun component4 ()Lcom/github/jengelman/gradle/plugins/shadow/ShadowStats; - public final fun copy (Ljava/lang/String;Ljava/io/InputStream;Ljava/util/List;Lcom/github/jengelman/gradle/plugins/shadow/ShadowStats;)Lcom/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext; - public static synthetic fun copy$default (Lcom/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext;Ljava/lang/String;Ljava/io/InputStream;Ljava/util/List;Lcom/github/jengelman/gradle/plugins/shadow/ShadowStats;ILjava/lang/Object;)Lcom/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext; + public final fun copy (Ljava/lang/String;Ljava/io/InputStream;Ljava/util/Set;Lcom/github/jengelman/gradle/plugins/shadow/ShadowStats;)Lcom/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext; + public static synthetic fun copy$default (Lcom/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext;Ljava/lang/String;Ljava/io/InputStream;Ljava/util/Set;Lcom/github/jengelman/gradle/plugins/shadow/ShadowStats;ILjava/lang/Object;)Lcom/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext; public fun equals (Ljava/lang/Object;)Z public static final fun getEntryTimestamp (ZJ)J public final fun getInputStream ()Ljava/io/InputStream; public final fun getPath ()Ljava/lang/String; - public final fun getRelocators ()Ljava/util/List; + public final fun getRelocators ()Ljava/util/Set; public final fun getStats ()Lcom/github/jengelman/gradle/plugins/shadow/ShadowStats; public fun hashCode ()I public fun toString ()Ljava/lang/String; @@ -599,7 +599,7 @@ public final class com/github/jengelman/gradle/plugins/shadow/transformers/Trans public final fun build ()Lcom/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext; public final fun inputStream (Ljava/io/InputStream;)Lcom/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext$Builder; public final fun path (Ljava/lang/String;)Lcom/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext$Builder; - public final fun relocators (Ljava/util/List;)Lcom/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext$Builder; + public final fun relocators (Ljava/util/Set;)Lcom/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext$Builder; public final fun stats (Lcom/github/jengelman/gradle/plugins/shadow/ShadowStats;)Lcom/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext$Builder; } diff --git a/src/docs/changes/README.md b/src/docs/changes/README.md index 63dc6b7f8..96e83d9d9 100644 --- a/src/docs/changes/README.md +++ b/src/docs/changes/README.md @@ -7,6 +7,11 @@ - Sync `SimpleRelocator` changes from maven-shade-plugin. ([#1076](https://github.com/GradleUp/shadow/pull/1076)) +**Changed** + +- **BREAKING CHANGE:** Migrate all `ListProperty` usages to `SetProperty`. ([#1103](https://github.com/GradleUp/shadow/pull/1103)) + Some public `List` parameters are also changed to `Set`. + ## [v9.0.0-beta4] (2024-12-06) diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/impl/RelocatorRemapper.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/impl/RelocatorRemapper.kt index 92ddede28..9337a3643 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/impl/RelocatorRemapper.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/impl/RelocatorRemapper.kt @@ -15,7 +15,7 @@ import org.objectweb.asm.commons.Remapper * @author John Engelman */ public open class RelocatorRemapper( - private val relocators: List, + private val relocators: Set, private val stats: ShadowStats, ) : Remapper() { private val classPattern: Pattern = Pattern.compile("(\\[*)?L(.+)") diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.kt index 657b1ab17..b16de7ec8 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.kt @@ -44,8 +44,8 @@ public open class ShadowCopyAction internal constructor( private val compressor: ZipCompressor, private val documentationRegistry: DocumentationRegistry, private val encoding: String?, - private val transformers: List, - private val relocators: List, + private val transformers: Set, + private val relocators: Set, private val patternSet: PatternSet, private val stats: ShadowStats, private val preserveFileTimestamps: Boolean, @@ -58,8 +58,8 @@ public open class ShadowCopyAction internal constructor( compressor: ZipCompressor, documentationRegistry: DocumentationRegistry, encoding: String?, - transformers: List, - relocators: List, + transformers: Set, + relocators: Set, patternSet: PatternSet, stats: ShadowStats, preserveFileTimestamps: Boolean, @@ -166,8 +166,8 @@ public open class ShadowCopyAction internal constructor( private inner class StreamAction( private val zipOutStr: ZipOutputStream, encoding: String?, - private val transformers: List, - private val relocators: List, + private val transformers: Set, + private val relocators: Set, private val patternSet: PatternSet, private val unused: Set, private val stats: ShadowStats, diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.kt index 4eebe0a0a..f494e07ba 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.kt @@ -31,8 +31,8 @@ import org.gradle.api.internal.DocumentationRegistry import org.gradle.api.internal.file.FileResolver import org.gradle.api.internal.file.copy.CopyAction import org.gradle.api.internal.file.copy.DefaultCopySpec -import org.gradle.api.provider.ListProperty import org.gradle.api.provider.Property +import org.gradle.api.provider.SetProperty import org.gradle.api.tasks.CacheableTask import org.gradle.api.tasks.Classpath import org.gradle.api.tasks.Input @@ -113,14 +113,14 @@ public abstract class ShadowJar : } @get:Nested - public open val transformers: ListProperty = objectFactory.property() + public open val transformers: SetProperty = objectFactory.property() @get:Nested - public open val relocators: ListProperty = objectFactory.property() + public open val relocators: SetProperty = objectFactory.property() @get:Classpath @get:Optional - public open val configurations: ListProperty = objectFactory.property() + public open val configurations: SetProperty = objectFactory.property() @get:Internal public open val dependencyFilter: Property = @@ -294,8 +294,8 @@ public abstract class ShadowJar : if (!enableRelocation.get()) return emptyList() val prefix = relocationPrefix.get() - // Must cast configurations to List to fix type mismatch in runtime. - return (configurations.get() as List).flatMap { configuration -> + // Must cast configurations to Set to fix type mismatch in runtime. + return (configurations.get() as Set).flatMap { configuration -> configuration.files.flatMap { file -> JarFile(file).use { jarFile -> jarFile.entries().toList() diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ManifestAppenderTransformer.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ManifestAppenderTransformer.kt index 30d57be4f..a2d906c72 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ManifestAppenderTransformer.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ManifestAppenderTransformer.kt @@ -9,7 +9,7 @@ import org.apache.tools.zip.ZipEntry import org.apache.tools.zip.ZipOutputStream import org.gradle.api.file.FileTreeElement import org.gradle.api.model.ObjectFactory -import org.gradle.api.provider.ListProperty +import org.gradle.api.provider.SetProperty import org.gradle.api.tasks.Input import org.slf4j.LoggerFactory @@ -27,7 +27,7 @@ public open class ManifestAppenderTransformer @Inject constructor( private var manifestContents = ByteArray(0) @get:Input - public open val attributes: ListProperty>> = objectFactory.property() + public open val attributes: SetProperty>> = objectFactory.property() override fun canTransformResource(element: FileTreeElement): Boolean { return MANIFEST_NAME.equals(element.relativePath.pathString, ignoreCase = true) diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/PropertiesFileTransformer.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/PropertiesFileTransformer.kt index 9d23aaefd..65c259225 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/PropertiesFileTransformer.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/PropertiesFileTransformer.kt @@ -14,9 +14,9 @@ import org.apache.tools.zip.ZipEntry import org.apache.tools.zip.ZipOutputStream import org.gradle.api.file.FileTreeElement import org.gradle.api.model.ObjectFactory -import org.gradle.api.provider.ListProperty import org.gradle.api.provider.MapProperty import org.gradle.api.provider.Property +import org.gradle.api.provider.SetProperty import org.gradle.api.tasks.Input import org.gradle.api.tasks.Internal @@ -107,7 +107,7 @@ public open class PropertiesFileTransformer @Inject constructor( internal val propertiesEntries = mutableMapOf() @get:Input - public open val paths: ListProperty = objectFactory.property() + public open val paths: SetProperty = objectFactory.property() @get:Input public open val mappings: MapProperty> = objectFactory.property() diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext.kt index 3bb9b1351..cefd226a0 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext.kt @@ -8,18 +8,18 @@ import java.io.InputStream public data class TransformerContext @JvmOverloads constructor( val path: String, val inputStream: InputStream, - val relocators: List = emptyList(), + val relocators: Set = emptySet(), val stats: ShadowStats = ShadowStats(), ) { public class Builder { private var path = "" private var inputStream: InputStream? = null - private var relocators = emptyList() + private var relocators = emptySet() private var stats = ShadowStats() public fun path(path: String): Builder = apply { this.path = path } public fun inputStream(inputStream: InputStream): Builder = apply { this.inputStream = inputStream } - public fun relocators(relocators: List): Builder = apply { this.relocators = relocators } + public fun relocators(relocators: Set): Builder = apply { this.relocators = relocators } public fun stats(stats: ShadowStats): Builder = apply { this.stats = stats } public fun build(): TransformerContext = TransformerContext( path = path, diff --git a/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/Log4j2PluginsCacheFileTransformerTest.kt b/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/Log4j2PluginsCacheFileTransformerTest.kt index 1b933940d..f411b33a4 100644 --- a/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/Log4j2PluginsCacheFileTransformerTest.kt +++ b/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/Log4j2PluginsCacheFileTransformerTest.kt @@ -47,7 +47,7 @@ class Log4j2PluginsCacheFileTransformerTest : BaseTransformerTest