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

Re-implement shadow's "component" method to correctly #4129

Merged
merged 2 commits into from
Jul 5, 2023
Merged
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 @@ -19,8 +19,30 @@ tasks.withType(Javadoc) {
}

PublishingTools.setupPublications(project) { publication ->
// This assumes that the shadow plugin is enabled
project.shadow.component(publication)
// This assumes that the shadow plugin is enabled, rather than using the vanilla java component.

// Inlines the shadow.component call, which doesn't actually use components, and doesn't generate
// the pom late enough to pick up gradle's own artifactId wiring from our archivesBaseName changes
// project.shadow.component(publication)
publication.artifact(project.tasks.named("shadowJar"))
publication.pom {
withXml {
def root = asNode()
def dependenciesNode = root.appendNode('dependencies')

project.configurations.shadow.allDependencies.each {
if ((it instanceof ProjectDependency) || ! (it instanceof SelfResolvingDependency)) {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
BasePluginConvention base = it.dependencyProject.convention.getPlugin(BasePluginConvention)

dependencyNode.appendNode('artifactId', base.archivesBaseName)
dependencyNode.appendNode('version', it.version)
dependencyNode.appendNode('scope', 'runtime')
}
}
}
}
}

PublishingTools.setupRepositories(project)
Expand Down
Loading