score:4

Accepted answer

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:

> set settingkey[string]("samplekeya") := "value 1"           
[info] reapplying settings...
[info] set current project to default-a57b70 (in build file:/users/heiko/tmp/sbt/)
> set settingkey[string]("samplekeya") in compile := "value 2"
[info] reapplying settings...
[info] set current project to default-a57b70 (in build file:/users/heiko/tmp/sbt/)
> samplekeya                                                  
[info] value 1
> samplekeya(for compile)                                     
[info] value 2

score:2

it picked value 1 because value 2 is scoped in compile, but you got the general version. if you wrote samplekeya in compile, it would then work. or, perhaps, in compile -- i think that declaration is incorrect, as the scope compile doesn't really exist.


Related Query