如何在ant中使用condition元素来设置另一个属性?

Pet*_*217 5 java ant

我有一个与ant一起使用的build.xml,我正在尝试在目标中放置一个条件:

首先,我在这里设置属性工作正常:

<condition property="isWindows">
    <os family="windows"/>
</condition>
Run Code Online (Sandbox Code Playgroud)

然后我尝试在目标中使用它:

<target name="-post-jar">
    <condition property="isWindows" value="true">
         <!-- set this property, only if isWindows set -->
         <property name="launch4j.dir" location="launch4j" />
    </condition>

    <!-- Continue doing things, regardless of property -->
    <move file="${dist.jar.dir}" tofile="myFile"/>
    <!-- etc -->
</target>
Run Code Online (Sandbox Code Playgroud)

我收到一个错误:"条件不支持嵌套的"property"元素." 问题是:如何正确地将条件放入目标中,为什么错误引用了'嵌套'属性?

JB *_*zet 2

condition用于定义属性,但不根据属性的值执行某些操作。

使用带有ifunless属性的目标可以根据属性的值执行某些任务。