简单build.xml

<?xml version="1.0"?>
<project name="exam" basedir="." default="all">
<property name="name" value="exam" />
<property name="war.dir" value="war" />
<property name="src.common" value="common" />
<property name="src.exam" value="exam" />
<property name="webroot.dir" value="webroot" />
<property name="build.dir" value=".build" />
<property name="dist.dir" value="dist" />
<path id="build-classpath">
<fileset dir="${basedir}/ext-lib">
<include name="*.jar" />
</fileset>
<fileset dir="${webroot.dir}/WEB-INF/lib">
<include name="*.jar" />
</fileset>
</path>
<target name="usage">
<echo message="" />
<echo message="${name} build file" />
<echo
message="------------------------------------------------------" />
<echo message="" />
<echo message="Available targets are:" />
<echo message="" />
<echo message="clean --> Clean output dirs" />
<echo
message="build --> Compile main Java sources and copy libraries" />
<echo message="warfile --> Build the web application archive" />
<echo message="all --> Clean, build, warfile" />
<echo message="" />
</target>
<target name="clean" description="Clean output dirs">
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
</target>
<target name="build"
description="Compile main source tree java files into class files, generate jar files">
<mkdir dir="${build.dir}/classes" />
<javac destdir="${build.dir}/classes" source="1.4" target="1.4"
debug="true" deprecation="false" optimize="false" failonerror="true"
encoding="UTF-8">
<src path="${src.common}" />
<src path="${src.exam}" />
<classpath refid="build-classpath" />
</javac>
<copy todir="${build.dir}/classes">
<fileset dir="${src.common}" excludes="**/*.java" />
<fileset dir="${src.exam}" excludes="**/*.java" />
</copy>
</target>
<target name="warfile" depends="build"
description="Build the web application archive">
<mkdir dir="${dist.dir}" />
<war warfile="${dist.dir}/${name}.war" basedir="${webroot.dir}"
webxml="${webroot.dir}/WEB-INF/web.xml">
<include name="WEB-INF/*.*" />
<exclude name="WEB-INF/web.xml" />
<classes dir="${build.dir}/classes" />
<include name="WEB-INF/lib/**" />
<include name="WEB-INF/pages/**" />
<include name="META-INF/*" />
<exclude name="**/.*" />
</war>
</target>
<target name="all" depends="clean,build,warfile"
description="clean,build,warfile" />
</project>

你可能感兴趣的:(java,xml,Web)