如何修复蚂蚁导入其中只允许作为一个顶级的任务吗? [英] How to fix Ant import which is only allowed as a top-level task?
本文介绍了如何修复蚂蚁导入其中只允许作为一个顶级的任务吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下code引发以下错误:进口只允许作为一个顶级任务
<目标名称=打包文件>
<如果>
<等于ARG1 =$ {} pack.typeARG2 =impl1/>
<然后>
<进口为=packimpl文件=myImplementation1.xml>
< /然后>
<否则>
<进口为=packimpl文件=myImplementation2.xml>
< /&其他GT;
< /若> < antcall目标=packimpl.build/>< /目标与GT;
解决方案
任务文档明确提到这一点:
导入任务可仅被用作顶层的任务。这意味着,它可能无法在靶中使用。
块引用>要解决它,只需将进口目标之外。
<项目...> ... <如果>
<等于ARG1 =$ {} pack.typeARG2 =impl1/>
<然后>
<进口为=packimpl文件=myImplementation1.xml>
< /然后>
<否则>
<进口为=packimpl文件=myImplementation2.xml>
< /&其他GT;
< /若>
<目标名称=打包文件>
< antcall目标=packimpl.build/>
< /目标与GT; ...< /项目>The code below throws the following error: import only allowed as a top-level task
<target name="packfiles"> <if> <equals arg1="${pack.type}" arg2="impl1" /> <then> <import as="packimpl" file="myImplementation1.xml"> </then> <else> <import as="packimpl" file="myImplementation2.xml"> </else> </if> <antcall target="packimpl.build" /> </target>
解决方案The task documentation explicitly mentions this:
The import task may only be used as a top-level task. This means that it may not be used in a target.
To solve it, simply move the import outside the target.
<project ...> ... <if> <equals arg1="${pack.type}" arg2="impl1" /> <then> <import as="packimpl" file="myImplementation1.xml"> </then> <else> <import as="packimpl" file="myImplementation2.xml"> </else> </if> <target name="packfiles"> <antcall target="packimpl.build" /> </target> ... </project>
这篇关于如何修复蚂蚁导入其中只允许作为一个顶级的任务吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文