暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

ant之build.xml配置文件及相关标签详解

zayki 2024-07-14
384

前言
最近刚接手ant中的build.xml文件,第一次接触难免手忙脚乱,根据实际配置文件跟网上一些材料进行整理,方便自己的同时也方便大家查阅和理解。

背景知识
Ant的概念
可能有些读者并不连接什么是Ant以及入可使用它,但只要使用通过Linux系统得读者,应该知道make这个命令。当编译Linux内核及一些软件的源程序时,经常要用这个命令。Make命令其实就是一个项目管理工具,而Ant所实现功能与此类似。像make,gnumake和nmake这些编译工具都有一定的缺陷,但是Ant却克服了这些工具的缺陷。最初Ant开发者在开发跨平台的应用时,用样也是基于这些缺陷对Ant做了更好的设计。

Ant 与 makefile
Makefile有一些不足之处,比如很多人都会碰到的烦人的Tab问题。最初的Ant开发者多次强调”只是我在Tab前面加了一个空格,所以我的命令就不能执行”。有一些工具在一定程度上解决了这个问题,但还是有很多其他的问题。Ant则与一般基于命令的工具有所不同,它是Java类的扩展。Ant运行需要的XML格式的文件不是Shell命令文件。它是由一个Project组成的,而一个Project又可分成可多target,target再细分又分成很多task,每一个task都是通过一个实现特定接口的java类来完成的。

Ant的优点
Ant是Apache软件基金会JAKARTA目录中的一个子项目,它有以下的优点。跨平台性。Ant是存Java语言编写的,所示具有很好的跨平台性。操作简单。Ant是由一个内置任务和可选任务组成的。Ant运行时需要一个XML文件(构建文件)。Ant通过调用target树,就可以执行各种task。每个task实现了特定接口对象。由于Ant构建文件时XML格式的文件,所以和容易维护和书写,而且结构很清晰。Ant可以集成到开发环境中。由于Ant的跨平台性和操作简单的特点,它很容易集成到一些开发环境中去。

Ant 开发Ant的构建文件当开始一个新的项目时,首先应该编写Ant构建文件。构建文件定义了构建过程,并被团队开发中每个人使用。Ant构建文件默认命名为build.xml,也可以取其他的名字。只不过在运行的时候把这个命名当作参数传给Ant。构建文件可以放在任何的位置。一般做法是放在项目顶层目录中,这样可以保持项目的简洁和清晰。下面是一个典型的项目层次结构。
(1) src存放文件。
(2) class存放编译后的文件。
(3) lib存放第三方JAR包。
(4) dist存放打包,发布以后的代码。
Ant构建文件是XML文件。每个构建文件定义一个唯一的项目(Project元素)。每个项目下可以定义很多目标(target元素),这些目标之间可以有依赖关系。当执行这类目标时,需要执行他们所依赖的目标。每个目标中可以定义多个任务,目标中还定义了所要执行的任务序列。Ant在构建目标时必须调用所定义的任务。任务定义了Ant实际执行的命令。Ant中的任务可以为3类。
(1) 核心任务。核心任务是Ant自带的任务。
(2) 可选任务。可选任务实来自第三方的任务,因此需要一个附加的JAR文件。
(3) 用户自定义的任务。用户自定义的任务实用户自己开发的任务。

build.xml配置参数
构建文件默认叫build.xml,其有很多配置参数。

1、project标签
每个构建文件对应一个项目。标签时构建文件的根标签。它可以有多个内在属性,就如代码中所示,其各个属性的含义分别如下。
(1) default表示默认的运行目标,这个属性是必须的。
(2) basedir表示项目的基准目录。
(3) name表示项目名。
(4) description表示项目的描述。
每个构建文件都对应于一个项目,但是大型项目经常包含大量的子项目,每一个子项目都可以有自己的构建文件
示例如下:

<project name="acm" default="package" basedir="../" xmlns:artifact="antlib:org.apache.maven.artifact.ant"> <description> 项目集成脚本 </description> </project>

2、property标签
类似于常量,可以供给build.xml中的其他标签使用。有两个特点:

  • 大小写敏感
  • 不可改变,谁先设定,之后的都不能改变。
    该标签可以与多个属性配合使用。
    示例如下:
- name和value: <property name="module_name" value="admin"/> 后面直接使用即可: <echo message="begin nej-build ${module_name}..."/> - name和refid: <property name="srcpath" refid="dao.compile.classpath"/> 其中的dao.compile.classpath在别的地方进行了定义。当然,也可以通过直接引用的方式: <property name="baseline.dir" value="${ob_baseline.dir}"/> - name和location: <property name="srcdir" location="src"/> 将srcdir的值设置为当前文件路径/src。 - file: <property file="./omad/build.properties"/>

导入相对文件中的所有变量,这里的build.properties专门用来存放各种变量
示例如下:

在这里插入图片描述

3、import标签
引入别的xml文件,提高复用性
示例如下:

<import file="./env-judge.xml"/> <import file="./tasks.xml"/>

甚至可以批量匹配:

<copy todir="${basedir}/src/html/${html.dir}" overwrite="true" includeEmptyDirs="true"> <fileset dir="${basedir}/lib"> <include name="module-*/**" /> </fileset> </copy>

4、target标签
一个项目标签下可以有一个或多个target标签。一个target标签可以依赖其他的target标签。例如,有一个target用于编译程序,另一个target用于声称可执行文件。在生成可执行文件之前必须先编译该文件,因策可执行文件的target依赖于编译程序的target。Target的所有属性如下。
(1) name表示标明,这个属性是必须的。
(2) depends表示依赖的目标。
(3) if表示仅当属性设置时才执行。
(4) unless表示当属性没有设置时才执行。
(5) description表示项目的描述。
Ant的depends属性指定了target的执行顺序。Ant会依照depends属性中target出现顺序依次执行每个target。在执行之前,首先需要执行它所依赖的target。程序中的名为run的target的depends属性compile,而名为compile的target的depends属性是prepare,所以这几个target执行的顺序是prepare->compile->run。一个target只能被执行一次,即使有多个target依赖于它。如果没有if或unless属性,target总会被执行。
示例如下:

<!-- 初始化任务 --> <target name="init"> <echo message=" init ${init} ..."/> </target> <!-- 编译 --> <target name="compile" depends="init"> <delete dir="${classes.dir}" /> <mkdir dir="${classes.dir}" /> <javac srcdir="${src.dir}" destdir="${classes.dir}"> <classpath refid="master-classpath" /> </javac> </target> if:当属性设置时才执行该任务。 <target name="sync_module_k12_teach" if="${is_k12_teach}"> <antcall target="sync_module_item"> <param name="html.dir" value="org"/> </antcall> </target> <target name="sync_module_backend" if="${is_backend}"> <antcall target="sync_module_item"> <param name="html.dir" value="admin"/> </antcall> </target> <target name="sync_module_k12_backend" if="${is_k12_backend}"> <antcall target="sync_module_item"> <param name="html.dir" value="admin"/> </antcall> </target> 通过判断变量是否存在,执行不同的任务。 - unless:当属性未设置时才执行。 - description:任务描述。

5、echo标签

控制台显示 <echo message="begin clean res/module-xx、component-xx、res-base..."/>

6、delete标签
该标签用于删除一个文件或一组文件,去属性如下:
(1).file表示要删除的文件。
(2).dir表示要删除的目录。
(3).includeEmptyDirs 表示指定是否要删除空目录,默认值是删除。
(4).failonerror 表示指定当碰到错误是否停止,默认值是自动停止。
(5).verbose表示指定是否列出所删除的文件,默认值为不列出。
示例如下:

<!--clean other dir--> <target name="clean_other_dir"> <echo message="begin clean_other_dir..."/> <delete dir="${basedir}/${compress.dir}"/> <delete dir="${basedir}/pub"/> <echo message="begin clean html module-xx..."/> <delete includeemptydirs="true"> <fileset dir="${basedir}/src/html" > <include name="**/module-*/**"/> </fileset> </delete> <echo message="begin clean res/module-xx、component-xx、res-base..."/> <delete includeemptydirs="true"> <fileset dir="${basedir}/res" > <include name="module-*/**"/> <include name="component-*/**"/> <include name="res-base/**"/> </fileset> </delete> </target>

7、mkdir标签
该标签用于创建一个目录,它有一个属性dir用来指定所创建的目录名,其代码如下:通过以上代码就创建了一个目录,这个目录已经被前面的property标签所指定。
8、copy标签
该标签用于文件或文件集的拷贝,其属性如下。
(1).file 表示源文件。
(2).tofile 表示目标文件。
(3).todir 表示目标目录。
(4).overwrite 表示指定是否覆盖目标文件,默认值是不覆盖。
(5).includeEmptyDirs 表示制定是否拷贝空目录,默认值为拷贝。
(6).failonerror 表示指定如目标没有发现是否自动停止,默认值是停止。
(7).verbose 表示制定是否显示详细信息,默认值不显示。。
示例如下:

<target name="cp"> <copy todir="${compress.dir}" overwrite="true"> <fileset dir="${ob_baseline.dir}"> <include name="pub/" /> <include name="res/" /> <include name="mail_template/" /> </fileset> </copy> </target>

9、fileset类型
Fileset 数据类型定义了一组文件,并通常表示为元素。不过,许多ant任务构建成了隐式的fileset,这说明他们支持所有的fileset属性和嵌套元素。以下为fileset 的属性列表。
(1).dir表示fileset 的基目录。
(2).casesensitive的值如果为false,那么匹配文件名时,fileset不是区分大小写的,其默认值为true。
(3).defaultexcludes 用来确定是否使用默认的排除模式,默认为true。
(4).excludes 是用逗号分隔的需要派出的文件模式列表。
(5).excludesfile 表示每行包含一个排除模式的文件的文件名。
(6).includes 是用逗号分隔的,需要包含的文件模式列表。
(7).includesfile 表示每行包括一个包含模式的文件名。
示例如下:

<delete includeemptydirs="true"> <fileset dir="${basedir}/src/html" > <include name="**/module-*/**"/> </fileset> </delete> <echo message="begin clean res/module-xx、component-xx、res-base..."/> <delete includeemptydirs="true"> <fileset dir="${basedir}/res" > <include name="module-*/**"/> <include name="component-*/**"/> <include name="res-base/**"/> </fileset> </delete> 也就是说,但凡遇到文件集操作,都需要用到fileset标签。

10、exec标签
用来执行系统命令,或者指定环境的命令。
示例如下:

<target name="test"> <exec executable="cmd.exe"> <arg line="/c dir"/> </exec> </target> 打开命名行,并转到c盘执行dir命令。 能够执行系统命令,就相当于可以执行各种环境比如node、gulp、bower等等: <!--build style--> <target name="build_style"> <echo message="begin build_style..."/> <exec dir="." executable="gulp" failonerror="true"> <arg line="scss"/> </exec> </target> <!--bower cache clean if必须是${]才是判断true,false, 否则只要有设定值即可执行--> <target name="bower_cache_clean" if="${is_bower_cache_clean}"> <echo message="begin bower_cache_clean ..."/> <exec dir="." executable="bower" failonerror="true"> <arg line="cache clean" /> </exec> </target>

11、antcall标签
执行某个定义的任务。
示例如下:

<target name="sync_module_teach" if="${is_teach}"> <antcall target="sync_module_item"> <param name="html.dir" value="org"/> </antcall> </target> 执行sync_module_item任务,并设置参数html.dir的值为org。 该任务定义如下: <target name="sync_module_item"> <echo message="begin sync_module ${html.dir}..."/> <copy todir="${basedir}/src/html/${html.dir}" overwrite="true" includeEmptyDirs="true"> <fileset dir="${basedir}/lib"> <include name="module-*/**" /> </fileset> </copy> </target> 或者更为简单的表达: <target name="deploy"> <echo message="begin auto deploy......"/> <antcall target="clean"/> <antcall target="bower_install"/> <antcall target="cnpm_install"/> <antcall target="sync_module"/> <antcall target="build_style"/> <antcall target="nej_build" /> <antcall target="cp"/> </target>

12、parallel标签
并行执行多个子任务。
示例如下:

<parallel failonany="true"> <antcall target="sync_module_corp"/> <antcall target="sync_module_main"/> <antcall target="sync_module_teach"/> <antcall target="sync_module_backend"/> <antcall target="sync_module_passport"/> <antcall target="sync_module_business"/> <antcall target="sync_module_k12_teach"/> <antcall target="sync_module_k12_backend"/> <antcall target="build_style"/> </parallel> 通过failonany控制如果一个失败,则不执行。通过并行执行,来提升性能,降低构建花费的时间。

13、regexp标签
用于正则的定义的使用,可以与matches结合使用。
比如,定义正则:
示例如下:

<regexp id="regexp_env_test" pattern="^${root_dir}/(${test_dir}|${test_k12_dir})/.+"/> <regexp id="regexp_env_pre" pattern="^${root_dir}/(${pre_dir}|${pre_k12_dir})/.+"/> 通过pattern指定正则内容,通过id标识。 在需要匹配的时候,使用之: <condition property="is_test"> <matches string="${basedir}"> <regexp refid="regexp_env_test"/> </matches> </condition>

14、condition标签
用来判断,如果包含的内容符合条件,则将property指定的属性设置为true,否则为false。
比如上面的例子中,就是将basedir变量的值和regexp_env_test对应的正则匹配,如果正确,就将is_test设置为true,然后后面的流程再去判断。
与之配合的标签有很多,下面一一介绍:

istrue,isfalse:断言
示例如下:

<condition property="is_test_backend"> <and> <istrue value="${is_test}"/> <istrue value="${is_backend}"/> </and> </condition> 只有is_test和is_backend变量的值均为true,is_test_backend的值才为true。 - and:逻辑与,需要都满足条件才行,如上例所述。 - not:逻辑非,反过来的结果。 - or,xor:逻辑或和逻辑异或。 - isset:指定属性是否存在: <condition property="scondition"> <!--如果属性name不存在则返回false--> <isset property="name"/> </condition>

15、equils标签
指定属性是否相等:
示例如下:

<condition property="scondition"> <!--如果arg1的值与arg2的值相等返回true,否则为false--> <equals arg1="${name}" arg2="this is name"/> </condition>

16、filesmatch标签
指定文件是否相等:
示例如下:

<condition property="scondition"> <!--如果file1所代表的文件与file2所代表的文件相等返回true,否则为false--> <filesmatch file1="testfile1.txt" file2="testfile2.txt"/> </condition>

Ant的数据类型
在构建文件中为了标识文件或文件组,经常需要使用数据类型。数据类型包含在
org.apache.tool.ant.types包中。下面简单介绍构建文件中一些常用的数据类型。

  1. argument 类型
    由Ant构建文件调用的程序,可以通过元素向其传递命令行参数,如apply,exec和java任务均可接受嵌套元素,可以为各自的过程调用指定参数。以下是的所有属性。
    (1).values 是一个命令参数。如果参数种有空格,但又想将它作为单独一个值,则使用此属性。
    (2).file表示一个参数的文件名。在构建文件中,此文件名相对于当前的工作目录。
    (3).line表示用空格分隔的多个参数列表。
    (4).path表示路径。

2.ervironment 类型
由Ant构建文件调用的外部命令或程序,元素制定了哪些环境变量要传递给正在执行的系统命令,元素可以接受以下属性。
(1).file表示环境变量值得文件名。此文件名要被转换位一个绝对路径。
(2).path表示环境变量的路径。Ant会将它转换为一个本地约定。
(3).value 表示环境变量的一个直接变量。
(4).key 表示环境变量名。
注意 file path 或 value只能取一个。

3.filelist类型
Filelist 是一个支持命名的文件列表的数据类型,包含在一个filelist类型中的文件不一定是存在的文件。以下是其所有的属性。
(1).dir是用于计算绝对文件名的目录。
(2).files 是用逗号分隔的文件名列表。
(3).refid 是对某处定义的一个的引用。
注意 dir 和 files 都是必要的,除非指定了refid(这种情况下,dir和files都不允许使用)。

4.patternset 类型
Fileset 是对文件的分组,而patternset是对模式的分组,他们是紧密相关的概念。支持4个属性:includes excludex includexfile 和 excludesfile,与fileset相同。Patternset 还允许以下嵌套元素:include,exclude,includefile 和 excludesfile。

5.filterset 类型
Filterset定义了一组过滤器,这些过滤器将在文件移动或复制时完成文件的文本替换。
主要属性如下:
(1).begintoken 表示嵌套过滤器所搜索的记号,这是标识其开始的字符串。
(2).endtoken表示嵌套过滤器所搜索的记号这是标识其结束的字符串。
(3).id是过滤器的唯一标志符。
(4).refid是对构建文件中某处定义一个过滤器的引用。

6.Path类型
Path元素用来表示一个类路径,不过它还可以用于表示其他的路径。在用作揖个属性时,路经中的各项用分号或冒号隔开。在构建的时候,此分隔符将代替当前平台中所有的路径分隔符,其拥有的属性如下。
(1).location 表示一个文件或目录。Ant在内部将此扩展为一个绝对路径。
(2).refid 是对当前构建文件中某处定义的一个path的引用。
(3).path表示一个文件或路径名列表。

7.mapper类型
Mapper类型定义了一组输入文件和一组输出文件间的关系,其属性如下。
(1).classname 表示实现mapper类的类名。当内置mapper不满足要求时,用于创建定制mapper。
(2).classpath表示查找一个定制mapper时所用的类型路径。
(3).classpathref是对某处定义的一个类路径的引用。
(4).from属性的含义取决于所用的mapper。
(5).to属性的含义取决于所用的mapper。
(6).type属性的取值为identity,flatten glob merge regexp 其中之一,它定义了要是用的内置mapper的类型。

Ant 的运行
安装好Ant并且配置好路径之后,在命令行中切换到构建文件的目录,输入Ant命令就可以运行Ant.若没有指定任何参数,Ant会在当前目录下查询build.xml文件。如果找到了就用该文件作为构建文件。如果使用了 –find 选项,Ant 就会在上级目录中找构建文件,直至到达文件系统得跟目录。如果构建文件的名字不是build.xml ,则Ant运行的时候就可以使用 –buildfile file,这里file 指定了要使用的构建文件的名称,示例如下:
Ant如下说明了表示当前目录的构建文件为build.xml 运行 ant 执行默认的目标。
Ant –buildfile test.xml使用当前目录下的test.xml 文件运行Ant ,执行默认的目标

实战演练

<project name="acm" default="package" basedir="../" xmlns:artifact="antlib:org.apache.maven.artifact.ant"> <description> 项目集成脚本 </description> <property name="monitorDir" location="${basedir}/SeeMonitorDev"/> <property name="webDir" location="${basedir}/see-hq-web"/> <property name="webappDir" location="${webDir}/src/main/webapp"/> <property name="seeBaseDir" value="${basedir}/see" /> <property name="seeUpdateDir" value="${basedir}/patch/see" /> <property name="war_name" value="acm.war"/> <property name="see_update_prefix" value="patch" /> <!-- 判断二次开发工程是否存在 --> <available property="monitorExist" file="${monitorDir}" type="dir" /> <available property="webExist" file="${webDir}" type="dir" /> <available property="patchExist" file="${see_update_prefix}" type="dir" /> <available property="docsExist" file="${basedir}/see-docs-web" type="dir" /> <target name="clean"> <echo message="clean......"/> <echo message="basedir=${basedir}"/> <delete dir="${basedir}/mon_tmp" /> <delete dir="${basedir}/mon_tmp_up" /> <delete dir="${basedir}/web_tmp_up" /> </target> <target name="init" depends="clean"> <echo message="init......"/> <mkdir dir="${basedir}/mon_tmp" /> <mkdir dir="${basedir}/mon_tmp_up" /> <mkdir dir="${basedir}/web_tmp_up" /> <fileset id="current.artifact" dir="see/repository/000" includes="Stock*.zip"/> <pathconvert property="monitorPackagePath" refid="current.artifact"/> </target> <target name="package" depends="init"> <echo message="package......"/> <antcall target="monitorBuild" /> <antcall target="webBuild" /> </target> <target name="monitorBuild" if="monitorExist"> <echo message="monitorBuild......"/> <!-- 解压缩内置监控安装包以及升级包 --> <unzip src="${monitorPackagePath}" dest="${basedir}/mon_tmp" /> <!-- 编译二次开发部分监控jar --> <ant antfile="${monitorDir}/build.xml" target="package" dir="${monitorDir}"/> <!-- 复制监控jar以及模板文件到安装包解压目录,如果有自己的扩展配置文件需要拷贝,请添加相关脚本 --> <copy todir="${basedir}/mon_tmp/See/SystemEagleEyes/server/lib" overwrite="true" preservelastmodified="true"> <fileset dir="${monitorDir}/dist/jars" /> </copy> <copy todir="${basedir}/mon_tmp/See/SystemEagleEyes/server/monitor/template" overwrite="true" preservelastmodified="true"> <fileset dir="${monitorDir}/monitor/template" excludes="templateconfig.xml" /> </copy> <!-- 监控安装包扩展 --> <ant antfile="integrate/monitorBuild.xml"/> <!-- 重新压缩监控模块安装包、升级包 --> <echo message="重新压缩内置监控安装包"/> <delete file="${monitorPackagePath}" /> <zip destfile="${monitorPackagePath}" > <zipfileset dir="${basedir}/mon_tmp" includes="**/*" /> </zip> <!-- <antcall target="monitorUpdate" /> --> </target> <target name="monitorUpdate" if="patchExist"> <echo message="monitorUpdate......"/> <!-- 复制监控jar以及模板文件到补丁包临时目录,如果有自己的扩展配置文件需要拷贝,请添加相关脚本 --> <unzip dest="${basedir}/mon_tmp_up"> <fileset dir="${seeUpdateDir}/repository/000/"> <include name="${see_update_prefix}*.zip"/> </fileset> </unzip> <!-- 复制监控jar以及模板文件到补丁包临时目录,如果有自己的扩展配置文件需要拷贝,请添加相关脚本 --> <copy todir="${basedir}/mon_tmp_up/See/SystemEagleEyes/server/lib" overwrite="true" preservelastmodified="true"> <fileset dir="${monitorDir}/dist/jars" /> </copy> <copy todir="${basedir}/mon_tmp_up/See/SystemEagleEyes/server/monitor/template" overwrite="true" preservelastmodified="true"> <fileset dir="${monitorDir}/monitor/template" /> </copy> <!-- 设置monitor的版本 --> <ant antfile="integrate/inner/monitorVersion.xml"/> <xmlproperty file="${basedir}/mon_tmp_up/See/SystemEagleEyes/server/system/update.xml" prefix="up"/> <!-- 监控升级包扩展 --> <ant antfile="integrate/monitorUpdate.xml"/> <delete file="${seeUpdateDir}/repository/000/${see_update_prefix}-${up.update.version}.zip" /> <echo message="重新压缩内置see升级包${see_update_prefix}-${up.update.version}.zip"/> <zip destfile="${seeUpdateDir}/repository/000/${see_update_prefix}-${up.update.version}.zip" > <zipfileset dir="${basedir}/mon_tmp_up" includes="**/*" excludes="See/SystemEagleEyes/server/monitor/template/templateconfig.xml" /> </zip> </target> <target name="webBuild" if="webExist"> <echo message="webBuild......"/> <unzip src="${seeBaseDir}/tomcat/webapps/${war_name}" dest="${basedir}/web_tmp_up" /> <exec executable="cmd.exe" dir="${webDir}"> <arg line="/c mvn clean package -f pom-jar.xml"/> </exec> <!-- 拷贝自身的jar --> <copy todir="${basedir}/web_tmp_up/WEB-INF/lib" overwrite="true" preservelastmodified="true"> <fileset dir="${webDir}/target" includes="see-*.jar"/> </copy> <!-- 设置web的版本 --> <ant antfile="integrate/inner/webVersion.xml"/> <!-- 文档拷贝 --> <antcall target="docsBuild" /> <!-- web的扩展 --> <ant antfile="integrate/webBuild.xml"/> <delete file="${seeBaseDir}/tomcat/webapps/${war_name}" /> <war destfile="${seeBaseDir}/tomcat/webapps/${war_name}"> <fileset dir="${basedir}/web_tmp_up" /> </war> <zip destfile="${basedir}/see.zip" duplicate="add"> <zipfileset dir="${seeBaseDir}/" excludes="svn/**" prefix="see" /> </zip> <!-- <antcall target="webUpdate" /> --> </target> <target name="docsBuild" if="docsExist"> <copy todir="${seeUpdateDir}/tomcat/webapps/docs" overwrite="true" preservelastmodified="true"> <fileset dir="${basedir}/see-docs-web"/> </copy> <copy todir="${seeBaseDir}/tomcat/webapps/docs" overwrite="true" preservelastmodified="true"> <fileset dir="${basedir}/see-docs-web"/> </copy> </target> <target name="webUpdate" if="patchExist"> <!-- 拷贝war到补丁目录 --> <copy todir="${seeUpdateDir}/tomcat/webapps" file="${seeBaseDir}/tomcat/webapps/${war_name}" overwrite="true" preservelastmodified="true" /> <!-- 打包补丁程序 --> <zip destfile="${basedir}/patch.zip" duplicate="add"> <zipfileset dir="${seeUpdateDir}/" excludes="svn/**" prefix="see" /> </zip> </target> </project>

————————————————
版权声明:本文为CSDN博主「努力的小澜」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_42971895/article/details/111817735

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论