Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use a maven BOM (bill of materials) to manage my dependencies in SBT?

I want to use an external BOM to manage dependency versions for my project in SBT.

For example, the AWS Java SDK publishes a bill-of-materials artifact to their maven repository: https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-bom/1.11.86

I can use it to manage versions of dependencies in the AWS SDK. In Maven I can do this by adding the BOM to my <dependencyManagement> section like so:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-bom</artifactId>
      <version>1.11.86</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

Then when I want to use a module that's covered in the BOM I can omit the version and the BOM will resolve it for me:

<dependencies>
  <dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-s3</artifactId>
  </dependency>
  <dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-sns</artifactId>
  </dependency>
</dependencies>

Similarly in Gradle, I can use the BOM to manage dependencies for me using this plugin, like so:

apply plugin: "io.spring.dependency-management"

dependencyManagement {
    imports {
        mavenBom 'com.amazonaws:aws-java-sdk-bom:1.11.86'
    }
}

dependencies {
    compile 'com.amazonaws:aws-java-sdk-sns'
    compile 'com.amazonaws:aws-java-sdk-s3'
}

Is there a similar plugin for SBT?

like image 629
kiiadi Avatar asked Feb 03 '17 20:02

kiiadi


People also ask

What is BOM in dependency management?

Maven's dependency management includes the concept of a bill-of-materials (bom). A bom is a special kind of pom that is used to control the versions of a project's dependencies and provides a central place to define and update those versions.

What is use of BOM in Maven?

What Is Maven BOM? BOM stands for Bill Of Materials. A BOM is a special kind of POM that is used to control the versions of a project's dependencies and provide a central place to define and update those versions.

Can a BOM have a parent?

You can only have one parent, but you can import multiple BOMs into your Maven project. Also, importing a BOM will only import the dependencyManagement, while having a parent will import everything you have in that pom.

What is BOM in AWS?

The AWS SDK for Java introduces a new Maven bill of materials (BOM) module, aws-java-sdk-bom, to manage all your dependencies on the SDK and to make sure Maven picks the compatible versions when depending on multiple SDK modules.


1 Answers

I'm looking for the same and have searched in a lot of place.

Most interesting thing I found is it looks like there is Open Ticket on SBT Project:

https://github.com/sbt/sbt/issues/4531

Can't wait that it's resolved !

like image 185
tdebroc Avatar answered Sep 19 '22 16:09

tdebroc