Permalink
Browse files

Scriptus build now produces executable WAR

The Scriptus maven build now produces a WAR that can also be executed by calling java -jar scriptus.jar. Command-line options exist for the port (-p) and the config file (-c).

Scriptus 0.1.0 will soon be released in this format :-)
  • Loading branch information...
1 parent f4f727c commit cc68bfd165e46471a64b3932ceba608cb5d32256 @ianso committed Dec 2, 2011
View
132 pom.xml
@@ -3,13 +3,16 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.ex337</groupId>
<artifactId>scriptus</artifactId>
- <packaging>jar</packaging>
+ <packaging>war</packaging>
<name>Scriptus</name>
<version>SNAPSHOT</version>
<url>http://maven.apache.org</url>
-
-
-
+
+ <properties>
+ <jetty.version>8.0.4.v20111024</jetty.version>
+ </properties>
+
+
<build>
<finalName>scriptus</finalName>
<resources>
@@ -19,27 +22,11 @@
<include>**/*.*</include>
</includes>
</resource>
- <resource>
- <filtering>true</filtering>
- <directory>build</directory>
- <includes>
- <include>*.*</include>
- </includes>
- </resource>
- <resource>
- <filtering>true</filtering>
- <directory>build/${build.id}</directory>
- <includes>
- <include>**/*.*</include>
- </includes>
- </resource>
- <resource>
- <filtering>false</filtering>
- <directory>build/keymat</directory>
- <includes>
- <include>*.*</include>
- </includes>
- </resource>
+ <!-- <resource> <filtering>true</filtering> <directory>build</directory>
+ <includes> <include>*.*</include> </includes> </resource> <resource> <filtering>true</filtering>
+ <directory>build/${build.id}</directory> <includes> <include>**/*.*</include>
+ </includes> </resource> <resource> <filtering>false</filtering> <directory>build/keymat</directory>
+ <includes> <include>*.*</include> </includes> </resource> -->
</resources>
@@ -52,6 +39,8 @@
</testResources>
<plugins>
+ <!-- This is here for testing: when checked out from GitHub, use mvn jetty:run
+ to launch. -->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
@@ -64,10 +53,36 @@
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
-<!-- <jettyEnvXml>target/test-classes/jetty-env.xml</jettyEnvXml>
- --> <useTestClasspath>true</useTestClasspath>
+ <useTestClasspath>true</useTestClasspath>
</configuration>
</plugin>
+ <!-- This builds the executable WAR file -->
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-5</version>
+ <configuration>
+ <finalName>scriptus</finalName>
+ <appendAssemblyId>false</appendAssemblyId>
+ <archive>
+ <manifest>
+ <mainClass>net.ex337.scriptus.server.ScriptusFrontend</mainClass>
+ </manifest>
+ </archive>
+ <descriptors>
+ <descriptor>src/main/assembly/executable-webapp.xml</descriptor>
+ </descriptors>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+
+ </plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
@@ -92,7 +107,6 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
- <!-- version>2.0</version -->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -144,11 +158,47 @@
<dependencies>
-
+
+ <!--
+ the provided dependencies are used
+ to construct the executable WAR file.
+ -->
+
+ <dependency>
+ <groupId>org.eclipse.jetty.aggregate</groupId>
+ <artifactId>jetty-webapp</artifactId>
+ <version>${jetty.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty.aggregate</groupId>
+ <artifactId>jetty-webapp</artifactId>
+ <version>${jetty.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.8</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-nop</artifactId>
+ <version>1.5.8</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jsp-2.1-glassfish</artifactId>
+ <version>2.1.v20100127</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
- <version>2.4</version>
+ <version>2.5</version>
+ <scope>provided</scope>
</dependency>
<dependency>
@@ -175,11 +225,11 @@
<version>4.1.1</version>
</dependency>
-<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>r08</version>
-</dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>r08</version>
+ </dependency>
<dependency>
<groupId>org.twitter4j</groupId>
@@ -196,13 +246,9 @@
<artifactId>js</artifactId>
<version>1.7R3.patched</version>
</dependency>
-<!--
+ <!-- <dependency> <groupId>rhino</groupId> <artifactId>js</artifactId>
+ <version>1.7R2</version> </dependency> -->
<dependency>
- <groupId>rhino</groupId>
- <artifactId>js</artifactId>
- <version>1.7R2</version>
- </dependency>
- --> <dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.3</version>
@@ -241,7 +287,7 @@
<version>3.0.5.RELEASE</version>
<scope>compile</scope>
</dependency>
-
+
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
@@ -271,7 +317,7 @@
</dependency>
</dependencies>
- <!--repo for temporarily patched libraries, like Rhino-->
+ <!--repo for temporarily patched libraries, like Rhino -->
<repositories>
<repository>
<id>ianso-github</id>
View
@@ -1,24 +1,33 @@
mvnDebug jetty:run -Dscriptus.config=test-scriptus.properties
mvnDebug jetty:run -Dscriptus.config=command-line-scriptus.properties
+
+ mvn install -Dmaven.test.skip=true
+ mvn cobertura:clean clean site -server -Dmaven.test.skip=false mvn jetty:run -Dmaven.test.skip=false -P T2
+ mvn -Dtest=ResearchCase_PostgreSQLProxyTesting -PT1 test-compile surefire:test
-!! WAR deployable for v0.1.0 & executable JAR?
+X!! executable WAR deployable for v0.1.0
+ - documentation
-test regexp based responses in dummy
+ improve first page of minisite
+ - better focus, call to action
+ improve internal first-time experience
+ - hardlinks to links to API documentation & known problems
+ - more links + content when new
-
twitter integration
test - listen
+ - habit judo from metafilter
+ -> see detials in script habitJudo.js
+ -> rate or just every X days? ask the guy
+
- line diet
- simple calculus
desired weight is healthy,
desired rate of weight loss is medically safe (ask for age maybe?)
- need to reverse-engineer curves
- - habit judo from metafilter
- -> see detials in script habitJudo.js
- -> rate or just every X days
- multi-user scripts:
- secret santa!
- auction
@@ -32,6 +41,7 @@ test - listen
medium
Amazon AMI for playing with Scriptus
low
+ add WAR filter to prevent traversal, downloading class files
pids should be URNs: "pid:12345";
docs: easy to write annoying, difficult to be considerate...
move outstanding stuff to github tasks
@@ -53,9 +63,6 @@ still a newbie? mefi projects?
- upgrade firmware, finally
blog posts
- idea of 'slow code'
- ask friends for feedback
-followup JavaScript Weekly
- ?feedback from this guy (rhino maintainer, works @ twitter): constc.blogspot.com
@@ -66,11 +73,9 @@ followup JavaScript Weekly
While I was thinking about the kind of programs I could write with Scriptus, I realised that my general concept of 'execution' was quite limiting, because it limited me to in-memory processes. Once execution can happen anywhere, like in the XKCD cartoon(http://xkcd.com/505/), we can use it for anything, on any scale.
-For example, how an election works is common knowledge. The process of nomination, candidature, campaigning and voting takes months, but is procedurally simple at heart. How do we write a program that that will let anybody run an election?
-
-The right answer is to write the program and then think about how to run it.
+For example, how an election works is common knowledge. The process of nomination, candidature, campaigning and voting takes months, but is procedurally simple at heart. How do we write a program that that will let anybody run an election?
-This is some that Tim O'Reilly
+The answer is to write the program and then think about how to run it. Once we expand the idea of programming to include many of the things that encompass everyday life, it becomes easier to think about Tim O'Reilly's idea of "working on stuff that matters".
@@ -456,4 +461,16 @@ X docd $ elect 2 "widget experts" | debate "Should widgets be splunked?"
X docd lessons learnt from reminders.js:
X docd eval(get) means your script has to run onlne
X docd -> good reason to have a filesystem
+X test regexp based responses in dummy
+X followup JavaScript Weekly
+X no ?feedback from this guy (rhino maintainer, works @ twitter): constc.blogspot.com
+X done ask friends for feedback
+X & executable JAR?
+X no - spring handlers merging
+X - file name corrections?
+X yes! - can we get it all in one file?
+X command-line options (
+X port,
+X test config file)
+X comment POM & assembly files...
@@ -0,0 +1,41 @@
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <!-- This assembly produces an executable WAR from a basic WAR file.
+ The only bit which is specific to Scriptus is the main class below.
+ -->
+ <id>executable-webapp</id>
+ <formats>
+ <format>war</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <fileSets>
+ <!-- we only take the 'Main' class from the actual project, that launches
+ the Jetty server. -->
+ <fileSet>
+ <directory>${project.build.directory}/classes</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>net/ex337/scriptus/server/ScriptusFrontend.class</include>
+ <include>log4j.properties</include>
+ </includes>
+ </fileSet>
+ <!-- We take everything that was built for that WAR. -->
+ <fileSet>
+ <directory>${project.build.directory}/${project.artifactId}</directory>
+ <outputDirectory>/</outputDirectory>
+ </fileSet>
+ </fileSets>
+ <dependencySets>
+ <!-- We take all the 'provided' libraries which are in fact the application
+ server, servlet & JSP spec etc. They're loaded at the application server
+ level. -->
+ <dependencySet>
+ <outputDirectory>/</outputDirectory>
+ <useProjectArtifact>true</useProjectArtifact>
+ <unpack>true</unpack>
+ <scope>provided</scope>
+ </dependencySet>
+ </dependencySets>
+</assembly>
@@ -2,6 +2,7 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -39,7 +40,9 @@
*/
public class ScriptusConfig implements AWSCredentials {
- public static enum TransportType {Twitter, CommandLine, Dummy};
+ public static final String SCRIPTUS_CONFIG_SYSVAR = "scriptus.config";
+
+ public static enum TransportType {Twitter, CommandLine, Dummy};
public static enum DatastoreType {Aws, File, Memory};
public static final String DURATION_FORMAT="([0-9]+)[\\ ,]*([smhdwMqyDC])";
@@ -103,9 +106,9 @@ public void init() throws IOException {
configLocation = defaultConfigLocation;
- if(System.getProperty("scriptus.config") != null) {
-
- configLocation = System.getProperty("scriptus.config");
+ if(System.getProperty(SCRIPTUS_CONFIG_SYSVAR) != null) {
+
+ configLocation = System.getProperty(SCRIPTUS_CONFIG_SYSVAR);
Properties props = new Properties();
@@ -122,15 +125,21 @@ public void init() throws IOException {
configStream = new URL(configLocation).openStream();
} catch(MalformedURLException mfe) {
-
+
configStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(configLocation);
}
+ if(configStream == null) try {
+ configStream = new FileInputStream(configLocation);
+ } catch(FileNotFoundException fnfe) {
+ //do nothing...
+ }
+
boolean canLoadConfig = (configStream != null);
if(canLoadConfig) {
-
+
props.load(configStream);
load(props);
Oops, something went wrong.

0 comments on commit cc68bfd

Please sign in to comment.