1

I am setting up a project specific BOM that will "inherit" definitions from other BOMs (available as pom.xml) and also define own managed dependendies.

I tried the following (as stated in the java-platform docs) in my build.gradle.kts:

plugins {
  `java-platform`
  `maven-publish`
}

dependencies {

   constraints {
      api(platform("org.camunda.bpm:camunda-bom:${Versions.camunda}"))
   }
}

publishing {
   publications {
      create<MavenPublication>("camunda-bom") {
          from(components["javaPlatform"])
      }
   }
}

But when I do gradle publishToMavenLocal and check the resulting pom.xml in .m2/repositories it looks like:

<dependencyManagement>
 <dependencies>
   <dependency>
     <groupId>org.camunda.bpm</groupId>
     <artifactId>camunda-bom</artifactId>
     <version>7.10.0</version>
     <scope>compile</scope>
   </dependency>
 </dependencies>

Which will not work because the syntax for importing poms should be

  ...
  <type>pom</type>
  <scope>import</scope>
  ...

How can I publish a valid BOM as pom.xml with gradle (using version 5.3.1)?

4

1 回答 1

4

您将 BOM 定义为constraint,但这很可能不是您想要做的。平台上的约束只会说如果该依赖项在其他地方进入图表,它应该使用它的platform一部分和来自约束的版本推荐。

如果您希望该 BOM 的约束对您平台的消费者可见,那么您需要platform dependency通过执行以下操作将 BOM 添加为:

javaPlatform {
    allowDependencies()
}
dependencies {
    api(platform("org.camunda.bpm:camunda-bom:${Versions.camunda}"))
}

然后这将在 Maven 中作为内联 BOM 正确发布。

于 2019-04-16T10:24:14.520 回答