ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: Print message if property unset (or if file doesn't exist)?
Date Mon, 16 Sep 2002 23:09:54 GMT
The easy way using ant-contrib (see Related Projects) is:

<if>
  <not><available file="x.properties" type="file"/></not>
  <then>
    <echo message="WARNING: Missing properties file" />
  </then>
</if>

The hard-Ant way without <if>:

<target name="-check-file">
  <available property="x found" file="x.properties" type="file"/>
</target>

<target name="-echo-file" unless="x found">
  <echo message="WARNING: Missing properties file" />
</target>

<target name="whatever" depends="-check-file, -echo-file">
</target>

BUT, with Ant 1.5, you could easily <fail> instead of just <echo>ing:

<available property="x found" file="x.properties" type="file"/>
<fail message="ERROR: Missing properties file" unless="x found" />

--DD

-----Original Message-----
From: Karr, David [mailto:david.karr@attws.com] 
Sent: Monday, September 16, 2002 5:54 PM
To: 'ant-user@jakarta.apache.org'
Subject: Print message if property unset (or if file doesn't exist)?

I just want to print a message if a "build.properties" file does not exist
in a directory.  I would think this would be an easy thing to do, but I
don't see a way to do it.  I figured out how to set a property if a file is
present, but I don't see how to do anything with that.

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message