Suhail Shaikh
Suhail Shaikh

Reputation: 21

How to determine if a property value is directory path using ANT?

We have a property file containing list of key and their values. The value of a property can be directory paths or numeric values or hyperlink URLs or database URLs or database server I.P address or port numbers etc.

I would like to know if there is a way in ANT build file to detrmine if the value of a property is directory path or not. Based on the answer, for the values with directory path, we would like to execute a special logic than others.

Please advise.

Upvotes: 2

Views: 557

Answers (1)

SamG
SamG

Reputation: 656

You want to use the Available Ant task. This is untested but it should get you started.

<target name="check.directory">
       <available file="${my.property}" type="dir" property="my.property.present"/>
</target>

<target name="do-if-directory" depends="check.directory" if="my.property.present">
    <!-- custom task here -->
</target> 

Alternatively you can use the Condition Ant Task.

Upvotes: 1

Related Questions