Ant1.8学习笔记
Ant1.8学习笔记
Ant Demo
- Ant demo1
- Ant demo2
- Ant demo3
- Ant demo4
Ant demo1
build.xml
<?xml version="1.0" encoding="utf-8"?>
<project default="package">
<description>hello world</description>
<property name="hello" value="welcome"/>
<target name="init" description="hello world">
<mkdir dir="helloworld"/>
<mkdir dir="hello"/>
<mkdir dir="${hello}"/>
<mkdir dir="world"/>
</target>
<target name="second" depends="init">
<delete dir="helloworld"/>
<delete dir ="hello"/>
<delete dir="welcome"/>
<delete dir="world"/>
</target>
</project>
Ant demo2
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="myAntProject" basedir="." default="package">
<property name="hello" value="hello123"></property>
<property name="world" value="world123"></property>
<target name="init"></target>
<target name="preprocess" depends="init">
<mkdir dir="${hello}"/>
<mkdir dir="${world}"/>
</target>
<target name="compile" depends="init,preprocess"></target>
<target name="package" depends="compile"></target>
</project>
Ant demo3
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="myAntProject" basedir="." default="package">
<property name="compile" value="compile"></property>
<property name="dist" value="dist"></property>
<target name="init"></target>
<target name="preprocess" depends="init">
<mkdir dir="${compile}"/>
<mkdir dir="${dist}"/>
</target>
<target name="myCompile" depends="preprocess">
<javac srcdir="src/com/mark" destdir="${compile}"></javac>
</target>
<target name="dist" depends="myCompile">
<tstamp></tstamp>
<jar destfile="${dist}/package-${DSTAMP}.jar" basedir="${compile}">
<manifest>
<attribute name="Build-By" value="${user.name}"/>
<attribute name="Main-Class" value="com.mark.Test3"/>
</manifest>
</jar>
</target>
<target name="deleteFile">
<delete file="${dist}/package.jar"></delete>
</target>
<target name="copyFile">
<copy file="src/com/mark/test3.java" tofile="c:/Test3copy.java"></copy>
</target>
<target name="moveFile">
<move file="src/com/mark/test3.java" todir="c:/"></move>
</target>
</project>
Ant demo4
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="myAntProject" basedir="." default="init">
<property name="compile" value="compile"></property>
<property name="dist" value="dist"></property>
<property name="cvsRoot" value=":pserver:username:password@localhost:c:\cvsroot"></property>
<property name="destLocation" value="c:/myCVS"></property>
<property name="src" value="src"></property>
<target name="init"></target>
<target name="preprocess" depends="init">
<mkdir dir="${compile}" />
<mkdir dir="${dist}" />
<mkdir dir="${destLocation}" />
</target>
<target name="myCompile" depends="preprocess">
<javac srcdir="src/com/mark" destdir="${compile}"></javac>
</target>
<target name="compress" depends="myCompile">
<zip destfile="${dist}/package.zip" basedir="${compile}"></zip>
</target>
<target name="uncompress" depends="compress">
<unzip dest="${dist}" src="${dist}/package.zip"></unzip>
</target>
<target name="cvs" depends="preprocess">
<cvs cvsroot="${cvsRoot}" package="chat" command="checkout" dest="${destLocation}"></cvs>
</target>
<target name="replaceOperation">
<replace file="input.txt" token="how" value="what" summary="true"></replace>
</target>
<target name="copy2">
<copy todir="${dist}">
<fileset dir="${src}">
<include name="**/*.java" />
<exclude name="*/*.txt"/>
</fileset>
</copy>
</target>
</project>