From 00cc3b7e03caad9251066b4f0eac2c07a94880c1 Mon Sep 17 00:00:00 2001 From: Goooler Date: Thu, 3 Sep 2026 14:06:01 +0800 Subject: [PATCH 1/2] Remove redundant loggings --- .../gradle/plugins/shadow/JavaPluginsTest.kt | 10 +------- .../gradle/plugins/shadow/ShadowPlugin.kt | 8 ++----- .../gradle/plugins/shadow/tasks/ShadowJar.kt | 23 ++----------------- 3 files changed, 5 insertions(+), 36 deletions(-) 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/ShadowJar.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.kt index e39d04eaf..361541235 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 @@ -604,15 +604,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 { @@ -694,18 +686,7 @@ public abstract class ShadowJar : Jar() { manifest.attributes[classPathAttributeKey] = attrs.joinToString(" ").trim() } - if (addMultiReleaseAttribute.get()) { - logger.info( - "Adding {} attribute to the manifest if any dependencies contain it.", - multiReleaseAttributeKey, - ) - } 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 -> From 06946314bf8ca36275f9bfb5f6fee24757d63ddf Mon Sep 17 00:00:00 2001 From: Goooler Date: Thu, 3 Sep 2026 14:14:44 +0800 Subject: [PATCH 2/2] Add missing loggings --- .../plugins/shadow/tasks/ShadowCopyAction.kt | 1 + .../gradle/plugins/shadow/tasks/ShadowJar.kt | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) 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 361541235..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 ( @@ -635,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() -> { @@ -648,6 +652,7 @@ public abstract class ShadowJar : Jar() { throw GradleException(message) } else -> { + logger.debug("Including dependency: {}", file) from(archiveOperations.zipTree(file)) } } @@ -683,7 +688,13 @@ 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() + val classPathValue = attrs.joinToString(" ").trim() + manifest.attributes[classPathAttributeKey] = classPathValue + logger.info( + "Adding {} attribute to the manifest with value '{}'.", + classPathAttributeKey, + classPathValue, + ) } if (!addMultiReleaseAttribute.get()) return @@ -701,6 +712,7 @@ public abstract class ShadowJar : Jar() { } if (includeMultiReleaseAttr) { manifest.attributes[multiReleaseAttributeKey] = true + logger.info("Adding {} attribute to the manifest.", multiReleaseAttributeKey) } }