mirror of https://github.com/sbt/sbt.git
Migrate JUnitXmlReport into an autoplugin.
This commit is contained in:
parent
b38b86add5
commit
447ae8b1d8
|
|
@ -371,7 +371,6 @@ object Defaults extends BuildCommon
|
||||||
Seq(ScalaCheck, Specs2, Specs, ScalaTest, JUnit)
|
Seq(ScalaCheck, Specs2, Specs, ScalaTest, JUnit)
|
||||||
},
|
},
|
||||||
testListeners :== Nil,
|
testListeners :== Nil,
|
||||||
testReportJUnitXml :== false,
|
|
||||||
testOptions :== Nil,
|
testOptions :== Nil,
|
||||||
testResultLogger :== TestResultLogger.Default,
|
testResultLogger :== TestResultLogger.Default,
|
||||||
testFilter in testOnly :== (selectedFilter _)
|
testFilter in testOnly :== (selectedFilter _)
|
||||||
|
|
@ -390,8 +389,7 @@ object Defaults extends BuildCommon
|
||||||
trl.run(streams.value.log, executeTests.value, taskName)
|
trl.run(streams.value.log, executeTests.value, taskName)
|
||||||
},
|
},
|
||||||
testOnly <<= inputTests(testOnly),
|
testOnly <<= inputTests(testOnly),
|
||||||
testQuick <<= inputTests(testQuick),
|
testQuick <<= inputTests(testQuick)
|
||||||
testListeners ++= (if( testReportJUnitXml.value ) Seq(new JUnitXmlTestsListener(target.value.getAbsolutePath)) else Nil)
|
|
||||||
)
|
)
|
||||||
lazy val TaskGlobal: Scope = ThisScope.copy(task = Global)
|
lazy val TaskGlobal: Scope = ThisScope.copy(task = Global)
|
||||||
lazy val ConfigGlobal: Scope = ThisScope.copy(config = Global)
|
lazy val ConfigGlobal: Scope = ThisScope.copy(config = Global)
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,8 @@ object PluginDiscovery
|
||||||
val defaultAutoPlugins = Seq(
|
val defaultAutoPlugins = Seq(
|
||||||
"sbt.plugins.IvyPlugin" -> sbt.plugins.IvyPlugin,
|
"sbt.plugins.IvyPlugin" -> sbt.plugins.IvyPlugin,
|
||||||
"sbt.plugins.JvmPlugin" -> sbt.plugins.JvmPlugin,
|
"sbt.plugins.JvmPlugin" -> sbt.plugins.JvmPlugin,
|
||||||
"sbt.plugins.CorePlugin" -> sbt.plugins.CorePlugin
|
"sbt.plugins.CorePlugin" -> sbt.plugins.CorePlugin,
|
||||||
|
"sbt.plugins.JUnitXmlReportPlugin" -> sbt.plugins.JUnitXmlReportPlugin
|
||||||
)
|
)
|
||||||
val detectedAutoPugins = discover[AutoPlugin](AutoPlugins)
|
val detectedAutoPugins = discover[AutoPlugin](AutoPlugins)
|
||||||
val allAutoPlugins = (defaultAutoPlugins ++ detectedAutoPugins.modules) map { case (name, value) =>
|
val allAutoPlugins = (defaultAutoPlugins ++ detectedAutoPugins.modules) map { case (name, value) =>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package sbt
|
||||||
|
package plugins
|
||||||
|
|
||||||
|
import Def.Setting
|
||||||
|
import Keys._
|
||||||
|
import Project.inConfig
|
||||||
|
import Configurations.Test
|
||||||
|
|
||||||
|
/** A plugin that adds the ability for junit-xml to be generated.
|
||||||
|
*
|
||||||
|
* While this plugin automatically includes its settings, to enable, you need to
|
||||||
|
* add:
|
||||||
|
* {{{
|
||||||
|
* testReportJunitXml in Global := true
|
||||||
|
* }}}
|
||||||
|
*/
|
||||||
|
object JUnitXmlReportPlugin extends AutoPlugin {
|
||||||
|
// TODO - If testing becomes its own plugin, we only rely on the core settings.
|
||||||
|
override def requires = JvmPlugin
|
||||||
|
override def trigger = allRequirements
|
||||||
|
|
||||||
|
// Right now we add to the global test listeners which should capture *all* tests.
|
||||||
|
// It might be a good idea to derive this setting into specific test scopes.
|
||||||
|
override lazy val projectSettings: Seq[Setting[_]] =
|
||||||
|
Seq(
|
||||||
|
testListeners ++= (if( testReportJUnitXml.value ) Seq(new JUnitXmlTestsListener(target.value.getAbsolutePath)) else Nil)
|
||||||
|
)
|
||||||
|
override lazy val globalSettings: Seq[Setting[_]] =
|
||||||
|
Seq(
|
||||||
|
// TODO - in sbt 1.0, this should default to true.
|
||||||
|
testReportJUnitXml :== false
|
||||||
|
)
|
||||||
|
|
||||||
|
override def projectConfigurations: Seq[Configuration] = Seq()
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue