Skip to content

Instantly share code, notes, and snippets.

@larrycai
Created April 28, 2011 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larrycai/945937 to your computer and use it in GitHub Desktop.
Save larrycai/945937 to your computer and use it in GitHub Desktop.
embed winstone for web application in maven
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<!-- file is based on jenkin's solution https://github.com/jenkinsci/jenkins/commit/f0fa10bd63487e8754c678f2984e5bd655a51aa6
& latest pom.xml
https://github.com/jenkinsci/jenkins/blob/master/war/pom.xml
-->
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.demo</groupId>
<artifactId>helloworld2-war</artifactId>
<packaging>war</packaging>
<name>helloworld2 war</name>
<version>1.0.0</version>
<build>
<finalName>helloworld2</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0</version>
<configuration>
<webResources>
<resource>
<directory>${basedir}/target/generated-resources</directory>
</resource>
</webResources>
<!-- for putting Main-Class into war -->
<archive>
<manifest>
<mainClass>Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.maven-antrun-extended-plugin</groupId>
<artifactId>maven-antrun-extended-plugin</artifactId>
<executions>
<execution>
<id>complie Main</id>
<phase>generate-resources</phase>
<configuration>
<tasks>
<mkdir dir="target/generated-resources" />
<!-- needs to be forked because Maven doesn't seem to put tools.jar
in classpath -->
<javac srcdir="src/launcher/java" includes="Main.java"
source="1.4" target="1.4" destdir="target/generated-resources"
fork="true" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>resgen</id>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<verifyArtifact>false</verifyArtifact>
<tasks>
<mkdir dir="target/generated-resources" />
<!-- put executable war header -->
<resolveArtifact groupId="org.jenkins-ci"
artifactId="executable-war" version="1.19" type="jar"
property="executable-war.jar" />
<unjar src="../target/helloworld2.war" dest="target/generated-resources">
</unjar>
<!-- dependencies that goes to unusual locations -->
<resolveArtifact artifactId="winstone"
tofile="${basedir}/target/generated-resources/winstone.jar" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<!-- not actually used by test but used by antrun plugin to include it
inside the war. -->
<groupId>org.jenkins-ci</groupId>
<artifactId>winstone</artifactId>
<version>0.9.10-jenkins-25</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment