Ant 为什么这个宏定义会失败?
我试图为构建xml中的每个目标打印一个本地时间戳。我有这个macrodef来尝试在每次打印的时间戳周围工作Ant 为什么这个宏定义会失败?,ant,build,jenkins,Ant,Build,Jenkins,我试图为构建xml中的每个目标打印一个本地时间戳。我有这个macrodef来尝试在每次打印的时间戳周围工作 <macrodef name="timestamp.echo"> <attribute name="message"/> <sequential> <local name="current.time" /> <tstamp>
<macrodef name="timestamp.echo">
<attribute name="message"/>
<sequential>
<local name="current.time" />
<tstamp>
<format property="current.time" pattern="dd/MM/yyyy hh:mm:ss.SSS"/>
</tstamp>
<echo message="${current.time}@{message}" />
</sequential>
</macrodef>
该代码位于每个目标的末尾,但在目标内-
<timestamp.echo message="Mail sent" />
当我在本地任务上运行这个时,它工作得很好,但是当我与Jenkins一起运行时,它失败了。我收到这个错误消息-
Problem: failed to create task or type local
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
问题:无法创建任务或类型本地
原因:名称未定义。
措施:检查拼写。
操作:检查是否已声明任何自定义任务/类型。
措施:检查是否发生了任何/声明。
我正在努力,因为我已经宣布了名字,但看不到问题的原因。感谢您的帮助
回答未来参考问题
对于早期的Ant版本,我发现这可以创建一个本地时间戳-
<target name="timestamp">
<tstamp>
<format property="current.time" pattern="MM/dd/yyyy hh:mm:ss.SSS" />
</tstamp>
<echo message="${current.time} ${message}" />
</target>
然后将其插入目标将起作用-
<antcall target="timestamp">
<param name="message" value="Completed" />
</antcall>
中已将
任务添加到Ant中。将Ant升级到至少1.8版或更高版本
否则,您可能必须使用第三方Ant Contrib来模拟作用域属性。中已将
任务添加到Ant中。将Ant升级到至少1.8版或更高版本
否则,您可能必须使用第三方Ant Contrib来模拟作用域属性。这是正确的答案,不幸的是,我被告知升级是不可能的,因此我将从这里开始调查。谢谢。我挣扎了一个小时。您的回答很有帮助。这是正确的答案,不幸的是,我被告知升级是不可能的,所以我将研究从这里开始的方向。谢谢。我挣扎了一个小时。你的回答很有帮助。