scala - How to pass scalacOptions (Xelide-below) to sbt via command line -
i trying call sbt assembly command line passing scalac compiler flag elides (elide-below 1).
i have managed flag working in build.sbt adding line build.sbt
scalacoptions ++= seq("-xelide-below", "1")
and it's working fine when start sbt , run following:
$> sbt $> set scalacoptions in thisbuild ++=seq("-xelide-below", "0") but know how pass in when starting sbt, ci jobs can use while doing different assembly targets (ie. dev/test/prod).
one way pass elide level command line option use system properties
scalacoptions ++= seq("-xelide-below", sys.props.getorelse("elide.below", "0")) and run sbt -delide.below=20 assembly. quick, dirty , easy.
another more verbose way accomplish same thing define different commands producing test/prod artifacts.
lazy val elidelevel = settingkey[int]("elide code below level.") elidelevel in global := 0 scalacoptions ++= seq("-xelide-below", elidelevel.value.tostring) def assemblycommand(name: string, level: int) = command.command(s"${name}assembly") { s => s"set elidelevel in global := $level" :: "assembly" :: s"set elidelevel in global := 0" :: s } commands += assemblycommand("test", 10) commands += assemblycommand("prod", 1000) and can run sbt testassembly prodassembly. buys cleaner command name in combination fact don't have exit active sbt-shell session call example testassembly. sbt-shell sessions tend live long time prefer second option.
Comments
Post a Comment