mirror of https://github.com/sbt/sbt.git
Merge pull request #2528 from eed3si9n/wip/scripted_issue
Implements scriptedBufferLog on sbt build
This commit is contained in:
commit
6b6fd305ff
30
build.sbt
30
build.sbt
|
|
@ -1,6 +1,5 @@
|
|||
import Util._
|
||||
import Dependencies._
|
||||
import Scripted._
|
||||
import Sxr.sxr
|
||||
|
||||
import com.typesafe.tools.mima.core._, ProblemFilters._
|
||||
|
|
@ -52,6 +51,7 @@ def testedBaseSettings: Seq[Setting[_]] =
|
|||
baseSettings ++ testDependencies
|
||||
|
||||
lazy val sbtRoot: Project = (project in file(".")).
|
||||
enablePlugins(ScriptedPlugin).
|
||||
configs(Sxr.sxrConf).
|
||||
aggregate(nonRoots: _*).
|
||||
settings(
|
||||
|
|
@ -210,19 +210,20 @@ lazy val mavenResolverPluginProj = (project in file("sbt-maven-resolver")).
|
|||
)
|
||||
|
||||
def scriptedTask: Def.Initialize[InputTask[Unit]] = Def.inputTask {
|
||||
val result = scriptedSource(dir => (s: State) => scriptedParser(dir)).parsed
|
||||
val result = scriptedSource(dir => (s: State) => Scripted.scriptedParser(dir)).parsed
|
||||
publishAll.value
|
||||
doScripted((sbtLaunchJar in bundledLauncherProj).value, (fullClasspath in scriptedSbtProj in Test).value,
|
||||
(scalaInstance in scriptedSbtProj).value, scriptedSource.value, result, scriptedPrescripted.value)
|
||||
Scripted.doScripted((sbtLaunchJar in bundledLauncherProj).value, (fullClasspath in scriptedSbtProj in Test).value,
|
||||
(scalaInstance in scriptedSbtProj).value,
|
||||
scriptedSource.value, scriptedBufferLog.value, result, scriptedPrescripted.value)
|
||||
}
|
||||
|
||||
def scriptedUnpublishedTask: Def.Initialize[InputTask[Unit]] = Def.inputTask {
|
||||
val result = scriptedSource(dir => (s: State) => scriptedParser(dir)).parsed
|
||||
doScripted((sbtLaunchJar in bundledLauncherProj).value, (fullClasspath in scriptedSbtProj in Test).value,
|
||||
(scalaInstance in scriptedSbtProj).value, scriptedSource.value, result, scriptedPrescripted.value)
|
||||
val result = scriptedSource(dir => (s: State) => Scripted.scriptedParser(dir)).parsed
|
||||
Scripted.doScripted((sbtLaunchJar in bundledLauncherProj).value, (fullClasspath in scriptedSbtProj in Test).value,
|
||||
(scalaInstance in scriptedSbtProj).value,
|
||||
scriptedSource.value, scriptedBufferLog.value, result, scriptedPrescripted.value)
|
||||
}
|
||||
|
||||
lazy val publishAll = TaskKey[Unit]("publish-all")
|
||||
lazy val publishLauncher = TaskKey[Unit]("publish-launcher")
|
||||
|
||||
lazy val myProvided = config("provided") intransitive
|
||||
|
|
@ -239,18 +240,17 @@ def rootSettings = fullDocSettings ++
|
|||
Util.publishPomSettings ++ otherRootSettings ++ Formatting.sbtFilesSettings ++
|
||||
Transform.conscriptSettings(bundledLauncherProj)
|
||||
def otherRootSettings = Seq(
|
||||
Scripted.scriptedPrescripted := { _ => },
|
||||
Scripted.scripted <<= scriptedTask,
|
||||
Scripted.scriptedUnpublished <<= scriptedUnpublishedTask,
|
||||
Scripted.scriptedSource := (sourceDirectory in sbtProj).value / "sbt-test",
|
||||
scripted <<= scriptedTask,
|
||||
scriptedUnpublished <<= scriptedUnpublishedTask,
|
||||
scriptedSource := (sourceDirectory in sbtProj).value / "sbt-test",
|
||||
publishAll := {
|
||||
val _ = (publishLocal).all(ScopeFilter(inAnyProject)).value
|
||||
},
|
||||
aggregate in bintrayRelease := false
|
||||
) ++ inConfig(Scripted.MavenResolverPluginTest)(Seq(
|
||||
Scripted.scripted <<= scriptedTask,
|
||||
Scripted.scriptedUnpublished <<= scriptedUnpublishedTask,
|
||||
Scripted.scriptedPrescripted := { f =>
|
||||
scripted <<= scriptedTask,
|
||||
scriptedUnpublished <<= scriptedUnpublishedTask,
|
||||
scriptedPrescripted := { f =>
|
||||
val inj = f / "project" / "maven.sbt"
|
||||
if (!inj.exists) {
|
||||
IO.write(inj, "addMavenResolverPlugin")
|
||||
|
|
|
|||
|
|
@ -4,13 +4,30 @@ import Def.Initialize
|
|||
|
||||
import scala.language.reflectiveCalls
|
||||
|
||||
object Scripted {
|
||||
def scriptedPath = file("scripted")
|
||||
object ScriptedPlugin extends sbt.AutoPlugin {
|
||||
override def requires = plugins.JvmPlugin
|
||||
object autoImport extends ScriptedKeys {
|
||||
def scriptedPath = file("scripted")
|
||||
}
|
||||
|
||||
import autoImport._
|
||||
import Scripted._
|
||||
override def projectSettings = Seq(
|
||||
scriptedBufferLog := true,
|
||||
scriptedPrescripted := { _ => }
|
||||
)
|
||||
}
|
||||
|
||||
trait ScriptedKeys {
|
||||
lazy val publishAll = TaskKey[Unit]("publish-all")
|
||||
lazy val scripted = InputKey[Unit]("scripted")
|
||||
lazy val scriptedUnpublished = InputKey[Unit]("scripted-unpublished", "Execute scripted without publishing SBT first. Saves you some time when only your test has changed.")
|
||||
lazy val scriptedSource = SettingKey[File]("scripted-source")
|
||||
lazy val scriptedPrescripted = TaskKey[File => Unit]("scripted-prescripted")
|
||||
lazy val scriptedBufferLog = SettingKey[Boolean]("scripted-buffer-log")
|
||||
}
|
||||
|
||||
object Scripted {
|
||||
lazy val MavenResolverPluginTest = config("mavenResolverPluginTest") extend Compile
|
||||
|
||||
import sbt.complete._
|
||||
|
|
@ -66,7 +83,8 @@ object Scripted {
|
|||
launchOpts: Array[String], prescripted: java.util.List[File]): Unit
|
||||
}
|
||||
|
||||
def doScripted(launcher: File, scriptedSbtClasspath: Seq[Attributed[File]], scriptedSbtInstance: ScalaInstance, sourcePath: File, args: Seq[String], prescripted: File => Unit): Unit = {
|
||||
def doScripted(launcher: File, scriptedSbtClasspath: Seq[Attributed[File]], scriptedSbtInstance: ScalaInstance,
|
||||
sourcePath: File, bufferLog: Boolean, args: Seq[String], prescripted: File => Unit): Unit = {
|
||||
System.err.println(s"About to run tests: ${args.mkString("\n * ", "\n * ", "\n")}")
|
||||
val noJLine = new classpath.FilteredLoader(scriptedSbtInstance.loader, "jline." :: Nil)
|
||||
val loader = classpath.ClasspathUtilities.toLoader(scriptedSbtClasspath.files, noJLine)
|
||||
|
|
@ -83,7 +101,7 @@ object Scripted {
|
|||
def get(x: Int): sbt.File = ???
|
||||
def size(): Int = 0
|
||||
}
|
||||
bridge.run(sourcePath, true, args.toArray, launcher, launcherVmOptions, callback)
|
||||
bridge.run(sourcePath, bufferLog, args.toArray, launcher, launcherVmOptions, callback)
|
||||
} catch { case ite: java.lang.reflect.InvocationTargetException => throw ite.getCause }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue