forked from teatrove/teatrove
-
Notifications
You must be signed in to change notification settings - Fork 0
Creating A War File
jappy edited this page Oct 12, 2011
·
2 revisions
Maven is a very useful build tool. Natively it has built in support for generating war files for your project. So let's say that you have setup an application that needs to be deployed as a WAR file that runs on the TeaServlet.
It is generally helpful to setup a separate project/git repository whose sole purpose is to describe your application's deployment. It will have your primary application code repository as a dependency as well as the TeaServlet if your application does not already depend on the TeaServlet.
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycoolcompany</groupId>
<artifactId>coolestappever</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>coolestappever</name>
<url>http://www.mycoolcompany.com</url>
<dependencies>
<dependency>
<groupId>com.mycoolcompany</groupId>
<artifactId>coolestappever-core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- if not included as dependency in coolestappever-core -->
<dependency>
<groupId>org.teatrove</groupId>
<artifactId>barista</artifactId>
<version>4.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>resources</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</project>
.
|-- pom.xml
|-- resource2
| |-- external-resource.jpg
| `-- image2
| `-- external-resource2.jpg
| `-- templates
| `-- helloWorld.tea
| `-- templateClasses
| `-- empty
`-- src
`-- main
|-- java
| `-- com
| `-- example
| `-- projects
| `-- SampleAction.java
|-- resources
| `-- images
| `-- sampleimage.jpg
`-- webapp
|-- WEB-INF
| `-- teaservlet.xml
| `-- web.xml
|-- index.jsp
`-- jsp
`-- websource.jsp
Would end up in the WAR as:
coolestappever-1.0-SNAPSHOT.war
|-- META-INF
| |-- MANIFEST.MF
| `-- maven
| `-- com.mycoolcompany
| `-- coolestappever
| |-- pom.properties
| `-- pom.xml
|-- WEB-INF
| |-- classes
| | |-- com
| | | `-- example
| | | `-- projects
| | | `-- SampleAction.class
| | `-- images
| | `-- sampleimage.jpg
| |-- teaservlet.xml
| `-- web.xml
|-- external-resource.jpg
|-- image2
| `-- external-resource2.jpg
|-- templates
| `-- helloWorld.tea
|-- index.jsp
`-- jsp
`-- websource.jsp