Add support for compile task specific settings on `compile` task axis

So far we had ability to configure compile task specific settings on
`Compile` Configuration scope only. We can now add `compile` task scope
as well.

Usecase: one can now specify:
```
// applies for all tasks on Compile axis
scalacOptions in Compile += "-deprecation"
// applies for compile tasks on Compile axis
scalacOptions in (Compile, compile) += "-Xcheckinit" // effectively, "-deprecation -Xcheckinit"
```
This commit is contained in:
Indrajit Raychaudhuri 2012-03-06 10:51:54 +05:30
parent 14f6d7fd87
commit 2e554c10ba
5 changed files with 19 additions and 2 deletions

View File

@ -208,7 +208,7 @@ object Defaults extends BuildCommon
}
def compilersSetting = compilers <<= (scalaInstance, appConfiguration, streams, classpathOptions, javaHome) map { (si, app, s, co, jh) => Compiler.compilers(si, co, jh)(app, s.log) }
lazy val configTasks = docSetting(doc) ++ compileInputsSettings ++ Seq(
lazy val configTasks = docSetting(doc) ++ compileTaskSettings ++ compileInputsSettings ++ Seq(
initialCommands in GlobalScope :== "",
cleanupCommands in GlobalScope :== "",
compile <<= compileTask tag(Tags.Compile, Tags.CPU),
@ -515,7 +515,9 @@ object Defaults extends BuildCommon
println()
}
def compileTask = (compileInputs, streams) map { (i,s) => Compiler(i,s.log) }
def compileTaskSettings: Seq[Setting[_]] = inTask(compile)(compileInputsSettings)
def compileTask = (compileInputs in compile, streams) map { (i,s) => Compiler(i,s.log) }
def compileIncSetupTask =
(dependencyClasspath, cacheDirectory, skip in compile, definesClass) map { (cp, cacheDir, skip, definesC) =>
Compiler.IncSetup(analysisMap(cp), definesC, skip, cacheDir / "inc_compile")

View File

@ -0,0 +1,3 @@
object A {
def x(i: Int) = 3
}

View File

@ -0,0 +1,3 @@
object B {
def x(i: Int) = 3
}

View File

@ -0,0 +1,4 @@
object C {
// broken method, D doesn't exist
def x: Int = D.i
}

View File

@ -0,0 +1,5 @@
-> compile
> 'set sources in (Compile, compile) <<= sources in (Compile, compile) map { _.filterNot(_.getName contains "C") }'
> compile