Skip to content
Browse files

containerless jetty

  • Loading branch information...
1 parent 0b830f5 commit a2ac9eba420f2cb61fa08c20075f376b8a3ac4f3 @jamesward committed Mar 23, 2012
View
1 .gitignore
@@ -8,3 +8,4 @@ bin/
*.ipr
*.iws
gradle.properties
+/out
View
10 build.gradle
@@ -1,4 +1,10 @@
+apply plugin: 'java'
apply plugin: 'ratpack'
+apply plugin: 'application'
+apply plugin: 'idea'
+
+mainClassName = "Main"
+applicationName = "app"
buildscript {
repositories {
@@ -11,9 +17,11 @@ buildscript {
dependencies {
groovy 'org.codehaus.groovy:groovy:1.8.6'
+ compile 'com.augusttechgroup:ratpack-plugin:0.5.1'
}
task wrapper(type: Wrapper) {
- gradleVersion = '1.0-milestone-8a'
+ gradleVersion = '1.0-milestone-9'
}
+task stage(dependsOn: ['clean', 'installApp'])
View
BIN gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
View
4 gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Mon Mar 12 10:17:22 MDT 2012
+#Fri Mar 23 05:55:56 MDT 2012
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.0-milestone-8a-bin.zip
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.0-milestone-9-bin.zip
View
39 src/main/java/Main.java
@@ -0,0 +1,39 @@
+import com.bleedingwolf.ratpack.RatpackServlet;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.ContextHandler;
+import org.mortbay.jetty.servlet.ServletHandler;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+public class Main {
+
+ private static final String APP_SCRIPT_FILENAME_PARAM_NAME = "app-script-filename";
+
+ public static void main(String[] args) throws Exception {
+ final String webappDirLocation = "src/main/webapp/";
+ final String appScriptFilename = "app.groovy";
+
+ //The port that we should run on can be set into an environment variable
+ //Look for that variable and default to 8080 if it isn't there.
+ String webPort = System.getenv("PORT");
+ if(webPort == null || webPort.isEmpty()) {
+ webPort = "8080";
+ }
+
+ ServletHolder servletHolder = new ServletHolder(new RatpackServlet());
+ servletHolder.setInitParameter(APP_SCRIPT_FILENAME_PARAM_NAME, appScriptFilename);
+
+ ServletHandler servletHandler = new ServletHandler();
+ servletHandler.addServletWithMapping(servletHolder, "/*");
+
+ ContextHandler contextHandler = new ContextHandler("/");
+ contextHandler.addHandler(servletHandler);
+ contextHandler.setResourceBase(webappDirLocation);
+
+ Server server = new Server(Integer.valueOf(webPort));
+ server.setHandler(contextHandler);
+
+ server.start();
+ server.join();
+ }
+
+}
View
0 src/app/resources/templates/index.html → src/main/resources/index.html
File renamed without changes.
View
0 src/app/resources/scripts/app.groovy → src/main/webapp/WEB-INF/scripts/app.groovy
File renamed without changes.

0 comments on commit a2ac9eb

Please sign in to comment.
Something went wrong with that request. Please try again.