From 98cd577e1d193fe88cabcdfb59b51ee35d4df95c Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Wed, 4 Aug 2010 20:33:50 -0400 Subject: [PATCH] Configure jetty-env.xml. Allows specifying JNDI datasources. Inspired by maven-jetty-plugin. Only takes effect when jettyEnvXml equals Some[File], by default None. Tested with jrebel. --- project/build/XSbt.scala | 2 ++ sbt/src/main/scala/sbt/DefaultProject.scala | 3 +++ web/WebApp.scala | 4 +++- web/jetty6.imports | 5 +++-- web/jetty7.imports | 6 ++++-- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/project/build/XSbt.scala b/project/build/XSbt.scala index 82ad988b3..ae637a259 100644 --- a/project/build/XSbt.scala +++ b/project/build/XSbt.scala @@ -109,9 +109,11 @@ class XSbt(info: ProjectInfo) extends ParentProject(info) with NoCrossPaths class WebAppProject(info: ProjectInfo) extends Base(info) { val jetty = "org.mortbay.jetty" % "jetty" % "6.1.14" % "optional" + val jettyplus = "org.mortbay.jetty" % "jetty-plus" % "6.1.14" % "optional" val jetty7server = "org.eclipse.jetty" % "jetty-server" % "7.0.1.v20091125" % "optional" val jetty7webapp = "org.eclipse.jetty" % "jetty-webapp" % "7.0.1.v20091125" % "optional" + val jetty7plus = "org.eclipse.jetty" % "jetty-plus" % "7.0.1.v20091125" % "optional" val optional = Configurations.Optional diff --git a/sbt/src/main/scala/sbt/DefaultProject.scala b/sbt/src/main/scala/sbt/DefaultProject.scala index 62350fa8d..f08e58dee 100644 --- a/sbt/src/main/scala/sbt/DefaultProject.scala +++ b/sbt/src/main/scala/sbt/DefaultProject.scala @@ -388,6 +388,7 @@ abstract class BasicWebScalaProject extends BasicScalaProject with WebScalaProje def scanInterval = p.scanInterval def port = jettyPort def log = p.log + def jettyEnv = jettyEnvXml } /** This is the classpath used to determine what classes, resources, and jars to put in the war file.*/ def webappClasspath = publicClasspath @@ -420,6 +421,8 @@ abstract class BasicWebScalaProject extends BasicScalaProject with WebScalaProje /** The port that Jetty runs on. */ def jettyPort: Int = JettyRunner.DefaultPort + def jettyEnvXml : Option[File] = None + lazy val jettyReload = task { jettyInstance.reload(); None } describedAs(JettyReloadDescription) lazy val jettyRestart = jettyStop && jettyRun lazy val jettyStop = jettyStopAction diff --git a/web/WebApp.scala b/web/WebApp.scala index 856c781dc..72633cb8f 100644 --- a/web/WebApp.scala +++ b/web/WebApp.scala @@ -95,12 +95,14 @@ trait DefaultJettyConfiguration extends JettyConfiguration def war: Path def scanDirectories: Seq[File] def scanInterval: Int + def contextPath: String def port: Int /** The classpath containing the classes, jars, and resources for the web application. */ def classpath: PathFinder def parentLoader: ClassLoader + def jettyEnv: Option[File] } abstract class CustomJettyConfiguration extends JettyConfiguration { @@ -144,4 +146,4 @@ private class JettyLoggerBase(delegate: AbstractLogger) else sb.append(piece).append(argStr) }.toString } -} \ No newline at end of file +} diff --git a/web/jetty6.imports b/web/jetty6.imports index 3b20abbf1..a950bcd74 100644 --- a/web/jetty6.imports +++ b/web/jetty6.imports @@ -1,7 +1,8 @@ import org.mortbay.jetty.{Handler, Server} import org.mortbay.jetty.nio.SelectChannelConnector - import org.mortbay.jetty.webapp.{WebAppClassLoader, WebAppContext} + import org.mortbay.jetty.webapp.{WebAppClassLoader, WebAppContext, WebInfConfiguration, Configuration, JettyWebXmlConfiguration, TagLibConfiguration, WebXmlConfiguration} import org.mortbay.log.{Log, Logger => JLogger} import org.mortbay.util.Scanner - import org.mortbay.xml.XmlConfiguration \ No newline at end of file + import org.mortbay.xml.XmlConfiguration + import org.mortbay.jetty.plus.webapp.{EnvConfiguration, Configuration=>PlusConfiguration} diff --git a/web/jetty7.imports b/web/jetty7.imports index 35f18d862..18db98175 100644 --- a/web/jetty7.imports +++ b/web/jetty7.imports @@ -1,7 +1,9 @@ import org.eclipse.jetty.server.{Server, Handler} import org.eclipse.jetty.server.nio.SelectChannelConnector - import org.eclipse.jetty.webapp.{WebAppClassLoader, WebAppContext} + import org.eclipse.jetty.webapp.{WebAppClassLoader, WebAppContext, WebInfConfiguration, Configuration, FragmentConfiguration, JettyWebXmlConfiguration, TagLibConfiguration, WebXmlConfiguration} import org.eclipse.jetty.util.log.{Log, Logger => JLogger} import org.eclipse.jetty.util.Scanner - import org.eclipse.jetty.xml.XmlConfiguration \ No newline at end of file + import org.eclipse.jetty.xml.XmlConfiguration + import org.eclipse.jetty.plus.webapp.{EnvConfiguration, Configuration=>PlusConfiguration} +