Programming
12 May 2012 1 Comment

How Maven Builds a WAR File

Introduction

When dealing with a Java Web applications, the completed application is commonly delivered as a WAR file. The Maven build system can easily be set up to create WAR files. In this post we take an in-depth look at how Maven goes from a source project to the final WAR product.

Used software: Apache Maven 3.0.4.

The structure of a WAR file looks like this (source):

Example Project

Let’s look at a very simple Mavenized Web application project in a directory named myprojectname. The contents of this folder are:

The pom.xml file looks like this:

 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">
  >4.0.0>
  >mygroup.com>
  >myprojectname>
  >war>
  >1.0-SNAPSHOT>
  >myprojectname Maven Webapp>
  >http://maven.apache.org