我一直试图理解“compile->compile;test->test”的用途,但在阅读 sbt 页面后我仍然不明白......
假设我在 build.sbt 中有这个
lazy val `api` = project.dependsOn(`domain` % "compile->compile;test->test")
...
lazy val `domain` = project...
如果我删除“compile->compile;test->test”有什么区别
lazy val `api` = project.dependsOn(`domain`)
...
lazy val `domain` = project...
如果我只输入“test->test”怎么办?还是“编译->编译”?
答案 0 :(得分:4)
查看正在发生的事情的有用命令是
show api / Test / dependencyClasspath
show api / Compile / dependencyClasspath
这将显示确切的类路径。
<块引用>如果我删除“compile->compile;test->test”
lazy val api = project.dependsOn(domain)
相当于
lazy val api = project.dependsOn(domain % "compile->compile")
表示 api / Compile
配置取决于 domain / Compile
。如果您执行 show api / Test / dependencyClasspath
,那么您应该会看到 domain
的测试类路径不存在。
如果我只输入“test->test”怎么办?
lazy val api = project.dependsOn(domain % "test->test")
意味着 api / Test
依赖于 domain / Test
并且执行 show api / Test / dependencyClasspath
应该显示 domain
的 test
类路径存在。但是,执行 show api / Compile / dependencyClasspath
应该会显示 domain
的 compile
类路径不存在。
因此,如果您希望 api / Test
依赖于 domain / Test
,而 api / Compile
依赖于 domain / Compile
,那么您必须指定
lazy val api = project.dependsOn(domain % "compile->compile;test->test")