Ant复制文件

 1 <?xml version="1.0" encoding="UTF-8"?>  
 2 <project name ="test" default="copy" basedir=".">  
 3 <target name ="copy">  
 4 <!--拷贝一个文件 -->  
 5 <copy file ="myfile.txt" tofile="mycopy.txt"/>  
 6   
 7 <!--拷贝一个文件到指定目录 -->  
 8 <copy file ="myfile.txt" todir="other"/>  
 9   
10 <!-- 拷贝一个目录到另一个目录 -->  
11 <copy todir="other">  
12 <fileset dir="bin"/>  
13 </copy>  
14   
15 <!-- 拷贝一个文件集到另一个目录 -->  
16 <copy todir="other">  
17 <fileset dir="bin">  
18 <!--  排除所有的.java文件 -->  
19 <exclude name="**/*.java"/>  
20 </fileset>  
21 </copy>  
22   
23 <!-- 拷贝一个文件集到另一个目录,同时建立备份文件-->  
24 <copy todir="other">  
25 <fileset dir="bin" />  
26 <globmapper from="*" to="*.bak"/>  
27 </copy>  
28   
29 <!-- 使用copydir拷贝一个目录下的东西到另一个目录,includes包含,excludes排除(已过时) -->  
30 <copydir src="bin"   
31 dest="other"  
32 includes="**/*.java"  
33 excludes="**/Test.java"  
34 />  
35   
36 <!-- 使用copyfile拷贝一个文件(已过时)-->  
37 <copyfile src ="test.java" dest="other/test.java"/>  
38 </target>  
39 </project>  

 

posted @ 2018-05-23 14:02  阿狸哥哥  阅读(217)  评论(0编辑  收藏  举报