在Ant中,我可以在目标的"依赖"中使用属性吗?

Yin*_*nan 5 ant

我试图用Ant做到这一点:

<property name="test" value="123"/>
<target name="helloworld" depends="${test}"/>
Run Code Online (Sandbox Code Playgroud)

但是我收到错误"这个项目中不存在Target $ {test}."

所以我猜我能做到这一点?

drf*_*oob 7

您可以使用AntCall任务在另一个任务中调用任务.

<project>
    <target name="asdf">
        <property name="prop" value="qwer" />
        <antcall target="${prop}" />
    </target>

    <target name="qwer">
        <echo message="in qwer" />
    </target>
</project>
Run Code Online (Sandbox Code Playgroud)

要使一个依赖另一个,您可以在从属任务中设置一个参数,并在您的调用任务中进行检查.