13

我想在 SBT 中使用外部 BOM 来管理我的项目的依赖版本。

例如,AWS Java SDK 将物料清单工件发布到他们的 maven 存储库:https ://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-bom/1.11.86

我可以使用它来管理 AWS 开发工具包中的依赖项版本。在 Maven 中,我可以通过将 BOM 添加到我的<dependencyManagement>部分来做到这一点,如下所示:

<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>

然后,当我想使用 BOM 中涵盖的模块时,我可以省略版本,BOM 将为我解决它:

<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>

同样在 Gradle 中,我可以使用 BOM 来使用这个插件为我管理依赖项,如下所示:

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'
}

SBT有类似的插件吗?

4

3 回答 3

3

我正在寻找相同的东西,并在很多地方进行了搜索。

我发现最有趣的是 SBT 项目上似乎有 Open Ticket:

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

等不及解决了!

于 2020-06-24T11:41:41.283 回答
0

您是否尝试过将 Ivy 与 sbt 一起使用?它允许您通过使用指定“获取最新”rev="+"

<ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven" xmlns:e="http://ant.apache.org/ivy/extras">
    <dependencies>
        <dependency org="com.amazonaws" name="aws-java-sdk-s3" rev="+" conf="compile->compile(*),master(*);runtime->runtime(*)" />
    </dependencies>
</ivy-module>

http://www.scala-sbt.org/1.0/docs/Library-Dependencies.html

于 2017-02-03T20:31:19.843 回答
0

If I understand you correctly, you can add this to your libraryDependencies:

"com.amazonaws" % "aws-java-sdk-bom" % "1.11.800" pomOnly()

You still have to put that version number in a variable and use it with the SDKs you actually want, unless someone knows the right magic to use to use in the revision field. I know you can go latest.release if you want the latest release version.

于 2020-06-15T21:47:26.930 回答