amphibient
amphibient

Reputation: 31278

Failing task if variable undefined

I would like my Ant task to fail if a variable it uses is not defined. E.g. currently

<mkdir dir="${some.dir}"/>

always succeeds, if some.dir is defined, it creates a directory under the variable's value, if not it creates a directory named literally ${some.dir}.

Is there a way and how to switch between the currently lenient and a more strict mode of resolving variables in Ant? I am running this in Eclipse.

Upvotes: 2

Views: 158

Answers (1)

Dante WWWW
Dante WWWW

Reputation: 2739

<fail unless="some.dir"/>

<mkdir dir="${some.dir}"/>

or

<fail>
    <condition>
        <not>
            <isset property="some.dir"/>
        </not>
    </condition>
</fail>

<mkdir dir="${some.dir}"/>

Upvotes: 2

Related Questions