对web工程打包的简单Ant文件

<?xml version="1.0" encoding="UTF-8"?>
<project name="Packaging Generator" default="newReport_war" basedir=".">
	<!--公共基础组件 -->
	<property name="commonLibDir" value="WebContent/WEB-INF/lib" />
	
	<!-- tomcat库文件-->
	<!--property name="tomcatLibDir" value="/usr/local/tomcat/common/lib" /-->
	<property name="tomcatLibDir" value="C:/Tomcat5.5.26/common/lib" />

	<property name="WebContent" value="WebContent"></property>
	<property name="build" value="build/classes" />
	
	<!--初始化 -->
	<target name="init">
	</target>
	<!-- 编译路径 -->
	<path id="compile-classpath">
                <fileset dir="${commonLibDir}" includes="**/*.jar" />
				<fileset dir="${tomcatLibDir}" includes="**/*.jar" />
    </path>
	
	<!-- 删除原有包-->
	<target name="clean">
		<delete file="newReport.war"></delete>
		<delete dir="build"></delete>
	</target>
	

	<!-- 编译-->
	<target name="compile">
		<mkdir dir="${build}" />
		<javac srcdir="src"  destdir="${build}" source="1.5">
			<compilerarg  line="-encoding GBK -Xlint:unchecked" />
			<classpath refid="compile-classpath" />
		</javac>	
	</target>

	
	<!--打包War文件-->
	<target name="newReport.war" description="package newReport war">
		<jar destfile="newReport.war">
			
			<zipfileset dir="${WebContent}" excludes="**/*.jar"/>
			<zipfileset dir="${commonLibDir}" prefix="WEB-INF/lib" includes="**/*.jar" />
			<zipfileset dir="${build}" prefix="WEB-INF/classes"/>
		</jar>
	</target>
	
	<!-- 执行-->
	<target name="newReport_war" depends="clean,compile,newReport.war" />
</project>

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