ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <>
Subject RE: how to check that a property exist
Date Wed, 11 Jun 2008 11:45:15 GMT
-----Original Message-----
From: []

Sent: Wednesday, June 11, 2008 12:22 PM
Subject: how to check that a property exist

I've a properties file like that:


I run my build.xml providing a parameter:

ant -DIPEvent=TestEvent

And I would like to set the value of a property named 'pollerEventValue'
according to these rules:

1) if exists a property like 

    <property name="pollerEvent"

then the requested value is:

    <property name="pollerEventValue" value="${${pollerEvent}}"/>
?????? but I think the syntax is wrong

2) else take as value

    <property name="pollerEventValue"

So if I run:

 ant -DIPEvent=TestEvent   the expected value is B
 ant -DIPEvent=other       the expected value is A (the default one)

Could anyone help me to solve that ?

that's a tricky one, i once had a similar problem and discovered, that
it works with the <var> task of antcontrib, so the solution in your case
would be =

ant -DIPEvent=TestEvent -f yourbuild.xml ...


<!-- // Taskdefs -->
<!-- Import AntContrib -->
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<!-- Taskdefs // -->

<!-- // Properties -->
<property name="defaultPollerManagedServer" value="A"/>
<property name="TestEvent.pollerManagedServer" value="B"/>
<property name="DummyEvent.pollerManagedServer" value="C"/>
<!-- Properties // -->

<target name="depends"> 
  <isset property="${IPEvent}.pollerManagedServer"/>
     <var name="pollerEventValue"
     <property name="pollerEventValue"

<target name="main" depends="depends">
  <echo>$${pollerEventValue} == ${pollerEventValue}</echo>

you need antcontrib =

Regards, Gilbert

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message