diff --git a/build.gradle.kts b/build.gradle.kts index 262fa1a22..786c6f381 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -80,6 +80,8 @@ tasks.withType().configureEach { maxHeapSize = "1g" } + // Add src/docs as an input directory to trigger ManualCodeSnippetTests re-run on changes. + inputs.dir(file("src/docs")) systemProperty("shadowVersion", version) // Required to test configuration cache in tests when using withDebug() diff --git a/src/docs/changes/README.md b/src/docs/changes/README.md index bdc8c1d01..b22c2b02b 100644 --- a/src/docs/changes/README.md +++ b/src/docs/changes/README.md @@ -3,6 +3,10 @@ ## [Unreleased] +**Added** + +- Add .md support to the Apache License and Notice transformers. ([#1041](https://github.com/GradleUp/shadow/pull/1041)) + **Changed** - **BREAKING CHANGE:** Rewrite this plugin in Kotlin. ([#1012](https://github.com/GradleUp/shadow/pull/1012)) @@ -11,6 +15,10 @@ - **BREAKING CHANGE:** Remove Develocity integration. ([#1013](https://github.com/GradleUp/shadow/pull/1013)) +**Fixed** + +- Fix single Log4j2Plugins.dat isn't included into fat jar. ([#1039](https://github.com/GradleUp/shadow/issues/1039)). + ## [v8.3.5] (2024-11-03) diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowApplicationPlugin.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowApplicationPlugin.kt index 54f064bb8..d788a9b75 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowApplicationPlugin.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowApplicationPlugin.kt @@ -98,11 +98,9 @@ public abstract class ShadowApplicationPlugin : Plugin { } } task.doLast { - task.eachFile { details -> - if (details.path == "bin/${applicationName.get()}") { - details.permissions { - it.unix(755) - } + task.eachFile { + if (it.path == "bin/${applicationName.get()}") { + it.permissions { permissions -> permissions.unix(755) } } } } diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ApacheLicenseResourceTransformer.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ApacheLicenseResourceTransformer.kt index e58350ae5..67d4155ad 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ApacheLicenseResourceTransformer.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ApacheLicenseResourceTransformer.kt @@ -3,9 +3,9 @@ package com.github.jengelman.gradle.plugins.shadow.transformers import org.gradle.api.file.FileTreeElement /** - * Prevents duplicate copies of the license + * Prevents duplicate copies of the license. * - * Modified from `org.apache.maven.plugins.shade.resouce.ApacheLicenseResourceTransformer.java` + * Modified from [org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer.java](https://github.com/apache/maven-shade-plugin/blob/master/src/main/java/org/apache/maven/plugins/shade/resource/ApacheLicenseResourceTransformer.java). * * @author John Engelman */ @@ -13,11 +13,13 @@ public open class ApacheLicenseResourceTransformer : Transformer by NoOpTransfor override fun canTransformResource(element: FileTreeElement): Boolean { val path = element.relativePath.pathString return LICENSE_PATH.equals(path, ignoreCase = true) || - LICENSE_TXT_PATH.regionMatches(0, path, 0, LICENSE_TXT_PATH.length, ignoreCase = true) + LICENSE_TXT_PATH.regionMatches(0, path, 0, LICENSE_TXT_PATH.length, ignoreCase = true) || + LICENSE_MD_PATH.regionMatches(0, path, 0, LICENSE_MD_PATH.length, ignoreCase = true) } private companion object { private const val LICENSE_PATH = "META-INF/LICENSE" private const val LICENSE_TXT_PATH = "META-INF/LICENSE.txt" + private const val LICENSE_MD_PATH = "META-INF/LICENSE.md" } } diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ApacheNoticeResourceTransformer.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ApacheNoticeResourceTransformer.kt index f58860e53..fa394e718 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ApacheNoticeResourceTransformer.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ApacheNoticeResourceTransformer.kt @@ -19,7 +19,7 @@ import org.gradle.api.tasks.Optional /** * Merges `META-INF/NOTICE.TXT` files. * - * Modified from `org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer.java` + * Modified from [org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer.java](https://github.com/apache/maven-shade-plugin/blob/master/src/main/java/org/apache/maven/plugins/shade/resource/ApacheNoticeResourceTransformer.java). * * @author John Engelman */ @@ -76,7 +76,9 @@ public open class ApacheNoticeResourceTransformer @Inject constructor( override fun canTransformResource(element: FileTreeElement): Boolean { val path = element.relativePath.pathString - return NOTICE_PATH.equals(path, ignoreCase = true) || NOTICE_TXT_PATH.equals(path, ignoreCase = true) + return NOTICE_PATH.equals(path, ignoreCase = true) || + NOTICE_TXT_PATH.equals(path, ignoreCase = true) || + NOTICE_MD_PATH.equals(path, ignoreCase = true) } override fun transform(context: TransformerContext) { @@ -184,5 +186,6 @@ public open class ApacheNoticeResourceTransformer @Inject constructor( private companion object { private const val NOTICE_PATH = "META-INF/NOTICE" private const val NOTICE_TXT_PATH = "META-INF/NOTICE.txt" + private const val NOTICE_MD_PATH = "META-INF/NOTICE.md" } } diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/AppendingTransformer.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/AppendingTransformer.kt index ca620746b..dcef14823 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/AppendingTransformer.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/AppendingTransformer.kt @@ -14,9 +14,8 @@ import org.gradle.api.tasks.Optional /** * A resource processor that appends content for a resource, separated by a newline. * - * Modified from `org.apache.maven.plugins.shade.resource.AppendingTransformer.java` + * Modified from [org.apache.maven.plugins.shade.resource.AppendingTransformer.java](https://github.com/apache/maven-shade-plugin/blob/master/src/main/java/org/apache/maven/plugins/shade/resource/AppendingTransformer.java). * - * Modifications * @author John Engelman */ @CacheableTransformer diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ComponentsXmlResourceTransformer.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ComponentsXmlResourceTransformer.kt index b917d47b8..345cfaa44 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ComponentsXmlResourceTransformer.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ComponentsXmlResourceTransformer.kt @@ -17,7 +17,7 @@ import org.gradle.api.file.FileTreeElement /** * A resource processor that aggregates plexus `components.xml` files. * - * Modified from `org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer.java` + * Modified from [org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer.java](https://github.com/apache/maven-shade-plugin/blob/master/src/main/java/org/apache/maven/plugins/shade/resource/ComponentsXmlResourceTransformer.java). * * @author John Engelman */ diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/DontIncludeResourceTransformer.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/DontIncludeResourceTransformer.kt index bc3ee2346..e39a30a04 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/DontIncludeResourceTransformer.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/DontIncludeResourceTransformer.kt @@ -7,7 +7,7 @@ import org.gradle.api.tasks.Optional /** * A resource processor that prevents the inclusion of an arbitrary resource into the shaded JAR. * - * Modified from `org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer.java` + * Modified from [org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer.java](https://github.com/apache/maven-shade-plugin/blob/master/src/main/java/org/apache/maven/plugins/shade/resource/DontIncludeResourceTransformer.java). * * @author John Engelman */ diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/GroovyExtensionModuleTransformer.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/GroovyExtensionModuleTransformer.kt index 36d3258c3..d0884e210 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/GroovyExtensionModuleTransformer.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/GroovyExtensionModuleTransformer.kt @@ -10,7 +10,7 @@ import org.apache.tools.zip.ZipOutputStream import org.gradle.api.file.FileTreeElement /** - * Modified from `eu.appsatori.gradle.fatjar.tasks.PrepareFiles.groovy` + * Aggregate Apache Groovy extension modules descriptors. * * Resource transformer that merges Groovy extension module descriptor files into a single file. * Groovy extension module descriptor files have the name org.codehaus.groovy.runtime.ExtensionModule @@ -23,6 +23,9 @@ import org.gradle.api.file.FileTreeElement * It will live in the legacy directory (META-INF/services) if all the processed descriptor * files came from the legacy location, otherwise it will be written into the now standard location (META-INF/groovy). * Note that certain JDK9+ tooling will break when using the legacy location. + * + * Modified from [eu.appsatori.gradle.fatjar.tasks.PrepareFiles.groovy](https://github.com/musketyr/gradle-fatjar-plugin/blob/master/src/main/groovy/eu/appsatori/gradle/fatjar/tasks/PrepareFiles.groovy). + * Related to [org.apache.maven.plugins.shade.resource.GroovyResourceTransformer.java](https://github.com/apache/maven-shade-plugin/blob/master/src/main/java/org/apache/maven/plugins/shade/resource/GroovyResourceTransformer.java). */ @CacheableTransformer public open class GroovyExtensionModuleTransformer : Transformer { diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/IncludeResourceTransformer.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/IncludeResourceTransformer.kt index 3d5315ef3..14f20385c 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/IncludeResourceTransformer.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/IncludeResourceTransformer.kt @@ -10,10 +10,9 @@ import org.gradle.api.tasks.PathSensitive import org.gradle.api.tasks.PathSensitivity /** - * A resource processor that allows the addition of an arbitrary file - * content into the shaded JAR. + * A resource processor that allows the addition of an arbitrary file content into the shaded JAR. * - * Modified from `org.apache.maven.plugins.shade.resource.IncludeResourceTransformer.java` + * Modified from [org.apache.maven.plugins.shade.resource.IncludeResourceTransformer.java](https://github.com/apache/maven-shade-plugin/blob/master/src/main/java/org/apache/maven/plugins/shade/resource/IncludeResourceTransformer.java). * * @author John Engelman */ diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/Log4j2PluginsCacheFileTransformer.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/Log4j2PluginsCacheFileTransformer.kt index 5fcb1d25d..ad1769630 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/Log4j2PluginsCacheFileTransformer.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/Log4j2PluginsCacheFileTransformer.kt @@ -18,10 +18,10 @@ import org.gradle.api.file.FileTreeElement /** * Modified from the maven equivalent to work with gradle * + * Modified from [org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer.java](https://github.com/apache/logging-log4j-transform/blob/main/log4j-transform-maven-shade-plugin-extensions/src/main/java/org/apache/logging/log4j/maven/plugins/shade/transformer/Log4j2PluginCacheFileTransformer.java). + * * @author Paul Nelson Baker - * @see [LinkedIn](https://www.linkedin.com/in/paul-n-baker/) - * @see [GitHub](https://github.com/paul-nelson-baker/) - * @see [PluginsCacheFileTransformer.java](https://github.com/edwgiz/maven-shaded-log4j-transformer/blob/master/src/main/java/com/github/edwgiz/mavenShadePlugin/log4j2CacheTransformer/PluginsCacheFileTransformer.java) + * @author John Engelman */ @CacheableTransformer public open class Log4j2PluginsCacheFileTransformer : Transformer { @@ -53,9 +53,7 @@ public open class Log4j2PluginsCacheFileTransformer : Transformer { // This functionality matches the original plugin, however, I'm not clear what // the exact logic is. From what I can tell temporaryFiles should be never be empty // if anything has been performed. - val hasTransformedMultipleFiles = temporaryFiles.size > 1 - val hasAtLeastOneFileAndRelocator = temporaryFiles.isNotEmpty() && relocators.isNotEmpty() - return hasTransformedMultipleFiles || hasAtLeastOneFileAndRelocator + return temporaryFiles.isNotEmpty() || relocators.isNotEmpty() } override fun modifyOutputStream(os: ZipOutputStream, preserveFileTimestamps: Boolean) { diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ManifestResourceTransformer.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ManifestResourceTransformer.kt index c65d0bf2a..bc03988fc 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ManifestResourceTransformer.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ManifestResourceTransformer.kt @@ -17,7 +17,7 @@ import org.slf4j.LoggerFactory * the first MANIFEST.MF that is found in the set of JARs being processed, or * to a newly created manifest for the shaded JAR. * - * Modified from `org.apache.maven.plugins.shade.resource.ManifestResourceTransformer` + * Modified from [org.apache.maven.plugins.shade.resource.ManifestResourceTransformer.java](https://github.com/apache/maven-shade-plugin/blob/master/src/main/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformer.java). * * @author Jason van Zyl * @author John Engelman 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 48844066f..79208cfd5 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 @@ -86,6 +86,8 @@ import org.gradle.api.tasks.Internal * } * ``` * + * Related to [org.apache.maven.plugins.shade.resource.properties.PropertiesTransformer.java](https://github.com/apache/maven-shade-plugin/blob/master/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java). + * * @author Andres Almiray * @author Marc Philipp */ diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ServiceFileTransformer.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ServiceFileTransformer.kt index 112e5e734..6d26c2a99 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ServiceFileTransformer.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ServiceFileTransformer.kt @@ -15,14 +15,14 @@ import org.gradle.api.tasks.util.PatternFilterable import org.gradle.api.tasks.util.PatternSet /** - * Modified from `org.apache.maven.plugins.shade.resource.ServiceResourceTransformer.java` - * * Resources transformer that appends entries in `META-INF/services` resources into * a single resource. For example, if there are several `META-INF/services/org.apache.maven.project.ProjectBuilder` * resources spread across many JARs the individual entries will all be concatenated into a single * `META-INF/services/org.apache.maven.project.ProjectBuilder` resource packaged into the resultant JAR produced * by the shading process. * + * Modified from [org.apache.maven.plugins.shade.resource.ServicesResourceTransformer.java](https://github.com/apache/maven-shade-plugin/blob/master/src/main/java/org/apache/maven/plugins/shade/resource/ServicesResourceTransformer.java). + * * @author jvanzyl * @author Charlie Knudsen * @author John Engelman diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/Transformer.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/Transformer.kt index e862f8d10..0a1c76f63 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/Transformer.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/Transformer.kt @@ -7,7 +7,7 @@ import org.gradle.api.model.ObjectFactory import org.gradle.api.tasks.Internal /** - * Modified from `org.apache.maven.plugins.shade.resource.ResourceTransformer.java` + * Modified from [org.apache.maven.plugins.shade.resource.ResourceTransformer.java](https://github.com/apache/maven-shade-plugin/blob/master/src/main/java/org/apache/maven/plugins/shade/resource/ResourceTransformer.java). * * @author Jason van Zyl * @author Charlie Knudsen diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/XmlAppendingTransformer.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/XmlAppendingTransformer.kt index e9fc642df..9694517d3 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/XmlAppendingTransformer.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/XmlAppendingTransformer.kt @@ -18,7 +18,7 @@ import org.xml.sax.InputSource /** * Appends multiple occurrences of some XML file. * - * Modified from `org.apache.maven.plugins.shade.resource.XmlAppendingTransformer.java` + * Modified from [org.apache.maven.plugins.shade.resource.XmlAppendingTransformer.java](https://github.com/apache/maven-shade-plugin/blob/master/src/main/java/org/apache/maven/plugins/shade/resource/XmlAppendingTransformer.java). * * @author John Engelman */ diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/transformers/ApacheLicenseResourceTransformerTest.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/transformers/ApacheLicenseResourceTransformerTest.groovy index 59a6c62dc..589f2afc3 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/transformers/ApacheLicenseResourceTransformerTest.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/transformers/ApacheLicenseResourceTransformerTest.groovy @@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.* * @author Benjamin Bentmann * @version $Id: ApacheLicenseResourceTransformerTest.java 673906 2008-07-04 05:03:20Z brett $ * - * Modified from org.apache.maven.plugins.shade.resources.ApacheLicenseResourceTransformerTest.java + * Modified from org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformerTest.java */ class ApacheLicenseResourceTransformerTest extends TransformerTestSupport { @@ -52,6 +52,8 @@ class ApacheLicenseResourceTransformerTest extends TransformerTestSupport