Robert Elliot
10/26/2025, 11:48 AMcom.github.johnrengelman.shadow:8.1.1 to com.gradleup.shadow:9.2.2, and it breaks some of my existing gradle config. Details in thread.Robert Elliot
10/26/2025, 11:50 AMpublishing {
publications {
create<MavenPublication>("standaloneJar") {
project.shadow.component(this)
}
}
getComponents().withType<AdhocComponentWithVariants>().forEach { c ->
c.withVariantsFromConfiguration(configurations.shadowRuntimeElements.get()) {
skip()
}
}
}
However, project.shadow.component(this) no longer compiles and if I remove it the getComponents().withType<AdhocComponentWithVariants>().forEach { c -> ... } block fails at runtime when I do a gradle shadowJar.
ChatGPT tells me I can simply replace as so:
publishing {
publications {
create<MavenPublication>("standaloneJar") {
from(components["shadow"])
}
}
}
and the getComponents().withType<AdhocComponentWithVariants>().forEach { c -> } stuff is not needed at all.
However, it couldn't give me a reference for this, so I'm suspicious...
Is it correct?Vampire
10/26/2025, 1:21 PMRobert Elliot
10/27/2025, 3:00 PMRobert Elliot
10/27/2025, 3:01 PMgetComponents().withType<AdhocComponentWithVariants>().forEach { c ->
c.withVariantsFromConfiguration(configurations.shadowRuntimeElements.get()) {
skip()
}
}
prevented Gradle from publishing duplicate runtime variants — otherwise, you’d end up with multiple variants for the same artifact (the plain JAR and the shadowed JAR).Vampire
10/27/2025, 3:05 PMVampire
10/27/2025, 3:06 PMVampire
10/27/2025, 3:07 PMVampire
10/27/2025, 3:11 PMproject.shadow.addShadowVariantIntoJavaComponent = false. At least from the naming I'd expect it to have the same effect as the lower part.Vampire
10/27/2025, 3:14 PMval shadow by components.existing
from(shadow.get())
or
from(components["shadow"])Vampire
10/27/2025, 3:15 PMRobert Elliot
10/27/2025, 3:34 PMVampire
10/27/2025, 3:38 PM