仅使相关文件更改触发多项目SBT构建中的执行

时间:2016-12-22 01:50:52

标签: scala sbt

我正在尝试设置这样的多项目构建:

+-- common
|   +-- build.sbt
+-- api
|   +-- build.sbt
+-- indexer
|   +-- build.sbt
+-- build.sbt
root中的

build.sbt看起来像这样:

lazy val common = (project in file("common"))
lazy val searchApi = (project in file("search"))
  .dependsOn(common)
lazy val indexer = (project in file("indexer"))
  .dependsOn(common)

如您所见,indexerapi都依赖于common但不依赖于compile。问题是如果我尝试为任务执行触发执行,比如sbt ~api/compile

indexer

然后更改watchSources项目中的文件,即使更改的文件实际上不在其类路径上,项目仍将重新编译 - 似乎build.sbt始终由引用的每个项目组成根watchSources并且不考虑您实际运行任务的项目。

我尝试过滤build.sbt,但很难做得很整齐,因为我放入的watchSources文件只能看到它所在项目的资源......例如indexer/build.sbt中的indexer只能看到build.sbt中的观看来源,根目录中的src/main/resources仅在根目录中观看watchSources(它看不到子项目的build.sbt

有没有人有一个很好的解决方法。我得到的最好的是在每个子项目的watchSources <<= (watchSources) map { files => if (Option(System.getProperty("project")).getOrElse("none").equals("indexer")) { files } else { Nil } } ...

中加入这样的东西
sbt -Dproject=indexer ~indexer/compile

...然后运行library(raster) library(SpaDES) m = matrix(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.2, 0.3, 0.4, 0.4, 0.3, 0.2, 0.1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0.4, 0.3, 0.2, 0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5),nrow=4, ncol=10, byrow=TRUE ) r <- raster(m) #the aspect ratio should be modified to "0.4". plot(r,asp=0.4,col = grey.colors(10, start=0, end=1)) #Because it is the relation beetween columns and rows.

1 个答案:

答案 0 :(得分:1)

~运算符监视当前活动的项目以进行更改。首先尝试运行project api

> project api
> ~compile
相关问题