2

I am migrating a Build.scala file to a build.sbt file.

In the Build.scala file, there are print statements that print out vals (of type String) defined in the body of the Build.scala file.

project/Build.scala:

import sbt._
import Keys._

object HelloBuild extends Build {
    val foo = System.getProperty("foo")
    println(foo)
}

How do I migrate these print statements to the build.sbt file?

Michael Lafayette
  • 2,972
  • 3
  • 20
  • 54
  • What's the purpose of this? If it's only for inspecting the build, than there's `sbt inspect` to do so. Otherwise, if it actually makes sense to print something every time build sbt is started/task is executed - you probably need logging, as in @muradm answer – J0HN Oct 27 '18 at 06:13

1 Answers1

2

You can't just print it. You are declaring your build, but when it will be printed is different story. Probably it should be within a task for instance. From docs:

myTask := {
  val log = streams.value.log
  val propertyFoo = System.getProperty("foo")
  log.info(s"property foo = $propertyFoo")
}
muradm
  • 1,973
  • 19
  • 30