ANT:使用条件标签,
我想做这样的事情
<target name="clean" description="clean">
<if>
<available file="${build}" type="dir" />
<then>
<delete dir="${build}" />
</then>
</if>
</target>
按照 建议 在 stackoverflow.com 上找到,我下载了 ant-contrib-1.0b3.jar 并将其放入我的路径
另外,在 Ant Build 配置下的类路径中,我有
运行 ANT 脚本时,我仍然得到
BUILD FAILED
C:\Repositories\blah\build.xml:60: Problem: failed to create task or type if
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.
我缺少什么?请指教
I would like to do something like this
<target name="clean" description="clean">
<if>
<available file="${build}" type="dir" />
<then>
<delete dir="${build}" />
</then>
</if>
</target>
As per suggestions found on stackoverflow.com, i downloaded ant-contrib-1.0b3.jar and put it into my path
Additionally, under Ant Build configuration, in classpath, i have
When running my ANT script, i still get
BUILD FAILED
C:\Repositories\blah\build.xml:60: Problem: failed to create task or type if
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.
What am i missing? Please advise
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
或者,一次可以在您的 ANT 脚本中包含以下行
只要
ant-contribs
在您的路径中,就不需要其他任何东西这个解决方案更干净一点,因为一个获得了对 ALL 的访问权限标签, 不仅仅是手动指定的标签
Alternately, once can include the following line in your ANT script
As long as
ant-contribs
is in your path, nothing else is neededThis solution is a bit cleaner, as one gains access to ALL the tags, not just the ones manually specified
同样的问题就这样解决了。
我在 buid XML 文件的开头放置了以下几行:
Same issue resolved in that way.
I put at the start of the buid XML file the following lines:
标准的 ant 方式类似于=
带有 Ant 插件 Flaka 的代码片段,这是最近的替代方案到 antcontrib。像往常一样通过
Preferences | 在 Eclipse 中安装蚂蚁 |运行时 |全球条目 | ant-flaka-1.02.-1.02.jar =
输出ant -f build.xml -Dbuildtype=prod 或
ant -f build.xml -Dbuildtype=prod -Ddummybuild=任何
有拼写错误的输出 => ant - build.xml -Dbuildtype=testt
输出 ant -f build.xml -Ddummybuild=whatever
The standard ant way would be something like =
A snippet with the Ant Plugin Flaka, a recent alternative to antcontrib. Installation in Eclipse as usual via
Preferences | Ant | Runtime | Global Entries | ant-flaka-1.02.-1.02.jar =
output with ant -f build.xml -Dbuildtype=prod or
ant -f build.xml -Dbuildtype=prod -Ddummybuild=whatever
output with typo => ant - build.xml -Dbuildtype=testt
output with ant -f build.xml -Ddummybuild=whatever
我遇到了同样的问题。我按照以下方式解决了。
有时这可能是兼容性问题。
到C:\XXXX\ant\XXX
ant-contrib.xxjar 位于 C:\XXXX\ant\XXX\ant-contrib\ 目录中。
I got the same issue. I resolved in the following way.
Sometimes this might be compatibility problem.
to C:\XXXX\ant\X.X.X.
ant-contrib.x.x.jar form C:\XXXX\ant\X.X.X\ant-contrib\ directory.
在 Ant 运行时的任务选项卡上,您是否看到“if”任务?
On the tasks tab for your Ant Runtime do you see the 'if' task?
导出 ANT_HOME=/path/to/ant/apache-ant-1.8.2
在正确设置 ANT_HOME 之前我无法让它工作。 Java 不断挑选安装在盒子上的另一只蚂蚁。
export ANT_HOME=/path/to/ant/apache-ant-1.8.2
I couldn't get it to work until I had ANT_HOME set properly. Java kept picking another ant installed on the box.