ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Edward Zarecor" <edward_zare...@harvard.edu>
Subject unless problem ant 1.4.1
Date Fri, 20 Sep 2002 15:19:47 GMT
Maybe I'm loosing it, but this logic looks pretty straightforward to me
except that my second target which defines an unless condition executes if
the available file exists and if it doesn't exist.  Echoing the condition
property is giving me the expected result, either true or the literal
${transfer.complete} depending upon the existence of the file.  So, if the
property is not set, and the unless parameter of a called target specifies
that parameter, it should not execute.  It's not a depends for any other
task by the way and is not called by any other task.

>From the ant 1.4.1 docs:

unless:  the name of the property that must not be set in order for this
target to execute.

I've included the tasks and the output when the file exists and when it
doesn't.  Notice that condition is working as expected.  Thanks in advance
for any help.

Ed.

<target name="check-file-completion">
    <!-- target looks for a 0 byte file that indicates -->
    <!-- that the import archive has been transfered completely -->

    <echo>Looking for file:
${source.directory.base}/${data.file.prefix}${file.number}.txt</echo>
    <condition property="transfer.complete" >
        <and>
            <available
file="${source.directory.base}/${data.file.prefix}${file.number}.txt" />
        </and>
    </condition>

    <echo>transfer status: ${transfer.complete}</echo>

    <antcall target="fail.transfer.complete" />

    <echo>Initial target</echo>

    <fail/>
</target>

<target name="fail.transfer.complete" unless="${transfer.complete}">
    <echo>transfer status: ${transfer.complete}</echo>
    <delete file="${run.file}" />
    <echo>Completion files are not present. Failing for now.</echo>
    <fail />
</target>

output file exists:

Buildfile: ant_run.xml

check-file-completion:
     [echo] Looking for file: C:/test/from/D0000001.txt
     [echo] transfer status: true

fail.transfer.complete:
     [echo] transfer status: true
   [delete] Deleting: C:\eclipse\workspace\project\scripts\project.lock
     [echo] Completion files are not present. Failing for now.

BUILD FAILED

...................................

output file doesn't exist:

C:\eclipse\workspace\PS2HUID\scripts>ant -buildfile ant_run.xml
Buildfile: ant_run.xml

start:

check-file-completion:
     [echo] Looking for file: C:/test/from/D0000001.txt
     [echo] transfer status: ${transfer.complete}

fail.transfer.complete:
     [echo] transfer status: ${transfer.complete}
   [delete] Deleting: C:\eclipse\workspace\project\scripts\project.lock
     [echo] Completion files are not present. Failing for now.

BUILD FAILED


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


Mime
View raw message