aboutsummaryrefslogtreecommitdiff
path: root/stage2
diff options
context:
space:
mode:
Diffstat (limited to 'stage2')
-rw-r--r--stage2/BasicBuild.scala41
-rw-r--r--stage2/Lib.scala5
-rw-r--r--stage2/libraries.scala1
3 files changed, 46 insertions, 1 deletions
diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala
index 0bdbad7..3a9c958 100644
--- a/stage2/BasicBuild.scala
+++ b/stage2/BasicBuild.scala
@@ -319,4 +319,45 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with SbtDep
final def crossScalaVersionsArray = Array(scalaVersion)
def publish: Seq[URL] = Seq()
+
+ def fork = false
+
+ def runForked: ExitCode = {
+ val ( pid, waitFor, destroy ) = runForkedHandles
+ waitFor()
+ }
+
+ /** currently only produces output when run via cbt direct */
+ def restart: Int = {
+ val pid = restart( mainClassOrFail.getName, context.args )
+ System.err.print("started process with pid: ")
+ pid
+ }
+
+ def restart( className: String, args: Seq[String] ): Int = {
+ val ( pid, waitFor, destroy ) = runForked( mainClassOrFail.getName, context.args )
+ lib.addProcessIdToKillList( context.cwd, pid )
+ pid
+ }
+
+ protected def runForkedHandles = runForked( mainClassOrFail.getName, context.args )
+
+ def runForked( className: String, args: Seq[String] ): ( Int, () => ExitCode, () => ExitCode ) =
+ lib.runMainForked(
+ className,
+ args,
+ classpath.string,
+ Some( context.workingDirectory ),
+ NailgunLauncher.runningViaNailgun.option(
+ lib.getOutErrIn match { case (l,r, in) => (l.get,r.get, in) }
+ )
+ )
+
+ override def runMain( className: String, args: Seq[String] ): ExitCode = {
+ if(fork){
+ runForked(className, args)._2()
+ } else {
+ super.runMain( className, args )
+ }
+ }
}
diff --git a/stage2/Lib.scala b/stage2/Lib.scala
index 56f24c6..8801b33 100644
--- a/stage2/Lib.scala
+++ b/stage2/Lib.scala
@@ -16,7 +16,10 @@ import scala.reflect.NameTransformer
case class Developer(id: String, name: String, timezone: String, url: URL)
/** Don't extend. Create your own libs :). */
-final class Lib(val logger: Logger) extends Stage1Lib(logger){
+final class Lib(val logger: Logger) extends
+ Stage1Lib(logger) with
+ _root_.cbt.process.Module
+{
lib =>
val buildFileName = "build.scala"
diff --git a/stage2/libraries.scala b/stage2/libraries.scala
index 08a7a74..b4515e1 100644
--- a/stage2/libraries.scala
+++ b/stage2/libraries.scala
@@ -14,6 +14,7 @@ class libraries( context: Context, scalaVersion: String, scalaMajorVersion: Stri
def eval = dep( "eval" )
def file = dep( "file" )
def interfaces = dep( "interfaces" )
+ def process = dep( "process" )
def proguard = dep( "proguard" )
def reflect = dep( "reflect" )
def scalatestRunner = dep( "scalatest-runner" )