mirror of https://github.com/sbt/sbt.git
Derive testGrouping,compilers,scalaBinaryVersion. Don't go through compileInputs for doc. Fixes #539, #708, #391.
This commit is contained in:
parent
871aeb1502
commit
0bb460c03e
|
|
@ -195,7 +195,6 @@ object Defaults extends BuildCommon
|
||||||
)
|
)
|
||||||
|
|
||||||
def compileBase = inTask(console)(compilersSetting :: Nil) ++ compileBaseGlobal ++ Seq(
|
def compileBase = inTask(console)(compilersSetting :: Nil) ++ compileBaseGlobal ++ Seq(
|
||||||
compilersSetting,
|
|
||||||
incOptions in GlobalScope := sbt.inc.IncOptions.defaultTransactional(crossTarget.value.getParentFile / "classes.bak"),
|
incOptions in GlobalScope := sbt.inc.IncOptions.defaultTransactional(crossTarget.value.getParentFile / "classes.bak"),
|
||||||
scalaInstance <<= scalaInstanceTask,
|
scalaInstance <<= scalaInstanceTask,
|
||||||
crossVersion := (if(crossPaths.value) CrossVersion.binary else CrossVersion.Disabled),
|
crossVersion := (if(crossPaths.value) CrossVersion.binary else CrossVersion.Disabled),
|
||||||
|
|
@ -209,9 +208,11 @@ object Defaults extends BuildCommon
|
||||||
javacOptions :== Nil,
|
javacOptions :== Nil,
|
||||||
scalacOptions :== Nil,
|
scalacOptions :== Nil,
|
||||||
scalaVersion := appConfiguration.value.provider.scalaProvider.version,
|
scalaVersion := appConfiguration.value.provider.scalaProvider.version,
|
||||||
scalaBinaryVersion := binaryScalaVersion(scalaVersion.value),
|
|
||||||
crossScalaVersions := Seq(scalaVersion.value)
|
crossScalaVersions := Seq(scalaVersion.value)
|
||||||
))
|
)) ++ Seq(
|
||||||
|
derive(compilersSetting),
|
||||||
|
derive(scalaBinaryVersion := binaryScalaVersion(scalaVersion.value))
|
||||||
|
)
|
||||||
def makeCrossTarget(t: File, sv: String, sbtv: String, plugin: Boolean, cross: Boolean): File =
|
def makeCrossTarget(t: File, sv: String, sbtv: String, plugin: Boolean, cross: Boolean): File =
|
||||||
{
|
{
|
||||||
val scalaBase = if(cross) t / ("scala-" + sv) else t
|
val scalaBase = if(cross) t / ("scala-" + sv) else t
|
||||||
|
|
@ -219,7 +220,7 @@ object Defaults extends BuildCommon
|
||||||
}
|
}
|
||||||
def compilersSetting = compilers := Compiler.compilers(scalaInstance.value, classpathOptions.value, javaHome.value)(appConfiguration.value, streams.value.log)
|
def compilersSetting = compilers := Compiler.compilers(scalaInstance.value, classpathOptions.value, javaHome.value)(appConfiguration.value, streams.value.log)
|
||||||
|
|
||||||
lazy val configTasks = docTaskSettings(doc) ++ compileTaskSettings ++ compileInputsSettings ++ configGlobal ++ Seq(
|
lazy val configTasks = docTaskSettings(doc) ++ inTask(compile)(compileInputsSettings) ++ configGlobal ++ Seq(
|
||||||
compile <<= compileTask tag(Tags.Compile, Tags.CPU),
|
compile <<= compileTask tag(Tags.Compile, Tags.CPU),
|
||||||
printWarnings <<= printWarningsTask,
|
printWarnings <<= printWarningsTask,
|
||||||
compileIncSetup <<= compileIncSetupTask,
|
compileIncSetup <<= compileIncSetupTask,
|
||||||
|
|
@ -373,9 +374,10 @@ object Defaults extends BuildCommon
|
||||||
testListeners.in(TaskGlobal).value
|
testListeners.in(TaskGlobal).value
|
||||||
},
|
},
|
||||||
testOptions := Tests.Listeners(testListeners.value) +: (testOptions in TaskGlobal).value,
|
testOptions := Tests.Listeners(testListeners.value) +: (testOptions in TaskGlobal).value,
|
||||||
testExecution <<= testExecutionTask(key),
|
testExecution <<= testExecutionTask(key)
|
||||||
testGrouping <<= testGrouping or singleTestGroup(key)
|
) ) ++ Seq(
|
||||||
) )
|
derive(testGrouping <<= singleTestGroupDefault)
|
||||||
|
)
|
||||||
def testLogger(manager: Streams, baseKey: Scoped)(tdef: TestDefinition): Logger =
|
def testLogger(manager: Streams, baseKey: Scoped)(tdef: TestDefinition): Logger =
|
||||||
{
|
{
|
||||||
val scope = baseKey.scope
|
val scope = baseKey.scope
|
||||||
|
|
@ -389,10 +391,11 @@ object Defaults extends BuildCommon
|
||||||
val mod = tdef.fingerprint match { case f: SubclassFingerprint => f.isModule; case f: AnnotatedFingerprint => f.isModule; case _ => false }
|
val mod = tdef.fingerprint match { case f: SubclassFingerprint => f.isModule; case f: AnnotatedFingerprint => f.isModule; case _ => false }
|
||||||
extra.put(name.key, tdef.name).put(isModule, mod)
|
extra.put(name.key, tdef.name).put(isModule, mod)
|
||||||
}
|
}
|
||||||
def singleTestGroup(key: Scoped): Initialize[Task[Seq[Tests.Group]]] = Def.task {
|
def singleTestGroup(key: Scoped): Initialize[Task[Seq[Tests.Group]]] = inTask(key, singleTestGroupDefault)
|
||||||
val tests = (definedTests in key).value
|
def singleTestGroupDefault: Initialize[Task[Seq[Tests.Group]]] = Def.task {
|
||||||
val fk = (fork in key).value
|
val tests = definedTests.value
|
||||||
val opts = inTask(key, forkOptions).value
|
val fk = fork.value
|
||||||
|
val opts = forkOptions.value
|
||||||
Seq(new Tests.Group("<default>", tests, if(fk) Tests.SubProcess(opts) else Tests.InProcess))
|
Seq(new Tests.Group("<default>", tests, if(fk) Tests.SubProcess(opts) else Tests.InProcess))
|
||||||
}
|
}
|
||||||
private[this] def forkOptions: Initialize[Task[ForkOptions]] =
|
private[this] def forkOptions: Initialize[Task[ForkOptions]] =
|
||||||
|
|
@ -648,24 +651,30 @@ object Defaults extends BuildCommon
|
||||||
|
|
||||||
@deprecated("Use `docTaskSettings` instead", "0.12.0")
|
@deprecated("Use `docTaskSettings` instead", "0.12.0")
|
||||||
def docSetting(key: TaskKey[File]) = docTaskSettings(key)
|
def docSetting(key: TaskKey[File]) = docTaskSettings(key)
|
||||||
def docTaskSettings(key: TaskKey[File] = doc): Seq[Setting[_]] = inTask(key)(compileInputsSettings ++ Seq(
|
def docTaskSettings(key: TaskKey[File] = doc): Seq[Setting[_]] = inTask(key)(Seq(
|
||||||
apiMappings ++= { if(autoAPIMappings.value) APIMappings.extract(dependencyClasspath.value, streams.value.log).toMap else Map.empty[File,URL] },
|
apiMappings ++= { if(autoAPIMappings.value) APIMappings.extract(dependencyClasspath.value, streams.value.log).toMap else Map.empty[File,URL] },
|
||||||
key in TaskGlobal <<= (compileInputs, target, configuration, apiMappings, streams) map { (in, out, config, xapis, s) =>
|
key in TaskGlobal := {
|
||||||
val srcs = in.config.sources
|
val s = streams.value
|
||||||
|
val cs = compilers.value
|
||||||
|
val srcs = sources.value
|
||||||
|
val out = target.value
|
||||||
|
val sOpts = scalacOptions.value
|
||||||
|
val jOpts = javacOptions.value
|
||||||
|
val xapis = apiMappings.value
|
||||||
val hasScala = srcs.exists(_.name.endsWith(".scala"))
|
val hasScala = srcs.exists(_.name.endsWith(".scala"))
|
||||||
val hasJava = srcs.exists(_.name.endsWith(".java"))
|
val hasJava = srcs.exists(_.name.endsWith(".java"))
|
||||||
val cp = in.config.classpath.toList.filterNot(_ == in.config.classesDirectory)
|
val cp = data(dependencyClasspath.value).toList
|
||||||
val label = nameForSrc(config.name)
|
val label = nameForSrc(configuration.value.name)
|
||||||
val (options, runDoc) =
|
val (options, runDoc) =
|
||||||
if(hasScala)
|
if(hasScala)
|
||||||
(in.config.options ++ Opts.doc.externalAPI(xapis),
|
(sOpts ++ Opts.doc.externalAPI(xapis), // can't put the .value calls directly here until 2.10.2
|
||||||
Doc.scaladoc(label, s.cacheDirectory / "scala", in.compilers.scalac.onArgs(exported(s, "scaladoc"))))
|
Doc.scaladoc(label, s.cacheDirectory / "scala", cs.scalac.onArgs(exported(s, "scaladoc"))))
|
||||||
else if(hasJava)
|
else if(hasJava)
|
||||||
(in.config.javacOptions,
|
(jOpts,
|
||||||
Doc.javadoc(label, s.cacheDirectory / "java", in.compilers.javac.onArgs(exported(s, "javadoc"))))
|
Doc.javadoc(label, s.cacheDirectory / "java", cs.javac.onArgs(exported(s, "javadoc"))))
|
||||||
else
|
else
|
||||||
(Nil, RawCompileLike.nop)
|
(Nil, RawCompileLike.nop)
|
||||||
runDoc(srcs, cp, out, options, in.config.maxErrors, s.log)
|
runDoc(srcs, cp, out, options, maxErrors.value, s.log)
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
|
|
@ -695,6 +704,7 @@ object Defaults extends BuildCommon
|
||||||
private[this] def exported(s: TaskStreams, command: String): Seq[String] => Unit = args =>
|
private[this] def exported(s: TaskStreams, command: String): Seq[String] => Unit = args =>
|
||||||
exported(s.text("export"), command)
|
exported(s.text("export"), command)
|
||||||
|
|
||||||
|
@deprecated("Use inTask(compile)(compileInputsSettings)", "0.13.0")
|
||||||
def compileTaskSettings: Seq[Setting[_]] = inTask(compile)(compileInputsSettings)
|
def compileTaskSettings: Seq[Setting[_]] = inTask(compile)(compileInputsSettings)
|
||||||
|
|
||||||
def compileTask: Initialize[Task[inc.Analysis]] = Def.task { compileTaskImpl(streams.value, (compileInputs in compile).value) }
|
def compileTask: Initialize[Task[inc.Analysis]] = Def.task { compileTaskImpl(streams.value, (compileInputs in compile).value) }
|
||||||
|
|
@ -848,7 +858,7 @@ object Classpaths
|
||||||
|
|
||||||
lazy val configSettings: Seq[Setting[_]] = classpaths ++ Seq(
|
lazy val configSettings: Seq[Setting[_]] = classpaths ++ Seq(
|
||||||
products <<= makeProducts,
|
products <<= makeProducts,
|
||||||
productDirectories := compileInputs.value.config.classesDirectory :: Nil,
|
productDirectories := classDirectory.value :: Nil,
|
||||||
classpathConfiguration := findClasspathConfig(internalConfigurationMap.value, configuration.value, classpathConfiguration.?.value, update.value)
|
classpathConfiguration := findClasspathConfig(internalConfigurationMap.value, configuration.value, classpathConfiguration.?.value, update.value)
|
||||||
)
|
)
|
||||||
private[this] def classpaths: Seq[Setting[_]] = Seq(
|
private[this] def classpaths: Seq[Setting[_]] = Seq(
|
||||||
|
|
@ -1190,8 +1200,11 @@ object Classpaths
|
||||||
}
|
}
|
||||||
|
|
||||||
def analyzed[T](data: T, analysis: inc.Analysis) = Attributed.blank(data).put(Keys.analysis, analysis)
|
def analyzed[T](data: T, analysis: inc.Analysis) = Attributed.blank(data).put(Keys.analysis, analysis)
|
||||||
def makeProducts: Initialize[Task[Seq[File]]] =
|
def makeProducts: Initialize[Task[Seq[File]]] = Def.task {
|
||||||
(compile, compileInputs, copyResources) map { (_, i, _) => i.config.classesDirectory :: Nil }
|
val x1 = compile.value
|
||||||
|
val x2 = copyResources.value
|
||||||
|
classDirectory.value :: Nil
|
||||||
|
}
|
||||||
def exportProductsTask: Initialize[Task[Classpath]] =
|
def exportProductsTask: Initialize[Task[Classpath]] =
|
||||||
(products.task, packageBin.task, exportJars, compile, apiURL) flatMap { (psTask, pkgTask, useJars, analysis, u) =>
|
(products.task, packageBin.task, exportJars, compile, apiURL) flatMap { (psTask, pkgTask, useJars, analysis, u) =>
|
||||||
(if(useJars) Seq(pkgTask).join else psTask) map { _ map { f => APIMappings.store(analyzed(f, analysis), u) } }
|
(if(useJars) Seq(pkgTask).join else psTask) map { _ map { f => APIMappings.store(analyzed(f, analysis), u) } }
|
||||||
|
|
@ -1596,4 +1609,6 @@ trait BuildCommon
|
||||||
|
|
||||||
def getPrevious[T](task: TaskKey[T]): Initialize[Task[Option[T]]] =
|
def getPrevious[T](task: TaskKey[T]): Initialize[Task[Option[T]]] =
|
||||||
(state, resolvedScoped) map { (s, ctx) => getFromContext(task, ctx, s) }
|
(state, resolvedScoped) map { (s, ctx) => getFromContext(task, ctx, s) }
|
||||||
|
|
||||||
|
private[sbt] def derive[T](s: Setting[T]): Setting[T] = Def.derive(s, allowDynamic=true, trigger = _ != streams.key)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -220,6 +220,7 @@ object Keys
|
||||||
val defaultConfigurationMapping = SettingKey[String]("default-configuration-mapping", "Defines the mapping used for a simple, unmapped configuration definition.", CSetting)
|
val defaultConfigurationMapping = SettingKey[String]("default-configuration-mapping", "Defines the mapping used for a simple, unmapped configuration definition.", CSetting)
|
||||||
|
|
||||||
val products = TaskKey[Seq[File]]("products", "Build products that get packaged.", BMinusTask)
|
val products = TaskKey[Seq[File]]("products", "Build products that get packaged.", BMinusTask)
|
||||||
|
@deprecated("This task is unused by the default project and will be removed.", "0.13.0")
|
||||||
val productDirectories = TaskKey[Seq[File]]("product-directories", "Base directories of build products.", CTask)
|
val productDirectories = TaskKey[Seq[File]]("product-directories", "Base directories of build products.", CTask)
|
||||||
val exportJars = SettingKey[Boolean]("export-jars", "Determines whether the exported classpath for this project contains classes (false) or a packaged jar (true).", BSetting)
|
val exportJars = SettingKey[Boolean]("export-jars", "Determines whether the exported classpath for this project contains classes (false) or a packaged jar (true).", BSetting)
|
||||||
val exportedProducts = TaskKey[Classpath]("exported-products", "Build products that go on the exported classpath.", CTask)
|
val exportedProducts = TaskKey[Classpath]("exported-products", "Build products that go on the exported classpath.", CTask)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
class A {
|
||||||
|
def x = 3
|
||||||
|
}
|
||||||
|
class B
|
||||||
|
object B {
|
||||||
|
implicit def bToA(b: B): A = new A
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
lazy val a = project.settings(
|
||||||
|
scalaVersion := "2.9.2",
|
||||||
|
scalaInstance in (Compile,doc) := (scalaInstance in b).value,
|
||||||
|
// 2.10.1-only, so this will only succeed if `doc` recognizes the more specific scalaInstance scoped to `doc`
|
||||||
|
scalacOptions in (Compile,doc) += "-implicits"
|
||||||
|
)
|
||||||
|
|
||||||
|
lazy val b = project.settings(
|
||||||
|
scalaVersion := "2.10.1"
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
> a/doc
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
scalaVersion := "2.10.1"
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
lazy val a = project.dependsOn(b).settings(scalaVersion := "2.8.2")
|
||||||
|
lazy val b = RootProject(uri("b"))
|
||||||
|
lazy val check = taskKey[Unit]("Checks the configured scalaBinaryVersion")
|
||||||
|
|
||||||
|
check := {
|
||||||
|
val av = (scalaBinaryVersion in a).value
|
||||||
|
val bv = (scalaBinaryVersion in b).value
|
||||||
|
same(av, "2.8.2")
|
||||||
|
same(bv, "2.10")
|
||||||
|
}
|
||||||
|
|
||||||
|
def same(actual: String, expected: String) {
|
||||||
|
assert(actual == expected, s"Expected binary version to be $expected, was $actual")
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
> check
|
||||||
|
|
@ -14,7 +14,7 @@ object ForkTestsTest extends Build {
|
||||||
|
|
||||||
lazy val root = Project("root", file("."), settings = defaultSettings ++ Seq(
|
lazy val root = Project("root", file("."), settings = defaultSettings ++ Seq(
|
||||||
scalaVersion := "2.9.2",
|
scalaVersion := "2.9.2",
|
||||||
testGrouping <<= definedTests in Test map { tests =>
|
testGrouping in Test <<= definedTests in Test map { tests =>
|
||||||
assert(tests.size == 1)
|
assert(tests.size == 1)
|
||||||
val groups = Stream continually tests(0) take totalFiles grouped groupSize
|
val groups = Stream continually tests(0) take totalFiles grouped groupSize
|
||||||
for ((ts, idx) <- groups.toSeq.zipWithIndex) yield {
|
for ((ts, idx) <- groups.toSeq.zipWithIndex) yield {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package org.example
|
||||||
|
|
||||||
|
// this tests that normal tests do not
|
||||||
|
// interfere with integration tests (#539)
|
||||||
|
|
||||||
|
import org.specs2.mutable._
|
||||||
|
|
||||||
|
class B extends Specification
|
||||||
|
{
|
||||||
|
"this" should {
|
||||||
|
"not work" in { 1 must_== 2 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object A extends Specification
|
||||||
|
{
|
||||||
|
"this" should {
|
||||||
|
"not work" in { 1 must_== 2 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,14 +3,12 @@
|
||||||
|
|
||||||
object B extends Build
|
object B extends Build
|
||||||
{
|
{
|
||||||
|
lazy val IntegrationTest = config("it") extend(Test)
|
||||||
lazy val root =
|
lazy val root =
|
||||||
Project("root", file("."))
|
Project("root", file("."))
|
||||||
.configs( IntegrationTest )
|
.configs( IntegrationTest )
|
||||||
.settings( Defaults.itSettings : _*)
|
.settings( Defaults.itSettings : _*)
|
||||||
.settings(
|
.settings( libraryDependencies += specs )
|
||||||
libraryDependencies += specs,
|
|
||||||
resolvers += ScalaToolsReleases
|
|
||||||
)
|
|
||||||
|
|
||||||
lazy val specs = "org.specs2" % "specs2_2.10" % "1.12.3" % "it,test"
|
lazy val specs = "org.specs2" % "specs2_2.10" % "1.12.3" % "test"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,12 @@ $ copy-file changes/ClassSuccessModuleFail.scala src/it/scala/Test.scala
|
||||||
> clean
|
> clean
|
||||||
$ delete src/
|
$ delete src/
|
||||||
$ copy-file changes/ClassSuccessModuleSuccess.scala src/it/scala/Test.scala
|
$ copy-file changes/ClassSuccessModuleSuccess.scala src/it/scala/Test.scala
|
||||||
> it:test
|
> it:test
|
||||||
|
|
||||||
|
# verify that a failing normal test fails when run directly
|
||||||
|
$ copy-file changes/AlwaysFail.scala src/test/scala/AlwaysFail.scala
|
||||||
|
-> test:test
|
||||||
|
|
||||||
|
# but that it does not affect the result of it:test (#539)
|
||||||
|
> it:test
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue