SBT:对所有项目执行操作

the*_*mel 6 scala sbt

我有一个包含多个子项目的SBT项目,即:

> projects
[info] In file:/home/me/src/foo/
[info]     popen
[info]     foobar-core
[info]   * foobar-client
[info]     foobar-db
Run Code Online (Sandbox Code Playgroud)

有没有办法在每个子项目中运行一个动作?我正在寻找类似的东西publish-all,因为我目前通过所有子项目并publish手动运行,一旦有少数子项目,这将变得相当繁琐.

我正在使用sbt-0.11.2惯性,但如果有帮助我愿意升级.

Kim*_*bel 10

您可以定义聚合所有其他项目的项目.此项目上运行的每个操作都将在所有聚合上运行.这是sbt wiki的一个例子:

import sbt._
import Keys._

object HelloBuild extends Build {
    lazy val root = Project(id = "hello",
                            base = file(".")) aggregate(foo, bar)

    lazy val foo = Project(id = "hello-foo",
                           base = file("foo"))

    lazy val bar = Project(id = "hello-bar",
                           base = file("bar"))
}
Run Code Online (Sandbox Code Playgroud)

  • 如果您有很多项目,这会变得重复。有没有办法列出构建中所有定义的项目? (2认同)