Looking through the getting started guide for scopes, it seems to imply that I should be able to do something like this:
(where Build.scala has the sampleKeyA/B/C/D from the getting started guide)
sampleKeyA := "value 1"
sampleKeyA in compile := "value 2"
compile <<= (compile in Compile, sampleKeyA) map { (result, s) =>
println("sample key: " + s)
result
}
But when I run sbt compile, the value printed for sampleKeyA is “value 1”, not “value 2” as I expect. What am I missing?
First, defining sampleKeyA in compile is of course valid, since it scopes the setting to the compile task.
Second, you get value 1, because you are using sampleKeyA without the above scope. Change it to sampleKeyA in compile and you will get value 2.
To see this, just start an “empty” sbt session and execute the following: