我有以下Build
项目定义,用于设置多项目构建:
import sbt._
import Keys._
object Build extends Build {
lazy val gostats = ProjectRef(id = "gostats", base = file("modules/gostats_0.1"))
lazy val godeploy = Project(id = "godeploy", base = file("."))
.aggregate(gostats).dependsOn(gostats)
}
这编译得很好,但我无法在SBT控制台中运行project gostats
。
如果我将ProjectRef
更改为Project
gostats
,则gostats
不再编译,因为在这种情况下SBT会忽略我的项目设置。
我怎样才能充分利用两个世界?
答案 0 :(得分:2)
如果您使用SBT 0.13.x
,则可以在build.sbt
中定义Multi-Project Builds。这是在您的对象godeploy
之后定义gostats
和Build
的方法。
lazy val godeploy = project in file(".") aggregate gostats dependsOn gostats
lazy val gostats = project in file("modules") / "gostats_0.1"
有了这个,我可以project
没有错误的项目。
[godeploy]> projects
[info] In file:/Users/jacek/sandbox/so/multi-0.13.1-project-ref/
[info] * godeploy
[info] gostats
[godeploy]> project gostats
[info] Set current project to gostats (in build file:/Users/jacek/sandbox/so/multi-0.13.1-project-ref/)
[gostats]> projects
[info] In file:/Users/jacek/sandbox/so/multi-0.13.1-project-ref/
[info] godeploy
[info] * gostats
[gostats]> compile
[info] Updating {file:/Users/jacek/sandbox/so/multi-0.13.1-project-ref/}gostats...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[success] Total time: 0 s, completed Jan 11, 2014 2:23:34 PM
SBT还为我创建了项目目录结构,因为我只从build.sbt
和project/build.properties
文件开始。
jacek:~/sandbox/so/multi-0.13.1-project-ref
$ tree -L 2
.
├── build.sbt
├── modules
│ └── gostats_0.1
└── project
└── build.properties
3 directories, 2 files