From 4886d95efa0c63cd4c6ac4725e713eb907eed094 Mon Sep 17 00:00:00 2001 From: dmharrah Date: Wed, 1 Jul 2009 04:57:20 +0000 Subject: [PATCH] new `jetty` action that waits for a key press before terminating (intended to be used from batch-style) git-svn-id: https://simple-build-tool.googlecode.com/svn/trunk@828 d89573ee-9141-11dd-94d4-bdf5e562f29c --- boot/src/main/scala/ProjectProperties.scala | 4 ++-- src/main/scala/sbt/DefaultProject.scala | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/boot/src/main/scala/ProjectProperties.scala b/boot/src/main/scala/ProjectProperties.scala index d63da6c4b..4f0a0df08 100644 --- a/boot/src/main/scala/ProjectProperties.scala +++ b/boot/src/main/scala/ProjectProperties.scala @@ -9,7 +9,7 @@ Name: Organization []: Version [1.0]: Scala version [2.7.5]: -sbt version [0.5]: +sbt version [0.5.1]: */ import java.io.File /** Constants related to reading/writing the build.properties file in a project. @@ -48,7 +48,7 @@ private object ProjectProperties /** The default version of the new user project when the user doesn't explicitly specify a version when prompted.*/ val DefaultVersion = "1.0" /** The default version of sbt when the user doesn't explicitly specify a version when prompted.*/ - val DefaultSbtVersion = "0.5" + val DefaultSbtVersion = "0.5.1" /** The default version of Scala when the user doesn't explicitly specify a version when prompted.*/ val DefaultScalaVersion = "2.7.5" diff --git a/src/main/scala/sbt/DefaultProject.scala b/src/main/scala/sbt/DefaultProject.scala index 554f98472..ba65239b6 100644 --- a/src/main/scala/sbt/DefaultProject.scala +++ b/src/main/scala/sbt/DefaultProject.scala @@ -315,8 +315,22 @@ abstract class BasicWebScalaProject extends BasicScalaProject with WebScalaProje def jettyRunClasspath = testClasspath def jettyWebappPath = temporaryWarPath lazy val jettyRun = jettyRunAction + lazy val jetty = task { idle() } dependsOn(jettyRun) describedAs(JettyDescription) protected def jettyRunAction = jettyRunTask(jettyWebappPath, jettyContextPath, jettyPort, jettyRunClasspath, "test", scanDirectories.map(_.asFile), scanInterval) dependsOn(prepareWebapp) describedAs(JettyRunDescription) + private def idle() = + { + log.info("Waiting... (press any key to interrupt)") + def doWait() + { + try { Thread.sleep(1000) } catch { case _: InterruptedException => () } + if(System.in.available() <= 0) + doWait() + } + doWait() + while (System.in.available() > 0) System.in.read() + None + } /** The directories that should be watched to determine if the web application needs to be reloaded..*/ def scanDirectories: Seq[Path] = jettyWebappPath :: Nil @@ -408,6 +422,8 @@ object BasicWebScalaProject "Stops the Jetty server that was started with the jetty-run action." val JettyRunDescription = "Starts the Jetty server and serves this project as a web application." + val JettyDescription = + "Starts the Jetty server and serves this project as a web application. Waits until interrupted, so it is suitable to call this batch-style." } /** Analyzes the dependencies of a project after compilation. All methods except `snapshot` return a * `PathFinder`. The underlying calculations are repeated for each call to PathFinder.get. */