I have a simple library project A and I use spring dependency management.
dependencyManagement {
imports {
mavenBom("io.grpc:grpc-bom:$grpcBomVersion")
mavenBom("com.google.protobuf:protobuf-bom:$protobufBomVersion")
}
}
Generated pom file fot this project is ok, but generated gradle 'module' file, which is used by default if I import my project A into project B does not contain following code snippet:
"dependencies": [
{
"group": "io.grpc",
"module": "grpc-bom",
"version": {
"requires": "1.58.0"
},
"attributes": {
"org.gradle.category": "platform"
},
"endorseStrictVersions": true
},
{
"group": "com.google.protobuf",
"module": "protobuf-bom",
"version": {
"requires": "3.24.0"
},
"attributes": {
"org.gradle.category": "platform"
},
"endorseStrictVersions": true
},
This behavior causes that** I need to manually add boms to project B**(project B imports library project A):
implementation(platform("io.grpc:grpc-bom:$grpcBomVersion")) implementation(platform("com.google.protobuf:protobuf-bom:$protobufBomVersion"))
if I use platform for library project A:
implementation(platform("io.grpc:grpc-bom:$grpcBomVersion"))
implementation(platform("com.google.protobuf:protobuf-bom:$protobufBomVersion"))
then all is ok, generated gradle .module file contains mentioned lines:
"dependencies": [
{
"group": "io.grpc",
"module": "grpc-bom",
"version": {
"requires": "1.58.0"
},
"attributes": {
"org.gradle.category": "platform"
},
"endorseStrictVersions": true
},
{
"group": "com.google.protobuf",
"module": "protobuf-bom",
"version": {
"requires": "3.24.0"
},
"attributes": {
"org.gradle.category": "platform"
},
"endorseStrictVersions": true
},
So no need to manually import boms to project B(project B imports library project A):
implementation(platform("io.grpc:grpc-bom:$grpcBomVersion")) implementation(platform("com.google.protobuf:protobuf-bom:$protobufBomVersion"))
But I don't like to use platform
gradle notation in project A, cause in this case I have different versions of same transitive dependencies in project A. I don't want to exclude them manually. When I use dependency-management
plugin in project A - I see that my duplicates of transitive dependencies are gone , so prefer to use dependency-management
plugin instead of platform
, but it causes missed boms in generated gradle .module file
This is not possible with the Spring Dependency Management plugin. See the following issue for details: https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/342