这似乎行不通。我想要这样做的主要原因是在多个多项目之间共享通用设置,例如“publishTo”或“凭据”。
有这样的项目结构
root
|--L1
|--L2
我想在 L1 中定义设置并在 L2 中使用它们,以及在 root 中定义设置并在 L1 和 L2 中使用它们。
通常,您可以通过在项目根目录的文件中in ThisBuild
指定,与任何子项目共享构建级别的设置,如http://www.scala-sbt.org/release/docs/Getting-Started/Multi中所述-Project.html#sharing-settingsbuild.sbt
但这只能在所有项目之间共享价值。
在您的情况下,如果您已将项目定义如下Build.scala
import sbt._
import Keys._
object MyBuild extends Build {
lazy val root = Project(id = "root",
base = file("."))
lazy val L1 = Project(id = "L1",
base = file("L1"))
lazy val L2 = Project(id = "L2",
base = file("L1/L2"))
}
如果您想重用您在中publishTo
定义的键(例如 ),您将在L1
L2
L2
build.sbt
publishTo <<= publishTo in L1
您可以使用inspect
sbt 中的命令来检出键值及其设置方式。
> projects
[info] In file:/Users/leo/src/project0/
[info] L1
[info] L2
[info] * root
> project L2
[info] Set current project to L2 (in build file:/Users/leo/src/project0/)
> inspect publish-to
[info] Setting: scala.Option[sbt.Resolver] = Some(Repo1: https://repo1.org)
[info] Description:
[info] The resolver to publish to.
[info] Provided by:
[info] {file:/Users/leo/src/project0/}L2/*:publish-to
[info] Defined at:
[info] /Users/leo/src/project0/L1/L2/build.sbt:1
[info] Dependencies:
[info] L1/*:publish-to
[info] Reverse dependencies:
[info] L2/*:publish-configuration
[info] L2/*:other-resolvers
[info] Delegates:
[info] L2/*:publish-to
[info] {.}/*:publish-to
[info] */*:publish-to
[info] Related:
[info] L1/*:publish-to
[info] */*:publish-to
[info] {.}/*:publish-to
>