Skip to content

use gradle java-platform in grpc-bom; Fixes #5530 #11875

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

Merged
merged 3 commits into from
Feb 5, 2025
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
44 changes: 18 additions & 26 deletions bom/build.gradle
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
plugins {
id 'java-platform'
id "maven-publish"
}

description = 'gRPC: BOM'

gradle.projectsEvaluated {
def projectsToInclude = rootProject.subprojects.findAll {
return it.name != 'grpc-compiler'
&& it.plugins.hasPlugin('java')
&& it.plugins.hasPlugin('maven-publish')
&& it.tasks.findByName('publishMavenPublicationToMavenRepository')?.enabled
}
dependencies {
constraints {
projectsToInclude.each { api it }
}
}
}

publishing {
publications {
maven(MavenPublication) {
// remove all other artifacts since BOM doesn't generates any Jar
artifacts = []

from components.javaPlatform
pom.withXml {
// Generate bom using subprojects
def internalProjects = [
project.name,
'grpc-compiler',
]

def dependencyManagement = asNode().appendNode('dependencyManagement')
def dependencies = dependencyManagement.appendNode('dependencies')
rootProject.subprojects.each { subproject ->
if (internalProjects.contains(subproject.name)) {
return
}
if (!subproject.hasProperty('publishMavenPublicationToMavenRepository')) {
return
}
if (!subproject.publishMavenPublicationToMavenRepository.enabled) {
return
}
def dependencyNode = dependencies.appendNode('dependency')
dependencyNode.appendNode('groupId', subproject.group)
dependencyNode.appendNode('artifactId', subproject.name)
dependencyNode.appendNode('version', subproject.version)
}
def dependencies = asNode().dependencyManagement.dependencies.last()
// add protoc gen (produced by grpc-compiler with different artifact name)
// not sure how to express "<type>pom</type>" in gradle, kept in XML
def dependencyNode = dependencies.appendNode('dependency')
dependencyNode.appendNode('groupId', project.group)
dependencyNode.appendNode('artifactId', 'protoc-gen-grpc-java')
Expand Down