

How can I use an SBT key to view the current configuration?
source link: https://www.codesd.com/item/how-can-i-use-an-sbt-key-to-view-the-current-configuration.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How can I use an SBT key to view the current configuration?
I have the following build.sbt
file:
version := "0.0.1"
version in Test := "0.0.1-DEBUG"
name <<= (version) apply { v:String => "demo-%s".format(v) }
and while the version seems to be right in the "test" configuration,
> show test:version
[info] 0.0.1-DEBUG
the name doesn't seem to look at the more-specific setting.
> show name
[info] demo-0.0.1
> show test:name
[info] demo-0.0.1
This is obviously a greatly-simplified example of what i'm really trying to do, but i think it illustrates the problem/misunderstanding.
EDIT (2013-07-04): What i'm really trying to do is change javaOptions
in the IntegrationTest
configuration (b/c we spin up a service and then run testing code against it, and i'd like the service being tested to run in a slightly sandboxed mode). Setting javaOptions in IntegrationTest
is easy enough (and show it:java-options
confirms), but doesn't actually get used by runner
unless i go to the trouble of explicitly defining it:runner
to use it:java-options
. I would have expected *:runner
to prefer the most-specific dependent vars.
Here's your Build.scala
translated to use inConfig
as suggested by @MarkHarrah:
import sbt._
import sbt.Keys._
object DemoBuild extends Build {
val mySettings = Seq(
name <<= version { v => "demo-%s".format(v) }
)
lazy val demo = Project(
id = "demo",
base = file("."),
settings = Project.defaultSettings ++ Seq(
organization := "com.demo",
scalaVersion := "2.10.0",
version := "0.0.1",
version in Test <<= version { v => "%s-DEBUG".format(v) }
) ++ mySettings
++ inConfig(Test)(mySettings)
)
}
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK