diff --git a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/JavaPluginsTest.kt b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/JavaPluginsTest.kt index fa505c589..77a13bd40 100644 --- a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/JavaPluginsTest.kt +++ b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/JavaPluginsTest.kt @@ -417,16 +417,8 @@ class JavaPluginsTest : BasePluginTest() { .trimMargin() ) - val result = runWithSuccess(serverShadowJarPath, infoArgument) + runWithSuccess(serverShadowJarPath) - assertThat(result.output) - .contains( - if (addAttribute) { - "Adding Multi-Release attribute to the manifest if any dependencies contain it." - } else { - "Skipping adding Multi-Release attribute to the manifest as it is disabled." - } - ) assertThat(outputServerShadowedJar.use { it.getMainAttr(multiReleaseAttributeKey) }) .isEqualTo(if (addAttribute) "true" else null) } diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowPlugin.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowPlugin.kt index 27bb8dd23..c3ff83d99 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowPlugin.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowPlugin.kt @@ -37,12 +37,8 @@ public abstract class ShadowPlugin : Plugin { private fun Project.configureBuildScan() { val enableDevelocityIntegration = findOptionalProperty(ENABLE_DEVELOCITY_INTEGRATION_PROPERTY)?.toBoolean() ?: false - if (enableDevelocityIntegration) { - logger.info("Enabling Develocity integration for Shadow plugin.") - } else { - logger.info("Skipping Develocity integration for Shadow plugin.") - return - } + if (!enableDevelocityIntegration) return + logger.info("Enabling Develocity integration for Shadow plugin.") addBuildScanCustomValues() } 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 096986904..c79e626ca 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 @@ -204,6 +204,7 @@ internal constructor( private fun transform(fileDetails: FileCopyDetails, path: String): Boolean { val transformer = transformers.find { it.canTransformResource(fileDetails) } ?: return false + logger.debug("Transforming resource '{}' using {}.", path, transformer::class.simpleName) fileDetails.inputStream().use { inputStream -> transformer.transform( TransformerContext(path = path, inputStream = inputStream, relocators = relocators) 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 e39d04eaf..914b674d5 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 @@ -546,6 +546,9 @@ public abstract class ShadowJar : Jar() { } else { emptySet() } + if (unusedClasses.isNotEmpty()) { + logger.info("Found {} unused classes to drop for minimization.", unusedClasses.size) + } val actualTransformers = transformers.get().let { set -> if ( @@ -604,15 +607,7 @@ public abstract class ShadowJar : Jar() { private val packageRelocators: List get() { - if (enableAutoRelocation.get()) { - logger.info( - "Adding auto relocation packages in the dependencies with prefix '{}'.", - relocationPrefix.get(), - ) - } else { - logger.info("Skipping package relocators as auto relocation is disabled.") - return emptyList() - } + if (!enableAutoRelocation.get()) return emptyList() val prefix = relocationPrefix.get() return includedDependencies.flatMap { file -> file.useZip { @@ -643,6 +638,7 @@ public abstract class ShadowJar : Jar() { logger.info("Skipping non-existent dependency: {}", file) } file.isDirectory -> { + logger.debug("Including dependency: {}", file) from(file) } file.isAar() -> { @@ -656,6 +652,7 @@ public abstract class ShadowJar : Jar() { throw GradleException(message) } else -> { + logger.debug("Including dependency: {}", file) from(archiveOperations.zipTree(file)) } } @@ -691,21 +688,16 @@ public abstract class ShadowJar : Jar() { val shadowFiles = shadowDependencies.get() if (!shadowFiles.isEmpty) { val attrs = listOf(classPathAttr) + shadowFiles.map { it.name } - manifest.attributes[classPathAttributeKey] = attrs.joinToString(" ").trim() - } - - if (addMultiReleaseAttribute.get()) { + val classPathValue = attrs.joinToString(" ").trim() + manifest.attributes[classPathAttributeKey] = classPathValue logger.info( - "Adding {} attribute to the manifest if any dependencies contain it.", - multiReleaseAttributeKey, + "Adding {} attribute to the manifest with value '{}'.", + classPathAttributeKey, + classPathValue, ) - } else { - logger.info( - "Skipping adding {} attribute to the manifest as it is disabled.", - multiReleaseAttributeKey, - ) - return } + + if (!addMultiReleaseAttribute.get()) return val includeMultiReleaseAttr = includedDependencies.any { try { JarFile(it).use { jarFile -> @@ -720,6 +712,7 @@ public abstract class ShadowJar : Jar() { } if (includeMultiReleaseAttr) { manifest.attributes[multiReleaseAttributeKey] = true + logger.info("Adding {} attribute to the manifest.", multiReleaseAttributeKey) } }