Based the previous emails about a war task and discussions held on the irc 
channel between myself, dIon, and Jason, here's a first cut at a 
standardized WAR build process for maven.
  
This email is just the description; by the time I'm done this it will be 
time for bed, and I get little enough sleep as it is. :)  I'll probably do 
a first cut of an implementation tomorrow.

I'm almost certain to have missed a detail or two.  I'm sure dIon will 
point out what I've missed.

Goals
=====

This process is designed to build one war, with little or no modification 
to the POM.

Directory Layout
================

WAR                 Repository
---                 ----------
Static content      src/webapps/${maven.war.name} 
WEB-INF/web.xml     src/conf/${maven.war.name}-web.xml
WEB-INF/classes     ${build.dir}/**/*.class
WEB-INF/lib         Dependent jars from POM (dependencies.set)

Properties
==========

Name                         Description
----                         -----------
maven.war.name               The name of the WAR file.  This must be set - 
                             there is no default value.

maven.war.content            Static content location, defaulting to 
                             src/webapps/${maven.war.name}.

maven.war.classes            The WEB-INF/classes files, defaults to 
                             ${build.dir}/**/*.class

maven.war.lib                The WEB-INF/lib fileset, defaults to the set 
                             of jars from the <dependency> elements.
                             (dIon - how was this to work again?)

maven.war.manifest           The manifest file, defaulting to the standard 
                             Maven manifest.

maven.war.prepareBuildFile   These two properties are used to provide a 
maven.war.prepareBuildTarget hook for doing any additional preparation; 
                             see the "Process" section below.

maven.war.updateBuildFile    These two properties are used to provide a 
maven.war.updateBuildTarget  hook for doing any additiona work on the 
                             generated WAR file; see the "Process" section
                             below.

Build File
==========

The build filename will be build-j2ee.xml and the target to create the war 
is (surprise) war.  The delegator target name is maven:war.  The 
build-j2ee.xml file has all the standard init targets.

Process
=======

1. Delegate to compile and jar-resources in build-maven.xml to create the 
   *.class files and move any resource files into place.

2. If the properties ${maven.war.prepareBuildFile} and
   ${maven.war.prepareBuildTarget} are set, execute

     <ant antfile="${maven.war.prepareBuildFile}"
          target="${maven.war.prepareBuildTarget}" />

   This provides a hook to do any additional prep work (like moving 
   template files in the classes directory, etc.) before creating the war.
   Thanks to Jason for the technique.

3. Create the WAR file : target/${maven.war.name}.war

4. If the properties ${maven.war.updateBuildFile} and 
   ${maven.war.updateBuildTarget} are set, execute

     <ant antfile="${maven.war.updateBuildFile}"
          target="${maven.war.updateBuildTarget}" />

   This provides a hook to do any post processing required on the war 
   file.

Afterwards
==========

You know, I think it would have been faster to simply write the build file 
than this email. :)

Note that while the goal of this process is to build a single war file, 
it can already build mutliple wars with differing web.xml and static 
content with the same set of WEB-INF/classes and WEB-INF/lib files due to 
the use of the ${maven.war.name} property.  Its a start.

Glenn McAllister
SOMA Networks, Inc.










Reply via email to