Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ public abstract class ShadowPlugin : Plugin<Project> {
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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -604,15 +607,7 @@ public abstract class ShadowJar : Jar() {

private val packageRelocators: List<SimpleRelocator>
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 {
Expand Down Expand Up @@ -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() -> {
Expand All @@ -656,6 +652,7 @@ public abstract class ShadowJar : Jar() {
throw GradleException(message)
}
else -> {
logger.debug("Including dependency: {}", file)
from(archiveOperations.zipTree(file))
}
}
Expand Down Expand Up @@ -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 ->
Expand All @@ -720,6 +712,7 @@ public abstract class ShadowJar : Jar() {
}
if (includeMultiReleaseAttr) {
manifest.attributes[multiReleaseAttributeKey] = true
logger.info("Adding {} attribute to the manifest.", multiReleaseAttributeKey)
}
}

Expand Down