未为子项目设置根项目版本

Root project version is not set for subprojects

我正在使用 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",
    //...
   )

但是没有用。

来自Examples of scoped key notation in the sbt shell

  • ThisBuild / version sets the subproject axis to “entire build” where the build is ThisBuild, with the default configuration.

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

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

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