ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian DeWeese <brd1_reut...@yahoo.com>
Subject Evaluating properties at runtime - not happening with <if>
Date Fri, 16 Aug 2002 21:10:50 GMT

I'm having a problem with properties being evaluated at runtime with the <if> task in
ant-contrib.  I'm hoping someone here can give me a clue to how and when ProjectHelp.configure()
gets called and what I might be able to do to force it to re-configure the task prior to execution.

The <if> task uses 2 Sequential tasks, one each for the then and else clauses.  If I
define a property in a regular Sequential task, the next task can access that property.  But
If I do so in the then clause of <if> it can not.

I thought the problem may be because IfTask extends ConditionBase rather than Task so I changed
it to extend Task but that didn't help.  I also overrode maybeConfigure() to pass the call
onto both Sequential tasks but that didn't help as well.

Here is a test file and it's output.  The 1st property, test1, is correctly evaluated by the
<echo> task but the 2nd one is not. 

 

<project name="test" default="main" basedir=".">
  <target name="main">
    <taskdef resource="net/sf/antcontrib/antcontrib.properties" />

    <sequential>
      <property name="test1" value="foobar"/>
      <echo message="test1=${test1}"/>
    </sequential>

    <if>
      <isset property="basedir"/>
      <then>
        <property name="test2" value="foobar"/>
        <echo message="test2=${test2}"/>
      </then>
    </if>
  </target>
</project>

The output is

Buildfile: test.xml

main:
     [echo] test1=foobar
     [echo] test2=${test2}

BUILD SUCCESSFUL
Total time: 1 second


Brian DeWeese



---------------------------------
Do You Yahoo!?
HotJobs, a Yahoo! service - Search Thousands of New Jobs
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message