gRPC Bill of Materials (BOM) providing centralized dependency management for all gRPC Java libraries
npx @tessl/cli install tessl/maven-io-grpc--grpc-bom@1.73.0The gRPC BOM (Bill of Materials) provides centralized dependency management for all gRPC Java libraries. It uses Gradle's java-platform plugin and Maven's dependency management to ensure version consistency across the entire gRPC Java ecosystem, eliminating version conflicts and simplifying dependency declarations.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-bom</artifactId>
<version>1.73.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>dependencies {
implementation(platform("io.grpc:grpc-bom:1.73.0"))
}dependencies {
implementation platform('io.grpc:grpc-bom:1.73.0')
}After importing the BOM, declare gRPC dependencies without version numbers:
<dependencies>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
</dependency>
</dependencies>dependencies {
implementation("io.grpc:grpc-netty-shaded")
implementation("io.grpc:grpc-protobuf")
implementation("io.grpc:grpc-stub")
}The gRPC BOM operates as a platform specification that provides:
The BOM provides version constraints for all published gRPC Java libraries, automatically managing compatibility between components.
<!-- Platform BOM import (Maven) -->
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-bom</artifactId>
<version>1.73.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>// Platform BOM import (Gradle)
implementation platform('io.grpc:grpc-bom:1.73.0')The BOM manages version constraints for exactly 30 gRPC Java modules plus the protocol compiler plugin. All dependencies are managed at version 1.73.0:
/**
* All managed dependencies inherit the BOM version (1.73.0)
* ensuring compatibility across the entire gRPC ecosystem.
* No explicit version numbers needed in dependency declarations.
*/The BOM is implemented using Gradle's java-platform plugin with automatic module discovery:
plugins {
id 'java-platform'
id 'maven-publish'
}
// Automatically includes all publishable gRPC subprojects as constraints
gradle.projectsEvaluated {
def projectsToInclude = rootProject.subprojects.findAll {
return it.name != 'grpc-compiler' // Explicitly excluded
&& it.plugins.hasPlugin('java')
&& it.plugins.hasPlugin('maven-publish')
&& it.tasks.findByName('publishMavenPublicationToMavenRepository')?.enabled
}
dependencies {
constraints {
projectsToInclude.each { api it }
}
}
}
// Manually add protoc-gen-grpc-java as POM-type dependency
publishing {
publications {
maven(MavenPublication) {
from components.javaPlatform
pom {
withXml {
def dependencyManagement = asNode().dependencyManagement[0]
def dependencies = dependencyManagement.dependencies[0]
dependencies.appendNode('dependency').with {
appendNode('groupId', 'io.grpc')
appendNode('artifactId', 'protoc-gen-grpc-java')
appendNode('version', version)
appendNode('type', 'pom')
}
}
}
}
}
}<type>pom</type> in Maven, java-platform in Gradle)Standard gRPC Application:
dependencies {
implementation platform('io.grpc:grpc-bom:1.73.0')
implementation 'io.grpc:grpc-netty-shaded'
implementation 'io.grpc:grpc-protobuf'
implementation 'io.grpc:grpc-stub'
}Testing with gRPC:
dependencies {
implementation platform('io.grpc:grpc-bom:1.73.0')
implementation 'io.grpc:grpc-netty-shaded'
testImplementation 'io.grpc:grpc-testing'
testImplementation 'io.grpc:grpc-inprocess'
}Full-featured gRPC Service:
dependencies {
implementation platform('io.grpc:grpc-bom:1.73.0')
implementation 'io.grpc:grpc-netty-shaded'
implementation 'io.grpc:grpc-protobuf'
implementation 'io.grpc:grpc-stub'
implementation 'io.grpc:grpc-services'
implementation 'io.grpc:grpc-auth'
implementation 'io.grpc:grpc-opentelemetry'
}