adviner
adviner

Reputation: 3577

Apache ant condition based on os

Im using cordova and the scripts from windows and mac are cordova.cmd and cordova What i want to do in my ant script is execute the right script based on the os:

Windows:

Mac:

I have tried:

<property name="CordovaCmd" value="" />

<condition property="isWindows" value="true"> 
<propertyreset name="CordovaCmd" value="cordova.cmd"/>
</condition>

<condition property="isMac" value="true">
<propertyreset name="CordovaCmd" value="cordova"/>
</condition>

But I get the error: condition doesn't support the nested "propertyreset" element.

So I know im doing something wrong. Any advice

Upvotes: 2

Views: 945

Answers (1)

user3139488
user3139488

Reputation:

<condition property="is.mac">
    <os family="mac"/>
</condition>

<condition property="is.windows">
    <os family="windows"/>
</condition>

<if>
    <isset property="is.windows"/>
    <then>
        <property name="CordovaCmd" value="cordova.cmd"/>
    </then>
    <else>
        <if>
            <isset property="is.mac"/>
            <then>
                <property name="CordovaCmd" value="cordova"/>
            </then>
        </if>
    </else>
</if>

Upvotes: 3

Related Questions