【问题标题】:Root project version is not set for subprojects未为子项目设置根项目版本
【发布时间】:2021-05-23 09:04:06
【问题描述】:

我正在使用 sbt package 打包多项目 sbt 构建,并在 build.sbt 根目录中设置了以下版本属性:

version := "1.0.0"

但不幸的是,聚合子项目jar 都具有0.1.0-SNAPSHOT 后缀,除非我专门为每个子项目指定version :=。有没有办法传播build.sbt 根中的version := "1.0.0" 集?或者任何其他方式为所有聚合子项目设置版本?

我试过了

lazy val root = project
  .in(file("."))
  .aggregate(
       //...
   )
  .settings(
    version := "1.0.0",
    //...
   )

但它没有用。

【问题讨论】:

  • 使用ThisBuild / version := "1.0.0"

标签: scala sbt


【解决方案1】:

来自Examples of scoped key notation in the sbt shell

  • ThisBuild / version 将子项目轴设置为“整个构建”,其中构建为 ThisBuild,默认配置。

因此,正如@LuisMiguelMejíaSuárez 在评论中提到的那样,以下应该这样做:

ThisBuild / version := "1.0.0"
lazy val root = project
  .in(file("."))
  .aggregate(
       //...
   )
  .settings(
    //...
   )

一般来说,我建议阅读 sbt 中的 Scopes

【讨论】:

    猜你喜欢
    • 2016-07-03
    • 2011-08-22
    • 1970-01-01
    • 2016-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-02
    • 2016-02-06
    相关资源
    最近更新 更多