diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..698740d --- /dev/null +++ b/build.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/project/build.scala b/project/build.scala index f6a4b0f..efecf5f 100644 --- a/project/build.scala +++ b/project/build.scala @@ -41,10 +41,11 @@ "com.novell.ldap" % "jldap" % "2009-10-07", "com.h2database" % "h2" % "1.3.171", "ch.qos.logback" % "logback-classic" % "1.0.6" % "runtime", - "org.eclipse.jetty" % "jetty-webapp" % "8.1.8.v20121106" % "container", - "org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container;provided;test" artifacts (Artifact("javax.servlet", "jar", "jar")) + "org.eclipse.jetty" % "jetty-webapp" % "8.1.8.v20121106" % "compile;container", + "org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "compile;container;provided;test" artifacts (Artifact("javax.servlet", "jar", "jar")) ), - EclipseKeys.withSource := true + EclipseKeys.withSource := true, + packageOptions += Package.MainClass("JettyLauncher") ) ++ seq(Twirl.settings: _*) ) } \ No newline at end of file diff --git a/src/main/java/JettyLauncher.java b/src/main/java/JettyLauncher.java new file mode 100644 index 0000000..6e2cb5d --- /dev/null +++ b/src/main/java/JettyLauncher.java @@ -0,0 +1,24 @@ +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.webapp.WebAppContext; + +import java.net.URL; +import java.security.ProtectionDomain; + +public class JettyLauncher { + public static void main(String[] args) throws Exception { + int port = System.getenv("PORT") != null ? Integer.parseInt(System.getenv("PORT")) : 8080; + Server server = new Server(port); + WebAppContext context = new WebAppContext(); + ProtectionDomain domain = JettyLauncher.class.getProtectionDomain(); + URL location = domain.getCodeSource().getLocation(); + + context.setContextPath("/"); + context.setDescriptor(location.toExternalForm() + "/WEB-INF/web.xml"); + context.setServer(server); + context.setWar(location.toExternalForm()); + + server.setHandler(context); + server.start(); + server.join(); + } +}