Copy命令使用:http://www.blogjava.net/hh-lux/archive/2009/04/07/86635.html
1.单文件拷贝 <copy todir="${basedir}/new" file="${basedir}/old/old1.txt1">或者<copy tofile="${basedir}/new/new1.txt" file="${basedir}/old/old1.txt1">。两者差别应该很容易鉴别。
2.多文件拷贝
<copy todir="${basedir}/new">
<fileset dir="${basedir}/old">
<include name="old1.txt" />
<include name="old2.txt" />
<exclude name="old8.txt" />
</fileset>
</copy>
其中include是包含,exclude是排除的意思。
也可以把fileset写成:<fileset dir="${basedir}/old" includes="old1.txt,old2.txt" />这种形式
多文件拷贝同样支持*,譬如在fileset里面内容为:
<include name="appgen/**"/>
<include name="ibatis/**"/>
<exclude name="**/*.log"/>
3.目录拷贝
<copy todir="${basedir}/new">
<fileset dir="${basedir}/old">
<include name="appgen" />
<include name="appgen/" />
<include name=appgen/**" />
<include name="appgen/***" />
</fileset>
</copy>
若使用<include/>, 又要分三种情况
若是“appgen”,则只会拷贝名为appgen的空目录过去,它里面的文件和子目录则不会拷贝。
若是“appgen/”,或“appgen/**”,则会把整个appgen目录拷贝过去,包括里面的文件和子目录。
若是“appgen/*”,则只会把该目录和该目录下第一级子目录的所有东西拷贝过去,而不会拷贝第二级和第二级以下的。注:“appgen/*”这儿是 一个*号,*号若大于两个,也跟一个*号是同样效果。比如“appgen/*”和“appgen/****”都只拷贝appgen目录下第一级子目录。
注:使用<exclude/>排除目录时,目录名必须写成“appgen/”或“appgen/**”形式,否则不会生效。
以上是三种拷贝到目录的种类,注意如果计算机中没有todir指定的路径,ant将会自动创建这个路径。
4.复制肯定还要涉及到同名覆盖的问题,ant在copy类的API中说明:Files are only copied if the source file is newer than the destination file,这里的newer是指文件的修改时间,即使你在修改时文件内容没有任何变化,只是导致修改时间变了,ant同样会覆盖同名文件,也就是 说,ant不会检查文件内容。
对于是复制目录的情况,由于目录没有修改时间,ant还是通过检查目录内文件的修改时间来决定是否覆盖的,若目录内某文件修改时间有变化,则会覆盖这个文件,而不是整个目录。
如果要强行覆盖,<copy/>有个overwrite属性,默认为false,改成true就行了。
filter的使用filter分filter和filterset两个,其作用是将某些文件的内容替换为新内容。
一、<filter filtersfile="filter.properties"/> 用外部文件定义filter,外部文件的写法为:
month=12
year=2008 这样这个filter就达到了把@month@和@year@替换为你指定的值的目的了。
二、<filter token="time" value="14时7分"/>,这个会把@time@替换掉。
三、
<copy toDir="${dist.dir}/docs"> <fileset dir="${build.dir}/docs"> <include name="**/*.html"> </fileset> <filterset begintoken="%" endtoken="*"> <filtersfile file="${user.dir}/dist.properties"/> </filterset> </copy>
若filter指定的外部文件还和上面一样,那么会把%month*替换为指定的值。
当然也可以在外面指定filterset,赋个ID(如myFilterSet),然后在里面引用的时候,
<filterset refid="myFilterSet"/>
即可。
最后,举一个build.xml的例子,用来打包war,ear文件【一般为EJB工程打包】(步骤分为copy到目标目录,然后运行javac编译,最后war,ear命令进行打包)。
<?xml version="1.0" encoding="UTF-8"?> <project name="ProjectWindow.web" default="buildear" basedir="."> <property name="dist" location="dist" /> <property name="src" location="src/main" /> <property name="web.webroot" location="WebRoot" /> <property name="web.inf" location="WebRoot/WEB-INF" /> <path id="project.class.path"> <fileset dir="${web.inf}/lib"> <include name="*.jar" /> </fileset> <pathelement path="${java.class.path}" /> </path> <target name="clean"> <delete dir="${dist}"> </delete> <delete dir="${web.inf}/classes"> </delete> </target> <target name="copy.config" depends="clean" > <mkdir dir="${web.inf}/classes"/> <mkdir dir="${web.inf}/classes/schedule"/> <copy file="${src}/resources/application.properties" tofile="${web.inf}/classes/application.properties"/> <copy file="${src}/resources/applicationContext-action.xml" tofile="${web.inf}/classes/applicationContext-action.xml"/> <copy file="${src}/resources/applicationContext-dao.xml" tofile="${web.inf}/classes/applicationContext-dao.xml"/> <copy file="${src}/resources/applicationContext-interceptor.xml" tofile="${web.inf}/classes/applicationContext-interceptor.xml"/> <copy file="${src}/resources/applicationContext-service.xml" tofile="${web.inf}/classes/applicationContext-service.xml"/> <copy file="${src}/resources/applicationContext.xml" tofile="${web.inf}/classes/applicationContext.xml"/> <copy file="${src}/resources/applicationContext-SumDataView.xml" tofile="${web.inf}/classes/applicationContext-SumDataView.xml"/> <copy file="${src}/resources/applicationContext-SysIndexView.xml" tofile="${web.inf}/classes/applicationContext-SysIndexView.xml"/> <copy file="${src}/resources/applicationContext-ProvinceDataView.xml" tofile="${web.inf}/classes/applicationContext-ProvinceDataView.xml"/> <copy file="${src}/resources/companyList.xml" tofile="${web.inf}/classes/companyList.xml"/> <copy file="${src}/resources/configuration.xml" tofile="${web.inf}/classes/configuration.xml"/> <copy file="${src}/resources/oracle/Fsxtsjwbd.hbm.xml" tofile="${web.inf}/classes/oracle/Fsxtsjwbd.hbm.xml"/> <copy file="${src}/resources/oracle/Xtzcywyyl.hbm.xml" tofile="${web.inf}/classes/oracle/Xtzcywyyl.hbm.xml"/> <copy file="${src}/resources/oracle/Yhhyd.hbm.xml" tofile="${web.inf}/classes/oracle/Yhhyd.hbm.xml"/> <copy file="${src}/java/com/telek/yyjk/oracle/ProvinceDataView.hbm.xml" tofile="${web.inf}/classes/com/telek/yyjk/oracle/ProvinceDataView.hbm.xml"/> <copy file="${src}/java/com/telek/yyjk/oracle/SumDataView.hbm.xml" tofile="${web.inf}/classes/com/telek/yyjk/oracle/SumDataView.hbm.xml"/> <copy file="${src}/java/com/telek/yyjk/oracle/SysIndexView.hbm.xml" tofile="${web.inf}/classes/com/telek/yyjk/oracle/SysIndexView.hbm.xml"/> <copy file="${src}/resources/schedule/applicationContext-quartz-cron-local.xml" tofile="${web.inf}/classes/schedule/applicationContext-quartz-cron-local.xml"/> <copy file="${src}/resources/fwn.properties" tofile="${web.inf}/classes/fwn.properties"/> <copy file="${src}/resources/log4j.properties" tofile="${web.inf}/classes/log4j.properties"/> <copy file="${src}/resources/msg.properties" tofile="${web.inf}/classes/msg.properties"/> </target> <target name="compile" description="compile the source " > <!-- Compile the java code from ${src} into ${build} --> <javac srcdir="${src}" destdir="${web.inf}/classes" source="1.4" target="1.4"> <classpath refid="project.class.path"> </classpath> </javac> </target> <target name="buildwar" depends="copy.config,compile" description="generate the distribution"> <mkdir dir="${dist}" /> <war destfile="${dist}/ProjectWindow.war" manifest="${web.webroot}/META-INF/MANIFEST.MF" webxml="${web.inf}/web.xml" basedir="${web.webroot}"> </war> </target> <target name="buildear" depends="buildwar" description="generate the distribution"> <ear destfile="${dist}/ProjectWindow.ear" appxml="${web.webroot}/SAPMETA-INF/application.xml" manifest="${web.webroot}/SAPMETA-INF/MANIFEST.MF"> <metainf dir="${web.webroot}/SAPMETA-INF"> <include name="application-j2ee-engine.xml"/> <include name="sda-dd.xml"/> <include name="SAP_MANIFEST.MF"/> </metainf> <fileset dir="${dist}"> <include name="ProjectWindow.war" /> </fileset> </ear> </target> </project>
相关推荐
标签中的"ant_1", "ant_1.6", "ant_1.6.0", "ant-1.6.0"和"apache-ant-1.6"都指的是Apache Ant的不同版本,1.6.0是其中的一个稳定版本,发布于2003年,提供了许多改进和新特性,比如支持JUnit 3.8,对ivy依赖管理...
Apache Ant 是一个开源的构建工具,广泛用于Java项目构建,由Apache软件基金会开发。这个"apache-ant-1.6.5-bin.zip"文件是Ant的1.6.5版本的二进制发行版,适合在Windows操作系统上使用。Ant是基于Java的,它的主要...
org.apache.tools.ant.Main org.apache.tools.ant.Task org.apache.tools.bzip2.CRC org.apache.tools.ant.Target org.apache.tools.ant.Project org.apache.tools.zip.ZipFile org.apache.tools.zip.ZipLong ...
在IT行业中,Ant是一个至关重要的自动化构建工具,尤其在Java开发领域中被广泛使用。Ant以其XML为基础的构建文件(通常命名为build.xml)为特点,允许开发者定义和执行项目的构建任务。现在,让我们深入探讨一下标题...
December 19, 2006 - Ant 1.7.0 Available Apache Ant 1.7.0 is now available for download. Ant 1.7 introduces a resource framework. Some of the core ant tasks such as <copy/> are now able to ...
开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6...
"Ant ant ant antant ant ant antant ant ant ant" 这个描述可能是在强调Ant在项目构建过程中的重复性和不可或缺性,暗示着它在工程中的频繁使用和核心地位。 Ant的设计理念是“一切都是XML”,它通过XML格式的构建...
Use the links below to download a source distribution of Ant from one of our mirrors. It is good practice to verify the integrity of the distribution files, especially if you are using one of our ...
Axure AntDesign元件库是一款专为Axure设计的高质量组件集合,它旨在帮助原型设计师快速构建基于AntDesign设计系统的Web应用界面。AntDesign是阿里巴巴开源的一款著名前端UI框架,以其优雅、直观、高效的特性广受...
ant配置后提示不是内部命令也不是外部命令解决办法: 1、解压缩包。例如解压到E:\学习类\apache-ant-1.8.2, 2、配置环境变量。在系统环境变量中新建一个ANT_HOME 的变量,值为D:\apache-ant-1.10.1。在path 变量中...
ANT+协议是一种无线通信协议,主要用于运动健康和健身设备之间的数据传输。该协议由Garmin公司开发,并在开放源码的基础上推广,使得不同厂商的设备能够无缝共享数据,如心率、速度、距离等运动参数。VS2015源文件指...
《AntDesign3.9Axure组件:原型设计的利器》 在互联网产品开发流程中,原型设计是一个至关重要的环节,它能清晰地呈现产品的功能结构和交互方式,为后续的开发工作提供明确的方向。AntDesign3.9Axure组件正是这样一...
Apache Ant 1.10.13-bin是Apache Ant的一个二进制分发版本。Apache Ant是一个由Apache软件基金会提供的Java库与命令行工具,主要用于自动化软件编译、测试、部署等步骤,尤其在Java环境中的软件开发中广泛应用。其...
在给定的文件中,`apache-ant-1.9.4-bin.zip`是Ant的一个版本,你需要解压并将其添加到系统路径中,这样命令行就可以识别`ant`命令了。安装完成后,确保你的环境配置正确,包括Android SDK和相关的环境变量(如`...
Apache Ant 是一个开源的构建工具,广泛用于Java项目管理,它是Apache软件基金会的产品之一。Ant以其XML为基础的构建文件(build.xml)而著名,这种文件定义了构建过程中的任务序列,使得开发人员能够自动化编译、...
**Ant Design Axure设计库详解** Ant Design是一个广泛使用的开源UI设计框架,源自阿里巴巴集团,专为构建高效、稳定且具有良好用户体验的Web应用而设计。它提供了丰富的组件库,覆盖了网页界面设计的各个方面,...
Apache Ant是Java开发中不可或缺的构建工具,它以其灵活性、可扩展性和跨平台特性而闻名。标题中的"ant1.9包下载"指的是Apache Ant 1.9系列的版本,这是该工具的一个重要里程碑,提供了许多增强的功能和修复了已知...
"ant-design-demos" 是一个基于Ant Design框架的示例集合,主要展示了Ant Design的各种组件和功能在实际应用中的使用方式。Ant Design是一款由阿里集团开发的高质量React UI库,它提供了一系列美观、易用且具有企业...
Apache Ant 是一个广泛使用的开源构建工具,主要用于Java项目的编译、打包、测试和部署等任务。这个"apache-ant-1.10.12-bin.zip"文件是Apache Ant的1.10.12版本的二进制发行包,包含了运行Ant所需的全部组件。 在...
开发工具 ant-launcher-1.9.6开发工具 ant-launcher-1.9.6开发工具 ant-launcher-1.9.6开发工具 ant-launcher-1.9.6开发工具 ant-launcher-1.9.6开发工具 ant-launcher-1.9.6开发工具 ant-launcher-1.9.6开发工具 ...