ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <hol...@yahoo.com>
Subject RE: Checking if properties is set
Date Wed, 19 Sep 2001 23:12:54 GMT
Okay -- right after (of course :) I sent the reply saying "there's no way
currently...", I thought of a way. It's a little weird, but it does work.
If you set a "check" property to be the symbolic representation of the
property name (ie., include the dollar-sign and curly-braces) then do an
<equals> against the real property and the "check" one, you'll be able to
check whether it's simply set. For example:

  <target name="runBuild" depends="chkProps" unless="missingProp">
    <echo message="Running build..."/>
  </target>

  <target name="chkProps">
    <property name="chkA" value="$${A}"/>
    <property name="chkB" value="$${B}"/>
    <property name="chkC" value="$${C}"/>
    <property name="chkD" value="$${D}"/>
    <condition property="missingProp">
      <or>
        <equals arg1="${chkA}" arg2="${A}"/>
        <equals arg1="${chkB}" arg2="${B}"/>
        <equals arg1="${chkC}" arg2="${C}"/>
        <equals arg1="${chkD}" arg2="${D}"/>
      </or>
    </condition>
  </target>

The "build" target will only run if all four properties are set (doesn't
matter to what).

P.S. to Ylan: I haven't seen any of my mail come through to the list
today, so I Cc'd you on this, in the hopes you'll get it sooner rather
than later.

Diane

--- Ylan Segal <ylan@digiworks.tv> wrote:
> > <target name="init">
> >     <condition property="all.okay">
> >         // use NOT, AND, OR etc here to check all required properties
> >     </condition>
> >     <antcall target="failIfMissingRequiredProperties"/>
> > </target>
> 
> But how do I check within the NOT, AND, OR if a property is set. The
> attribute "available" is a mimic of the Available task, and there you
> can
> only check for a classname, file or resource as far as I can tell from
> the
> ant manual, not for a property.
> 
> Ylan
> 


=====
(holtdl@yahoo.com)



__________________________________________________
Terrorist Attacks on U.S. - How can you help?
Donate cash, emergency relief information
http://dailynews.yahoo.com/fc/US/Emergency_Information/

Mime
View raw message