You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Julien Couvreur <jc...@redcart.com> on 2000/06/20 02:58:59 UTC

Weird "available" behavior on test for a just created file

Hello,

I have tried this little set of targets, by calling "ant test" but test.read
doesn't execute as one could have thought.
Would somebody have an idea ?
Are the writing deferred until the JVM closes or something ?

Here are the target, followed by the execution stdout :

    <target name="test.copy">
       <copyfile src="./A"
                 dest="./B"/>
       <echo message="Copied B"/>
    </target>

    <target name="test.read" depends="B.check" if="B.exists">
       <echo message="Test read executed"/>
    </target>

    <target name="test" depends="test.copy, test.read">
       <echo message="Test executed"/>
    </target>


Executing Target: test.copy
Copied B
Executing Target: B.check
Verifying presence of B
null
Executing Target: test.read
Executing Target: test
Test executed

NB : if you run "ant test" a second time right after, it will work fine,
since the first execution DID copy the A file to B...


Julien



Re: Weird "available" behavior on test for a just created file

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "JC" == Julien Couvreur <jc...@redcart.com> writes:

 JC> Are the writing deferred until the JVM closes or something ?

No, the available task is evaluated before your target test.copy is
executed. I assume your target B.check looks like

  <target name="B.check>
    <available property="B.exists" file="./B" />
  </target>

The problem is that some tasks, namely Available, Property, Taskdef
and Tstamp (did I forget one) get executed during parsing -
technically they do their work in the init method not in execute.

They get evaluated even when the target containing them doesn't get
executed at all BTW.

This is weird and it is going to change sometime - rather soon I hope.

Stefan