【发布时间】:2015-08-01 03:51:00
【问题描述】:
我写了一个简单的SBT插件,里面定义了一个helloMessage,默认值为None:
lazy val helloMessage = settingKey[Option[String]]("the message for hello")
override def projectSettings = Seq(
helloMessage in ThisBuild := None,
hello := println("Hello from my plugin: " + helloMessage.value)
)
然后在一个测试项目中,我添加了这个插件,并在build.sbt中定义:
helloMessage in ThisBuild := Some("hello from this build")
lazy val root = project in file(".")
lazy val core = project in file("core")
你可能注意到我用ThisBuild 代替helloMessage。
但问题是,当我在测试项目中运行./sbt helloMessage 时,它只会输出None!不是我定义的消息Some("hello from this build")!
但如果我删除这两行:
lazy val root = project in file(".")
lazy val core = project in file("core")
或只是core 行,它将输出预期的消息Some("hello from this build")。
哪里错了?如果我必须保留多个项目,如何解决?
【问题讨论】: