ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <Gilbert.Reb...@huk-coburg.de>
Subject RE: ANT / AntXtras quick question.
Date Tue, 18 Sep 2007 13:05:22 GMT
 
Hi,


-----Original Message-----
From: warhero [mailto:beingthexemplary@gmail.com] 
Sent: Tuesday, September 18, 2007 2:53 AM
To: user@ant.apache.org
Subject: ANT / AntXtras quick question.


/*
I'm having trouble trying to figure out how to make sure a property is
not
empty.

So I have a properties file like so
myprop=something.

And if the myprop is not empty (myprop=) then execute something. Does
that
make sense? here's some kind of pseudocode.

<if myprop != ''>
  <exec whatever>
</if>

Just some pseudo code, but get's the point across..
*/

If you're running the AntXtras task suite you can go with assert, i.e.

<project name="bla" default="main" basedir=".">
  <!-- // Taskdefs -->
  <!-- Import AntXtras -->
  <taskdef resource="com/idaremedia/antx/install/antlib.xml"/>
  <!-- Taskdefs // -->

  <!-- // Properties -->
  <property name="testproperty" value="foobar"/>
  <!-- Properties // -->

    <target name="depends">

<!-- make sure property is set, but will also return true if property
        is set to "" -->
 <assert isset="testproperty"/>
 <!-- make sure the property is a string of chars, will return
    false if it's set to 12345 or also if property is an empty string ""
-->
<assert matches="\w+" property="testproperty"/>
      
   <echo>
     Yup, $${testproperty} set to ${line.separator} => ${testproperty}
    </echo>
        
    </target>

    <target name="main" depends="depends"/>
</project>


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


Mime
View raw message