Jeremy Stein - Brain

« »

Simple build.xml file for Java web application

For future reference, here’s the build.xml for a simple webapp:

<project name="NAME_OF_PROJECT" default="compile" basedir=".">

  <!-- should define:
    J2EE_LIBRARY_PATH - generally just points to the tomcat common/lib
    BUILD_PATH - where to build files (optional)
  <property file=""/>
  <property name="BUILD_PATH" location="build"/>

  <target name="compile" description="compile the source">
    <mkdir dir="${BUILD_PATH}"/>
    <copy todir="${BUILD_PATH}/webapp">
      <fileset dir="web" />
    <mkdir dir="${BUILD_PATH}/webapp/WEB-INF/lib"/>
    <copy todir="${BUILD_PATH}/webapp/WEB-INF/lib">
      <fileset dir="lib" excludes="**/*.zip"/>
    <mkdir dir="${BUILD_PATH}/webapp/WEB-INF/classes"/>
    <javac srcdir="src" destdir="${BUILD_PATH}/webapp/WEB-INF/classes" debug="true" debuglevel="lines,vars,source" source="1.5" target="1.5">
        <fileset dir="lib" />
        <fileset dir="${J2EE_LIBRARY_PATH}" />
      <include name="**/*.java"/>
    <copy todir="${BUILD_PATH}/webapp/WEB-INF/classes">
      <fileset dir="src" excludes="**/*.java"/>

  <target name="dist" depends="compile" description="generate the distribution">
    <zip destfile="${BUILD_PATH}/NAME_OF_PROJECT.war" basedir="${BUILD_PATH}/webapp" />

  <target name="clean" description="remove all generated files">
    <delete includeemptydirs="true">
      <fileset dir="${BUILD_PATH}" includes="*/**"/>

August 2, 2012 No Comments.

No Comments

Be the first to comment!

Leave a Reply

Your email address will not be published. Required fields are marked *

Why ask?

« »