Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit 5e41a47f50e6e433c39f3d8e725069a30804f207 1 parent 8d2275c
Trond Bjerkestrand tbje authored committed
4 project/build/SbtProject.scala
View
@@ -42,9 +42,11 @@ abstract class SbtProject(info: ProjectInfo) extends DefaultProject(info) with t
val ivy = "org.apache.ivy" % "ivy" % "2.1.0" intransitive()
val jsch = "com.jcraft" % "jsch" % "0.1.31" intransitive()
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 testInterface = "org.scala-tools.testing" % "test-interface" % "0.5"
@@ -80,4 +82,4 @@ abstract class SbtProject(info: ProjectInfo) extends DefaultProject(info) with t
}
def processJettyTemplate(template: String, version: String, imports: String): String =
template.replaceAll("""\Q${jetty.version}\E""", version).replaceAll("""\Q${jetty.imports}\E""", imports)
-}
+}
3  sbt/src/main/scala/sbt/DefaultProject.scala
View
@@ -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
4 sbt/src/main/scala/sbt/WebApp.scala
View
@@ -96,12 +96,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
{
@@ -145,4 +147,4 @@ private class JettyLoggerBase(delegate: Logger)
else sb.append(piece).append(argStr)
}.toString
}
-}
+}
16 sbt/src/main/scala/sbt/jetty/LazyJettyRun.scala.templ
View
@@ -1,3 +1,4 @@
+
package sbt.jetty
import java.io.File
@@ -69,9 +70,24 @@ private object LazyJettyRun${jetty.version} extends JettyRun
}
def setLoader() = webapp.setClassLoader(createLoader)
+ // enable loading of custom jetty-env.xml file.
+ jettyEnv.foreach{jettyEnvFile:File =>
+ val envConfig = new EnvConfiguration
+ envConfig.setJettyEnvXml(jettyEnvFile.toURL)
+ val confArray : Array[Configuration] = Array(
+ new WebInfConfiguration,
+ new WebXmlConfiguration,
+ envConfig,
+ new PlusConfiguration,
+ new JettyWebXmlConfiguration,
+ new TagLibConfiguration)
+ webapp.setConfigurations(confArray)
+ }
+
setLoader()
server.setHandler(webapp)
+
val listener = new Scanner.BulkListener with Reload {
def reloadApp() = reload(server, setLoader(), log)
def filesChanged(files: java.util.List[_]) { reloadApp() }
5 sbt/src/main/scala/sbt/jetty/jetty6.imports
View
@@ -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
+ import org.mortbay.xml.XmlConfiguration
+ import org.mortbay.jetty.plus.webapp.{EnvConfiguration, Configuration=>PlusConfiguration}
6 sbt/src/main/scala/sbt/jetty/jetty7.imports
View
@@ -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
+ import org.eclipse.jetty.xml.XmlConfiguration
+ import org.eclipse.jetty.plus.webapp.{EnvConfiguration, Configuration=>PlusConfiguration}
+
Please sign in to comment.
Something went wrong with that request. Please try again.