初步学习ant,因难度较低,资料较多,初级学习较容易,直接贴代码
<?xml version="1.0"?>
<project name="AntTEST" default="testwar">
<property name="antname">antname's name</property>
<property name="">
</property>
<target name="sayHelloWorld" depends="testcopy">
<echo message="Hello,Amigo" />
<echo>${basedir}</echo>
<echo>${ant.java.version}</echo>
<echo>${antname}</echo>
<echo>${ant.file}</echo>
</target>
<target name="testif" unless="name">
<echo>this is testif </echo>
</target>
<target name="testcopy">
<!--
<copy file="test.txt" tofile="test2.txt"></copy>
<copy file="test.txt" todir="testidir"></copy>
-->
<copy todir="tttt" overwrite="true">
<fileset dir="testccc">
</fileset>
</copy>
</target>
<target name="testdel">
<!--
<delete file="test.txt"></delete>
<delete dir="testidir"></delete>
-->
</target>
<target name="clean">
<delete dir="build"/>
</target>
<target name="compile" depends="clean">
<mkdir dir="build/classes"/>
<javac srcdir="src" destdir="build/classes"/>
</target>
<target name="testjava" depends="compile">
<java classname="test.HelloWorld">
<classpath>
<pathelement path="build/classes"/>
</classpath>
</java>
</target>
<target name="testjar">
<jar destfile="helloworld.jar" basedir="build/classes">
</jar>
</target>
<target name="testwar" depends="compile">
<war destfile="${build}/antwebproject.war" webxml="WebContent/WEB-INF/web.xml">
<!-- 拷贝WebRoot下除了WEB-INF和META-INF的两个文件夹-->
<fileset dir="WebContent" includes="**/*.jsp" />
<!-- 拷贝lib目录下的jar包-->
<lib dir="WebContent/WEB-INF/lib/" />
<!-- 拷贝build/classes下的class文件-->
<classes dir="build/classes"/>
</war>
</target>
</project>
学习参考自:http://www.blogjava.net/amigoxie/archive/2007/11/09/159413.html
遗留问题:
拷贝功能,将一个文件夹拷贝到另外一个文件夹下,而不是拷贝文件夹下的内容。