mirror of https://github.com/sbt/sbt.git
Bumping up Scala version to 2.10.5/2.11.6. Fixes #1980
To pass File => Unit callback across the classloader boundary I am encoding it as a java.util.List[File] by overriding method. This was needed since Java didn't allow me to cast from one classloader to the other.
This commit is contained in:
parent
0c1d07dde7
commit
618ac5236a
|
|
@ -24,7 +24,7 @@ def buildLevelSettings: Seq[Setting[_]] = Seq(
|
||||||
)
|
)
|
||||||
|
|
||||||
def commonSettings: Seq[Setting[_]] = Seq(
|
def commonSettings: Seq[Setting[_]] = Seq(
|
||||||
scalaVersion := "2.10.4",
|
scalaVersion := scala210,
|
||||||
publishArtifact in packageDoc := false,
|
publishArtifact in packageDoc := false,
|
||||||
publishMavenStyle := false,
|
publishMavenStyle := false,
|
||||||
componentID := None,
|
componentID := None,
|
||||||
|
|
@ -387,7 +387,7 @@ lazy val scriptedBaseProj = (project in scriptedPath / "base").
|
||||||
)
|
)
|
||||||
|
|
||||||
lazy val scriptedSbtProj = (project in scriptedPath / "sbt").
|
lazy val scriptedSbtProj = (project in scriptedPath / "sbt").
|
||||||
dependsOn (ioProj, logProj, processProj, scriptedBaseProj).
|
dependsOn (ioProj, logProj, processProj, scriptedBaseProj, interfaceProj).
|
||||||
settings(
|
settings(
|
||||||
baseSettings,
|
baseSettings,
|
||||||
name := "Scripted sbt",
|
name := "Scripted sbt",
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ object Dependencies {
|
||||||
lazy val scala282 = "2.8.2"
|
lazy val scala282 = "2.8.2"
|
||||||
lazy val scala292 = "2.9.2"
|
lazy val scala292 = "2.9.2"
|
||||||
lazy val scala293 = "2.9.3"
|
lazy val scala293 = "2.9.3"
|
||||||
lazy val scala210 = "2.10.4"
|
lazy val scala210 = "2.10.5"
|
||||||
lazy val scala211 = "2.11.1"
|
lazy val scala211 = "2.11.6"
|
||||||
|
|
||||||
lazy val jline = "jline" % "jline" % "2.11"
|
lazy val jline = "jline" % "jline" % "2.11"
|
||||||
lazy val ivy = "org.scala-sbt.ivy" % "ivy" % "2.3.0-sbt-fccfbd44c9f64523b61398a0155784dcbaeae28f"
|
lazy val ivy = "org.scala-sbt.ivy" % "ivy" % "2.3.0-sbt-fccfbd44c9f64523b61398a0155784dcbaeae28f"
|
||||||
|
|
|
||||||
|
|
@ -57,15 +57,30 @@ object Scripted {
|
||||||
(token(Space) ~> (PagedIds | testIdAsGroup)).* map (_.flatten)
|
(token(Space) ~> (PagedIds | testIdAsGroup)).* map (_.flatten)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Interface to cross class loader
|
||||||
|
type SbtScriptedRunner = {
|
||||||
|
def run(resourceBaseDirectory: File, bufferLog: Boolean, tests: Array[String], bootProperties: File,
|
||||||
|
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) {
|
def doScripted(launcher: File, scriptedSbtClasspath: Seq[Attributed[File]], scriptedSbtInstance: ScalaInstance, sourcePath: File, args: Seq[String], prescripted: File => Unit) {
|
||||||
System.err.println(s"About to run tests: ${args.mkString("\n * ", "\n * ", "\n")}")
|
System.err.println(s"About to run tests: ${args.mkString("\n * ", "\n * ", "\n")}")
|
||||||
val noJLine = new classpath.FilteredLoader(scriptedSbtInstance.loader, "jline." :: Nil)
|
val noJLine = new classpath.FilteredLoader(scriptedSbtInstance.loader, "jline." :: Nil)
|
||||||
val loader = classpath.ClasspathUtilities.toLoader(scriptedSbtClasspath.files, noJLine)
|
val loader = classpath.ClasspathUtilities.toLoader(scriptedSbtClasspath.files, noJLine)
|
||||||
val m = ModuleUtilities.getObject("sbt.test.ScriptedTests", loader)
|
val bridgeClass = Class.forName("sbt.test.ScriptedRunner", true, loader)
|
||||||
val r = m.getClass.getMethod("run", classOf[File], classOf[Boolean], classOf[Array[String]], classOf[File], classOf[Array[String]], classOf[File => Unit])
|
val bridge = bridgeClass.newInstance.asInstanceOf[SbtScriptedRunner]
|
||||||
val launcherVmOptions = Array("-XX:MaxPermSize=256M") // increased after a failure in scripted source-dependencies/macro
|
val launcherVmOptions = Array("-XX:MaxPermSize=256M") // increased after a failure in scripted source-dependencies/macro
|
||||||
try { r.invoke(m, sourcePath, true: java.lang.Boolean, args.toArray[String], launcher, launcherVmOptions, prescripted) }
|
try {
|
||||||
catch { case ite: java.lang.reflect.InvocationTargetException => throw ite.getCause }
|
// Using java.util.List to encode File => Unit.
|
||||||
|
val callback = new java.util.AbstractList[File] {
|
||||||
|
override def add(x: File): Boolean = {
|
||||||
|
prescripted(x)
|
||||||
|
false
|
||||||
|
}
|
||||||
|
def get(x: Int): sbt.File = ???
|
||||||
|
def size(): Int = 0
|
||||||
|
}
|
||||||
|
bridge.run(sourcePath, true, args.toArray, launcher, launcherVmOptions, callback)
|
||||||
|
} catch { case ite: java.lang.reflect.InvocationTargetException => throw ite.getCause }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
scalaVersion := "2.10.5"
|
||||||
|
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies ++= Seq(
|
||||||
"net.databinder" %% "dispatch-http" % "0.8.9",
|
"net.databinder" %% "dispatch-http" % "0.8.9",
|
||||||
"org.jsoup" % "jsoup" % "1.7.1"
|
"org.jsoup" % "jsoup" % "1.7.1"
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import xsbt.test.{ CommentHandler, FileCommands, ScriptRunner, TestScriptParser
|
||||||
import IO.wrapNull
|
import IO.wrapNull
|
||||||
|
|
||||||
final class ScriptedTests(resourceBaseDirectory: File, bufferLog: Boolean, launcher: File, launchOpts: Seq[String]) {
|
final class ScriptedTests(resourceBaseDirectory: File, bufferLog: Boolean, launcher: File, launchOpts: Seq[String]) {
|
||||||
import ScriptedTests.emptyCallback
|
import ScriptedTests._
|
||||||
private val testResources = new Resources(resourceBaseDirectory)
|
private val testResources = new Resources(resourceBaseDirectory)
|
||||||
|
|
||||||
val ScriptFilename = "test"
|
val ScriptFilename = "test"
|
||||||
|
|
@ -46,6 +46,7 @@ final class ScriptedTests(resourceBaseDirectory: File, bufferLog: Boolean, launc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def scriptedTest(label: String, testDirectory: File, prescripted: File => Unit, log: Logger): Unit =
|
private def scriptedTest(label: String, testDirectory: File, prescripted: File => Unit, log: Logger): Unit =
|
||||||
{
|
{
|
||||||
val buffered = new BufferedLogger(new FullLogger(log))
|
val buffered = new BufferedLogger(new FullLogger(log))
|
||||||
|
|
@ -94,9 +95,9 @@ final class ScriptedTests(resourceBaseDirectory: File, bufferLog: Boolean, launc
|
||||||
} finally { buffered.clear() }
|
} finally { buffered.clear() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
object ScriptedTests {
|
|
||||||
val emptyCallback: File => Unit = { _ => () }
|
|
||||||
|
|
||||||
|
object ScriptedTests extends ScriptedRunner {
|
||||||
|
val emptyCallback: File => Unit = { _ => () }
|
||||||
def main(args: Array[String]) {
|
def main(args: Array[String]) {
|
||||||
val directory = new File(args(0))
|
val directory = new File(args(0))
|
||||||
val buffer = args(1).toBoolean
|
val buffer = args(1).toBoolean
|
||||||
|
|
@ -108,19 +109,27 @@ object ScriptedTests {
|
||||||
val logger = ConsoleLogger()
|
val logger = ConsoleLogger()
|
||||||
run(directory, buffer, tests, logger, bootProperties, Array(), emptyCallback)
|
run(directory, buffer, tests, logger, bootProperties, Array(), emptyCallback)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ScriptedRunner {
|
||||||
|
import ScriptedTests._
|
||||||
|
|
||||||
def run(resourceBaseDirectory: File, bufferLog: Boolean, tests: Array[String], bootProperties: File,
|
def run(resourceBaseDirectory: File, bufferLog: Boolean, tests: Array[String], bootProperties: File,
|
||||||
launchOpts: Array[String]): Unit =
|
launchOpts: Array[String]): Unit =
|
||||||
run(resourceBaseDirectory, bufferLog, tests, ConsoleLogger(), bootProperties, launchOpts, emptyCallback) //new FullLogger(Logger.xlog2Log(log)))
|
run(resourceBaseDirectory, bufferLog, tests, ConsoleLogger(), bootProperties, launchOpts, emptyCallback) //new FullLogger(Logger.xlog2Log(log)))
|
||||||
|
|
||||||
|
// This is called by project/Scripted.scala
|
||||||
|
// Using java.util.List[File] to encode File => Unit
|
||||||
def run(resourceBaseDirectory: File, bufferLog: Boolean, tests: Array[String], bootProperties: File,
|
def run(resourceBaseDirectory: File, bufferLog: Boolean, tests: Array[String], bootProperties: File,
|
||||||
launchOpts: Array[String], prescripted: File => Unit): Unit =
|
launchOpts: Array[String], prescripted: java.util.List[File]): Unit =
|
||||||
run(resourceBaseDirectory, bufferLog, tests, ConsoleLogger(), bootProperties, launchOpts, prescripted) //new FullLogger(Logger.xlog2Log(log)))
|
run(resourceBaseDirectory, bufferLog, tests, ConsoleLogger(), bootProperties, launchOpts,
|
||||||
|
{ f: File => prescripted.add(f); () }) //new FullLogger(Logger.xlog2Log(log)))
|
||||||
|
|
||||||
def run(resourceBaseDirectory: File, bufferLog: Boolean, tests: Array[String], logger: AbstractLogger, bootProperties: File,
|
def run(resourceBaseDirectory: File, bufferLog: Boolean, tests: Array[String], logger: xsbti.Logger, bootProperties: File,
|
||||||
launchOpts: Array[String]): Unit =
|
launchOpts: Array[String]): Unit =
|
||||||
run(resourceBaseDirectory, bufferLog, tests, logger, bootProperties, launchOpts, emptyCallback)
|
run(resourceBaseDirectory, bufferLog, tests, logger, bootProperties, launchOpts, emptyCallback)
|
||||||
|
|
||||||
def run(resourceBaseDirectory: File, bufferLog: Boolean, tests: Array[String], logger: AbstractLogger, bootProperties: File,
|
def run(resourceBaseDirectory: File, bufferLog: Boolean, tests: Array[String], logger: xsbti.Logger, bootProperties: File,
|
||||||
launchOpts: Array[String], prescripted: File => Unit) {
|
launchOpts: Array[String], prescripted: File => Unit) {
|
||||||
val runner = new ScriptedTests(resourceBaseDirectory, bufferLog, bootProperties, launchOpts)
|
val runner = new ScriptedTests(resourceBaseDirectory, bufferLog, bootProperties, launchOpts)
|
||||||
val allTests = get(tests, resourceBaseDirectory, logger) flatMap {
|
val allTests = get(tests, resourceBaseDirectory, logger) flatMap {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue