-
Notifications
You must be signed in to change notification settings - Fork 129
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
Manually remove from pom.xml the dependencies that have been inlined by the shadow plugin #87
Conversation
Hello @anuraaga , I'm sorry to bother you with this. The bug is that the dependencies inlined by the Gradle Shadow plugin are unexpectedly listed in the generated pom.xml as RUNTIME dependencies when it is expected that they are not listed in the pom.xml at all. The proposed fix seems to do the job but I'm not a Gradle person so I would like to get a review on this. |
Sure @cyrille-leclerc let me take a look at this tomorrow |
@cyrille-leclerc welcome to the club of people who ask @anuraaga for shadowJar help 😂 try this:
|
…by the shadow plugin
380753c
to
845ddb5
Compare
Thanks @trask, so we have 2 solutions, yours is way shorter. I have no clue on what's the the most maintainable solution. Maybe @anuraaga can help decide. @trask's solution sounds appealing as it's compact. configure<PublishingExtension> {
(components["java"] as AdhocComponentWithVariants).run {
withVariantsFromConfiguration(configurations["runtimeElements"]) {
skip()
}
}
} or publishing {
(publications) {
"maven"(MavenPublication::class) {
pom {
withXml {
val pomNode = asNode()
val dependenciesNode = (pomNode.get("dependencies") as NodeList)[0] as Node
val dependencyNodes = dependenciesNode.children() as NodeList
// the jar dependencies bundled in the uber-jar by the shadow plugin are wrongly added as
// 'runtime' dependencies in the generated pom.xml instead of being absent this pom.xml.
// Remove those runtime dependencies from the pom.xml:
dependencyNodes.removeIf {
val dependencyNode = it as Node
val scope: String = ((dependencyNode.get("scope") as NodeList)[0] as Node).text()
val removeDependency = (scope == "runtime" || scope == "compile")
logger.debug("pom.xml remove: $removeDependency dependency $dependencyNode")
removeDependency
}
}
}
}
}
} |
…by the shadow plugin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Description:
Manually remove from
pom.xml
the dependencies that have been inlined by the shadow plugin as they should no be listed in pom.xml as RUNTIME dependenciesExisting Issue(s):
<extension>
inpom.xml
because thepom.xml
of the Otel Maven extension lists dependencies even though they are bundled #86Testing:
./gradlew :maven-extension:publishToMavenLocal
~/.m2/repository/io/opentelemetry/contrib/opentelemetry-maven-extension/1.7.0-alpha-SNAPSHOT/opentelemetry-maven-extension-1.7.0-alpha-SNAPSHOT.pom
that the pom doesn't contain any dependency.Documentation:
N/A
Outstanding items: