Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print/log val in sbt build?

Tags:

sbt

If we want to print/log a simple variable like,

lazy val config = ConfigFactory.load()

And inspect its value in sbt, then how do we do that?

When I just type it in sbt shell, I get:

> 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
like image 806
Dhruv Kapur Avatar asked Aug 29 '17 08:08

Dhruv Kapur


People also ask

What is ThisBuild in sbt?

Typically, if a key has no associated value in a more-specific scope, sbt will try to get a value from a more general scope, such as the ThisBuild scope. This feature allows you to set a value once in a more general scope, allowing multiple more-specific scopes to inherit the value.

How do I specify sbt?

Create or open your sbt project. In the Project tool window, in the source root directory, locate the build. properties file and open it in the editor. In the editor explicitly specify the version of sbt that you want to use in the project.


1 Answers

If you want to print something when you type a string in sbt console,you can add

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

configTest := "config test"

Then you will get

> configTest
[info] config test
like image 173
jiayp89 Avatar answered Sep 28 '22 03:09

jiayp89