http://hi.baidu.com/dancemachine/blog/item/e949520e74f096c87bcbe115.html
http://blog.csdn.net/ln831015/archive/2007/08/13/1740869.aspx
转)用Ant打war包Build.xml全攻略
<project basedir="." default="usage" name="myceaas">
<target name="init"> <property name="Name" value="myceaas" /> <echo message="----------- ${Name} ${version} [${year}] ------------" /> <property name="debug" value="off" /> <!--<property name="mycedatasycn.location" value="D:/project/myce/mycedatasycn" />--> <!-- java源文件路径 --> <!-- jar包路径 --> <!-- webapp路径 --> <!-- 准备源文件路径 --> <!-- 编译源文件路径 --> <!-- 准备webapp文件路径 --> <!-- 准备javadoc文件路径 --> <!-- 打包jar文件路径 --> <!-- 打包war文件路径 --> <!-- tomcat-home路径 --> <!-- classpath --> <filter token="year" value="${year}" /> </target> <!-- =================================================================== --> <!-- =================================================================== --> <!-- =================================================================== --> <!-- =================================================================== --> <!-- =================================================================== --> |
------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="war" name="bid">
<property name="app-name" value="bid" />
<property name="release-version" value="20060720-1549" />
<property name="src" value="src" />
<property name="dist" value="dist" />
<property name="classes" value="WebRoot/WEB-INF/classes" />
<property name="lib" value="WebRoot/WEB-INF/lib" />
<property name="ext-lib" value="ext-lib" />
<property name="charset" value="UTF-8" />
<property name="javadoc-packagenames" value="com.safemore.bid,com.safemore.bid.bid,com.safemore.bid.common,com.safemore.bid.issue,com.safemore.bid.logon,com.safemore.bid.util" />
<patternset id="resources">
<include name="**/*.jpe" />
<include name="**/*.jpeg" />
<include name="**/*.rmf" />
<include name="**/*.wav" />
<include name="**/*.midi" />
<include name="**/*.mid" />
<include name="**/*.au" />
<include name="**/*.gif" />
<include name="**/*.png" />
<include name="**/*.jpg" />
<include name="**/*.aiff" />
<include name="**/*.properties" />
<include name="**/*.txt" />
<include name="**/*.xml" />
</patternset>
<path id="classpath">
<pathelement location="${dist}" />
<fileset dir="${lib}">
<include name="*.jar" />
</fileset>
<fileset dir="${ext-lib}">
<include name="*.jar" />
</fileset>
</path>
<target name="init">
<mkdir dir="${dist}" />
<mkdir dir="${classes}" />
</target>
<target name="war" depends="resource, jar">
<!--touch file="WEB-INF/web.xml"/-->
<war compress="false" destfile="${dist}/${app-name}-${release-version}.war" webxml="WebRoot/WEB-INF/web.xml">
<fileset dir="WebRoot">
<include name="**/*.*" />
<exclude name="WEB-INF/" />
</fileset>
<fileset dir="WebRoot">
<include name="WEB-INF/*.*" />
<exclude name="WEB-INF/web.xml" />
<exclude name="WEB-INF/${app-name}.xml" />
<exclude name="lib/" />
</fileset>
<lib dir="${lib}">
<include name="*.jar" />
</lib>
<!--
<lib dir="${dist}">
<include name="*.jar" />
</lib>
-->
<classes dir="${classes}" />
</war>
</target>
<target name="resource">
<copy todir="${classes}">
<fileset dir="${src}">
<patternset refid="resources" />
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${classes}" />
<delete dir="${dist}" />
</target>
<target name="compile" depends="init">
<javac classpathref="classpath" debug="true" deprecation="false" destdir="${classes}" nowarn="false" encoding="${charset}">
<src path="${src}" />
</javac>
</target>
<target name="jar" depends="resource, compile, init">
<jar compress="false" destfile="${dist}/${app-name}-${release-version}.jar">
<fileset dir="${classes}">
<include name="**/*.class" />
<patternset refid="resources" />
</fileset>
</jar>
</target>
<target name="rejar" depends="clean, jar" />
<target name="ear" depends="war">
<ear destfile="${dist}/${app-name}-${release-version}.ear" appxml="META-INF/application-j1.3.xml">
<fileset dir="${dist}" includes="${app-name}-${release-version}.war" />
</ear>
</target>
<target name="release" depends="war">
<zip destfile="${dist}/${app-name}-${release-version}.zip">
<zipfileset dir="${dist}" includes="${app-name}-${release-version}.war" prefix="." />
<zipfileset dir="db" includes="*.*" prefix="db" />
<zipfileset dir="doc" includes="*.*" prefix="doc" />
</zip>
</target>
<target name="javadoc">
<javadoc encoding="${charset}" charset="${charset}" access="public" author="true" destdir="${dist}/javadoc" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" source="1.5" splitindex="true" use="true" version="true" packagenames="${javadoc-packagenames}" sourcepath="${src}" classpathref="classpath" />
</target>
</project>