ant中用到的标签介绍,其中代码摘录自tomcat源代码和网络中。如果对ant感兴趣可以参考更详细的ant介绍文章:http://www.blogjava.net/baoyaer/articles/102217.html
tstamp:
<tstamp>
<format property="year" pattern="yyyy" locale="en"/>
<format property="TODAY" pattern="MMM d yyyy" locale="en"/>
<format property="TSTAMP" pattern="hh:mm:ss"/>
</tstamp>
也就是说:在你的Ant脚本中定义了<tstamp/>对象后,它便为我们定义了三个属性变量:DSTAMP,TSTAMP,TODAY
你可以随时使用(分别为两个日期和一个时间)
filterset:
<filterset id="version.filters">
<filter token="YEAR" value="${year}"/>
<filter token="VERSION" value="${version}"/>
<filter token="VERSION_NUMBER" value="${version.number}"/>
<filter token="VERSION_MAJOR" value="${version.major}"/>
<filter token="VERSION_MAJOR_MINOR" value="${version.major.minor}"/>
<filter token="VERSION_BUILT" value="${TODAY} ${TSTAMP}"/>
<filter token="JDT_VERSION" value="${jdt.version}"/>
</filterset>
关于filterset的介绍请参考:http://zghbwjl.blog.163.com/blog/static/12033667220109242851909/
patternset:
<patternset id="files.jasper-el">
<include name="org/apache/el/**" />
</patternset>
Fileset 是对文件的分组,而patternset是对模式的分组,他们是紧密相关的概念。 <patternset>支持4个属性:includes excludex includexfile 和 excludesfile,与fileset相 同。Patternset 还允许以下嵌套元素:include,exclude,includefile 和 excludesfile
macrodef:
<macrodef name="jarIt" description="utility macro for standard JAR packaging">
<attribute name="jarfile" description="the name of the JAR file to create"/>
<attribute name="filesId" description="the patternset id of the files to use"/>
<attribute name="manifest" description="the manifest file use"
default="${tomcat.manifests}/default.manifest" />
<attribute name="notice" description="the LICENSE file to use"
default="${tomcat.manifests}/default.notice" />
<attribute name="license" description="the NOTICE file to use"
default="${tomcat.manifests}/default.license" />
<sequential>
<jar jarfile="@{jarfile}" manifest="@{manifest}">
<fileset dir="${tomcat.classes}">
<patternset refid="@{filesId}"/>
<!-- Javadoc and i18n exclusions -->
<exclude name="**/package.html" />
<exclude name="**/LocalStrings_*" />
</fileset>
<zipfileset file="@{notice}" fullpath="META-INF/NOTICE" />
<zipfileset file="@{license}" fullpath="META-INF/LICENSE" />
</jar>
</sequential>
</macrodef>
详细讲解参考以下链接地址:http://www.incoding.org/admin/archives/782.html
antcall:
<antcall target="downloadfile-2">
<param name="sourcefile.1" value="${tomcat-native.loc.1}"/>
<param name="sourcefile.2" value="${tomcat-native.loc.2}"/>
<param name="destfile" value="${tomcat-native.tar.gz}"/>
<param name="destdir" value="${tomcat-native.home}"/>
</antcall>
target:
<target>元素
是project元素的子元素,在project元素中能够有多个target;一般形式如下:
<target name=" " [ depends=" A "] [ if =" prop1 "] [ unless=" prop2"]>
</target>
name表示target的名称;
depends中填写其他target名称(可以有多个名称,用逗号分割),表示只有targetA完成之后才能够做此target,如果执行此target,则会先执行A;
if的值表示一个属性名,只有设置了该属性名,才能执行此target;
unless的值表示一个属性名,只有没有设置该属性名,才能执行此target;