惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
GRAHAM CLULEY
T
Tenable Blog
Know Your Adversary
Know Your Adversary
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Privacy International News Feed
S
Security Affairs
NISL@THU
NISL@THU
O
OpenAI News
Attack and Defense Labs
Attack and Defense Labs
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Hacker News: Ask HN
Hacker News: Ask HN
Webroot Blog
Webroot Blog
Schneier on Security
Schneier on Security
S
SegmentFault 最新的问题
S
Schneier on Security
G
Google Developers Blog
V
V2EX
C
Check Point Blog
U
Unit 42
Google DeepMind News
Google DeepMind News
T
Threatpost
阮一峰的网络日志
阮一峰的网络日志
T
The Exploit Database - CXSecurity.com
Recent Announcements
Recent Announcements
M
MIT News - Artificial intelligence
S
Secure Thoughts
博客园 - 司徒正美
Recorded Future
Recorded Future
P
Proofpoint News Feed
Spread Privacy
Spread Privacy
K
Kaspersky official blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
AI
AI
博客园 - 聂微东
N
News and Events Feed by Topic
SecWiki News
SecWiki News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Vulnerabilities – Threatpost
P
Palo Alto Networks Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Engineering at Meta
Engineering at Meta
Recent Commits to openclaw:main
Recent Commits to openclaw:main
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
酷 壳 – CoolShell
酷 壳 – CoolShell
WordPress大学
WordPress大学
The Hacker News
The Hacker News
The Last Watchdog
The Last Watchdog
Project Zero
Project Zero
W
WeLiveSecurity
博客园 - Franky

博客园 - yiling

Eclipse 12大使用技巧 Hibernate 缓存的使用 Quartz应用 Solaris9下安装Oracle10g详细过程(转) Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/mail/util/LineInputStream - yiling 使用JOX实现JavaBean和XML之间的转化 java读取property文件 db2常用命令 java查看文件的创建时间 - yiling - 博客园 [转]Oracle exp imp sybase备份服务(backup server)不能启动的处理方法 SQL*PLUS环境输入'&字符'的方法 DB2 Catalog hibernate如何设置一对多cascade Hibernate 一些疑点(转的文章,还不错) Ajax客户端与伺服端之间,使用XML作为数据传送 从找实习的过程中发现了自己的弱点 (转)CAD二次开发简介 WID实施过程中的常见问题
ant中利用macrodef来定义可重用的task
yiling · 2009-05-18 · via 博客园 - yiling

先来看下macrodef的说明

This defines a new task using a <sequential> nested task as a template. Nested elements <attribute> and <element> are used to specify attributes and elements of the new task. These get substituted into the <sequential> task when the new task is run.

下面是ant doc的一个example

<macrodef name="test">  这里是macrodef的定义,定义了name属性
<attribute name="one"/> 参数定义,可以在macrodef外部调用
<attribute name="two" default="@{one}"/> 内部参数
<sequential>
实际执行的内容在sequential里
<echo>one=@{one} two=@{two}</echo>
</sequential>
</macrodef>

<test one="test"/> 外部调用

需要注意的是:
1、在整个build文件里macrodef是和target平级的。
2、macrodef可以调用其他macrodef,不可以调用target;target可以调用macrodef,也可以调用其他target
3、macrodef嵌套的时候,参数名称必须不同
比如上面的macrodef test,定义了one的参数
如果定义另外一个macrodef test2 也有一个参数,最好不要再叫one了,不然容易出现混乱