简体   繁体   中英

sbt 0.13.16 - How do I println(systemProperty) in build.sbt file?

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?

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")
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM