This compiles, but it doesn't add the scalacOptions
to the compile
task. What's the correct way to do this?
compileWall in ThisBuild := Def.task {
scalacOptions += "-Xfatal-warnings"
(compile in Compile).value
}.value
SBT settings is immutable in the Runtime, so we can't update scalacOptions
in the customize Task
.
http://www.scala-sbt.org/0.13/docs/Full-Def.html#Reminder%3A+it%E2%80%99s+all+immutable
but There is a way to achieve change scalacOptions
in the customize Task
by creating the customize config and bind the scalacOptions
in this config, like:
lazy val MyCompile = config("MyCompile") extend Compile // customize config: MyCompile
configs(MyCompile) //configs
inConfig(MyCompile)(Defaults.configTasks) //inConfig and append the Defaults.configTasks
val compileWall = taskKey[Unit]("compileWall")
compileWall in ThisBuild := {
(compile in MyCompile).value
}
scalacOptions in MyCompile := Seq("-Xfatal-warnings") // bind the scalacOptions in customize config.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With