Ant 基本操作

1.新建文件夹
<mkdir dir="classes/test" />
 
2.删除文件夹或文件
<delete dir="classes/test" />
<delete file="classes/test.jar" />
 
3.复制文件及目录
<copy file="src/Test.java" tofile="src/TestCopy.java" />
 
4.重命名文件及目录
<move file="src/Test.java" tofile="src/TestCopy.java" />
 
5.创建和解压zip及tar文件
压缩文件zip
<zip destfile="output.zip" basedir="output" />
压缩文件tar
<gzip src="output.tar" zipfile="output.tar.gz" />
解压
<unzip src="output.tar.gz" dest="extractDir" />
 
6.文本替换
<replace file="input.txt' token="old" value="new" />
 
7.文件集
<fileset dir="src">
<include name="*.java"><!-- 选择的文件 -->
<exclude name="xxx.java"><!-- 排除的文件 -->
</fileset>
eg: 选择大于512字节并包含字符串“hello”的文件
<fileset dir="dir">
<and>
  <contains text="hello" />
  <size value="512" when="more" />
</and>
</fileset>
 
8.ant文件链接调用(调用其它ant文件)
<project default="default">
<target name="default">
  <ant antfile="目标文件.xml" target="目标target" inheritAll="false">
    <property name="message" value="传入参数"/>
  </ant >
</target>
</project>
posted @ 2014-11-28 10:30  sleepend  阅读(379)  评论(0编辑  收藏  举报