如何在sbt构建中打印/记录val?

Dhr*_*pur 7 sbt

如果我们要打印/记录一个简单的变量,例如

lazy val config = ConfigFactory.load()
Run Code Online (Sandbox Code Playgroud)

并检查其在sbt中的价值,那么我们该怎么做?

当我在sbt shell中键入它时,我得到:

> config

[error] Not a valid command: config

[error] Not a valid project ID: config

[error] Expected ':' (if selecting a configuration)

[error] Not a valid key: config (similar: configuration, deploy-configs, conflictManager)

[error] config
Run Code Online (Sandbox Code Playgroud)

小智 5

如果你想在 sbt 控制台中输入字符串时打印一些内容,你可以添加

lazy val configTest = settingKey[String]("example")

configTest := "config test"
Run Code Online (Sandbox Code Playgroud)

然后你会得到

> configTest
[info] config test
Run Code Online (Sandbox Code Playgroud)