最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

build.gradle - mavenBom from spring dependency-management Gradle plugin does not add bom to gradle module file - Stack Overflow

matteradmin6PV0评论

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": {
            ".gradle.category": "platform"
          },
          "endorseStrictVersions": true
        },
        {
          "group": "com.google.protobuf",
          "module": "protobuf-bom",
          "version": {
            "requires": "3.24.0"
          },
          "attributes": {
            ".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": {
            ".gradle.category": "platform"
          },
          "endorseStrictVersions": true
        },
        {
          "group": "com.google.protobuf",
          "module": "protobuf-bom",
          "version": {
            "requires": "3.24.0"
          },
          "attributes": {
            ".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

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": {
            ".gradle.category": "platform"
          },
          "endorseStrictVersions": true
        },
        {
          "group": "com.google.protobuf",
          "module": "protobuf-bom",
          "version": {
            "requires": "3.24.0"
          },
          "attributes": {
            ".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": {
            ".gradle.category": "platform"
          },
          "endorseStrictVersions": true
        },
        {
          "group": "com.google.protobuf",
          "module": "protobuf-bom",
          "version": {
            "requires": "3.24.0"
          },
          "attributes": {
            ".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

Share Improve this question asked Nov 16, 2024 at 16:30 Alexandra ZverkovichAlexandra Zverkovich 112 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

This is not possible with the Spring Dependency Management plugin. See the following issue for details: https://github/spring-gradle-plugins/dependency-management-plugin/issues/342

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far