Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shade gradle-plugin dependencies #9286

Open
sschuberth opened this issue Oct 15, 2024 · 0 comments
Open

Shade gradle-plugin dependencies #9286

sschuberth opened this issue Oct 15, 2024 · 0 comments
Labels
analyzer About the analyzer tool bug Issues that are considered to be bugs

Comments

@sschuberth
Copy link
Member

While the gradle-plugin that the gradle-inspector injects into the build via an init.gradle script is already built as a fat JAR, see

tasks.register<Jar>("fatJar") {
description = "Creates a fat JAR that includes all required runtime dependencies."
group = "Build"
archiveClassifier = "fat"
// Handle duplicate `META-INF/DEPENDENCIES` files.
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from(sourceSets.main.get().output)
dependsOn(configurations.runtimeClasspath)
from({
configurations.runtimeClasspath.get().filter {
// Only bundle JARs that are not specific to the Gradle version.
it.extension == "jar" && !("gradle" in it.path && gradle.gradleVersion in it.path)
}.map {
zipTree(it)
}
})
}

the bundled dependencies are not rewritten / shaded regarding their package locations. So depending on classpath ordering, e.g. the "wrong" Kotlin standard library could be used, resulting in strange errors like

NoSuchMethodError: 'java.util.List kotlin.collections.CollectionsKt.createListBuilder()'

because the stdlib bundled with Gradle's Kotlin DSL is used instead of the one from the gradle-plugin.

The general problem is a bit similar to #6798.

As a solution, either the Shadow plugin could be used with relocation, or the probably even more fitting Gr8 plugin could be used.

@sschuberth sschuberth added analyzer About the analyzer tool bug Issues that are considered to be bugs labels Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer About the analyzer tool bug Issues that are considered to be bugs
Projects
None yet
Development

No branches or pull requests

1 participant