ANT之macrodef
macrodef 的意思是宏定义, 可以理解为自定义函数。
对于大型部署,可以提高代码利用率。
为了方便理解,请看代码示例:
<macrodef name="macro-send-file">
<attribute name="host" />
<attribute name="toPath" />
<attribute name="file" />
<attribute name="userID" />
<attribute name="password" />
<sequential>
<echo>@{userID}:@{password}@@@{host}:@{toPath}</echo>
<scp verbose="false" trust="true" localFile="@{file}" todir="@{userID}:@{password}@@@{host}:@{toPath}" failonerror="true" />
<!-- sshexec trust="true" host="@{host}" username="@{userID}" password="@{password}" command="chmod -R u+rw,g+rwx @{toPath}/*.ear"/ --><sshexec trust="true" host="@{host}" username="@{userID}" password="@{password}" command="chown thangamm:wadmfsms @{toPath}/*.ear"/>
<echo>Sent @{file} to @{host}:@{toPath}</echo>
<!-- delete build dir -->
<echo message="clean app project" />
<!-- after done, should clean the preparation folders but keep release folder -->
<delete dir="${build.dir.app}${file.separator}${name.bin}" failonerror="false" />
<delete dir="${build.dir.app}${file.separator}${name.docs}" failonerror="false" />
<delete dir="${build.dir.app}${file.separator}${name.reports}" failonerror="false" />
<delete dir="${build.dir.app}${file.separator}${name.stage}" failonerror="false" />
<echo message="clean core project" />
<delete dir="${build.dir.core}" failonerror="false" />
<echo message="clean web project" />
<delete dir="${build.dir.web}" failonerror="false" />
</sequential>
</macrodef>
name 属性说明这个自定义宏的名字 通过这个name 来调用这个宏
<macro-send-file file="${file}" host="${autodeploy.host}" topath="${autodeploy.path}/${envName}" userid="${autodeploy.userID}" password="${autodeploy.password}" />
表示宏的输入参数(相当于函数的参数)。在marcodef 中不同通过${}来调用attrbute 的值而要通过@{}。例如显示传入参数userID 是什么通过@{userID}.
相当于函数的body 就是你这个可以调用常用ant tag 如何copy javac mkdir jar war 等
补充链接
http://lhq1013.iteye.com/blog/1157234
ANT之macrodef的更多相关文章
- [Ant] Ant之MacroDef—“宏
转载自:http://lhq1013.iteye.com/blog/1157234 Ant是一个基于Java的跨平台构建工具,它易于使用,并且可扩展.可升级. MacroDef——“宏”,在An ...
- 从源码角度深入分析ant
Ant的基本概念 首先是ant的基本概念:Project,Target,Tasks,Properties,Paths 1.Project <project> build.xml文件最顶层的 ...
- 从源码角度深入分析 ant
[转自] http://www.tuicool.com/articles/eQvIRbA Ant的基本概念 首先是ant的基本概念: Project,Target,Tasks,Properties,P ...
- Ant: macrodef
<macrodef name="tokenReplace"> <attribute name="subapp"/> <attrib ...
- windows+ant+git+tomcat中ant直接获取git项目部署注意点
最近项目搬迁到公司的"GitHub"上面原来的SVN的ant发布脚本要改下,于是百度ant获取git的方法太少了,windows平台上更是没有所以搞了两天,今天终于有点成果分享给大 ...
- android自动打包方法(ant+proguard+签名)
前段时间做了一个android的网游项目,现在优化减少体积和防止别人反编译,需要把编译后.class进行混淆,开始在网上看了一些关于 ProGuard的介绍,基本上都是使用ADT自带的打包方式,那个打 ...
- 转 Apache Ant 实现自动化部署
Apache Ant 实现自动化部署 Apache Ant 实现自动化部署 http://www.netkiller.cn/journal/java.ant.html Mr. Neo Chen (陈景 ...
- ant的设置properties
特点 大小写敏感: 不可改变,先到先得,谁先设定,之后的都不能改变. 怎样设置 1 .设置 name 和 value 属性值,比如: <property name="srcdir&qu ...
- 脚本自动化 ant
用ant,shell下也可以用make. 1,ant 是一个自动化编译工具,安装使用. 2,编写build.xml,核心,写明进行哪些操作,删,建,编译,javac,java等,从例子可以看出每个操作 ...
随机推荐
- 【C/C++】例题5-4 反片语/算法竞赛入门经典/C++与STL入门/映射:map
本题是映射:map的例题. map:键值对. [题目] 输入一些单词,找出所有满足如下条件的单词:该单词不能通过字母重排,得到输入文本中的另外一个单词. 在判断是否满足条件时,字母不分大小写,但在输出 ...
- Jenkins安全加固
1.jenkins未授权访问 描述 jenkins不当配置可导致未授权访问管理控制台,可以通过脚本命令行执行系统命令.通过该漏洞,可以后台管理服务,通过脚本命令行功能执行系统命令,如反弹shell,w ...
- vue文件上传及压缩(canvas实现压缩)
// 读取文件结果 afterRead(files) { let that = this; let file = files.file; if (file === undefined) { retur ...
- 【js基础】基础数据类型变量为啥有属性?
1.变量和数值 let a =1 这是一个简单的变量声明,其中"a"是变量,在代码中供程序员或者语法操作的,而1是数值,是我最终需要的东西.为什么不直接使用数值而使用变量?这个就不 ...
- [BUUCTF]PWN——jarvisoj_level1
jarvisoj_level1 附件 步骤: 例行检查,32位程序,没有开任何保护 本地运行一下程序,看看大概的情况,可以看到输出了一个地址 32位ida载入,习惯性的检索程序里的字符串,没有发现可以 ...
- 【论文笔记】 Denoising Implicit Feedback for Recommendation
Denoising Implicit Feedback for Recommendation Authors: 王文杰,冯福利,何向南,聂礼强,蔡达成 WSDM'21 新加坡国立大学,中国科学技术大学 ...
- 预算(Project)
<Project2016 企业项目管理实践>张会斌 董方好 编著 预算是件重要的事,不然银几一花没边了,那结果可是要牺牺的(以下省略具体描述9^323字) 在Project里做预算,步骤不 ...
- JAVA运行报错 [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
执行 String[] rwords = (String[]) list.toArray(); 报错[Ljava.lang.Object; cannot be cast to [Ljava.lang. ...
- 【LeetCode】160. Intersection of Two Linked Lists 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 双指针 栈 日期 题目地址:https://leet ...
- 【LeetCode】908. Smallest Range I 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 数学计算 日期 题目地址:https://leetc ...