views:

161

answers:

1

I'm sure I'm missing something really simple... I want to set the system property java.awt.headless to true for my sbt project. Reading the page on properties I think that I need to use system or systemOptional. In my project file I've tried things like:

lazy val javaAwtHeadless = system[Boolean]("java.awt.headless")

Setting it as a user property (e.g. lazy val javaAwtHeadless = property[Boolean]) and setting the accompanying value in build.properties made the property visible in the sbt console but not within sbt's Scala console (via System.getProperty("java.awt.headless")).

set java.awt.headless true from the sbt console works, including being set in the Scala console, but it doesn't persist to the next time I launch sbt.

+1  A: 

A straightforward method would be to edit the batch file or shell script that you use to run sbt and add -Dprop=val

retronym
Yes, but this would require me to change my sbt launch commands on all the machines I develop on, plus would impact other projects I develop using sbt.
pr1001
I personally check the sbt launcher and sbt shell script into each project, for example: http://github.com/scalaz/scalaz. Have you just tried `System.setProperty("prop", "val")` somewhere in your project definition? Remember that SBT by default runs everything in the same process, unless you explicitly ask to to fork: http://code.google.com/p/simple-build-tool/wiki/Forking
retronym
Ok, thanks, that'll do for now.
pr1001