ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Cepek" <mce...@smsi.com>
Subject uptodate bug?
Date Wed, 08 Jan 2003 17:03:13 GMT
I have a really simple Ant script (below) which appears to show the
<uptodate> task not working as documented.  I've tested this on both
unix and windows Ant 1.5.1.  Can anyone reproduce it and/or tell me what
I'm doing wrong or misunderstanding?

The script creates two files with different timestamps, and then tests
<uptodate>:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

<?xml version="1.0"?>
<project name="test" default="test">

    <property name="tmpdir" value="temp"/>

    <target name="test" description="run me">
        <delete dir="${tmpdir}"/>
        <mkdir dir="${tmpdir}"/>
        <touch file="${tmpdir}/one.txt"/>
        <sleep seconds="1"/>
        <touch file="${tmpdir}/two.txt"/>
        <uptodate property="is-uptodate" targetfile="${tmpdir}/one.tmp">
            <srcfiles dir="${tmpdir}" file="two.txt"/>
        </uptodate>
        <property name="is-uptodate" value="false"/>
        <echo message="Is one.txt newer than two.txt?  ${is-uptodate}"/>
        <echo message=""/>

        <delete dir="${tmpdir}"/>
        <mkdir dir="${tmpdir}"/>
        <touch file="${tmpdir}/two.txt"/>
        <sleep seconds="1"/>
        <touch file="${tmpdir}/one.txt"/>
        <uptodate property="is-uptodate2"
targetfile="${tmpdir}/one.tmp">
            <srcfiles dir="${tmpdir}" file="two.txt"/>
        </uptodate>
        <property name="is-uptodate2" value="false"/>
        <echo message="Is one.txt newer than two.txt?
${is-uptodate2}"/>
    </target>

    <target name="test2" description="manual target">
        <uptodate property="is-uptodate" targetfile="${tmpdir}/one.tmp"
            <srcfile="${tmpdir}/two.txt"/>
        <echo message="is-uptodate = ${is-uptodate}"/>
    </target>

    <target name="clean" description="clean up all created files">
        <delete dir="${tmpdir}"/>
    </target>

</project>
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

I have found the <sleep> task to be REQUIRED for Ant under Windows to
believe that one.txt and two.txt have different timestamps.  This in
itself seems like a major issue worth noting somewhere in the Ant docs.
But back to the <uptodate> task...

Below is the output I get under unix.  I first run the 'test' target
which automatically timestamps the files.  After that I use the 'test2'
target twice to manually timestamp the files.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

mike@orkid$ ant -version
Apache Ant version 1.5.1 compiled on October 2 2002
mike@orkid$ ant -f test.xml
Buildfile: test.xml

test:
    [mkdir] Created dir: /usr2/home/mike/temp
    [touch] Creating /usr2/home/mike/temp/one.txt
    [touch] Creating /usr2/home/mike/temp/two.txt
     [echo] Is one.txt newer than two.txt?  false

   [delete] Deleting directory /usr2/home/mike/temp
    [mkdir] Created dir: /usr2/home/mike/temp
    [touch] Creating /usr2/home/mike/temp/two.txt
    [touch] Creating /usr2/home/mike/temp/one.txt
     [echo] Is one.txt newer than two.txt?  false

BUILD SUCCESSFUL
Total time: 4 seconds
mike@orkid$ touch temp/one.txt
mike@orkid$ ant -f test.xml test2
Buildfile: test.xml

test2:
     [echo] is-uptodate = ${is-uptodate}

BUILD SUCCESSFUL
Total time: 2 seconds
mike@orkid$ touch temp/two.txt
mike@orkid$ ant -f test.xml test2
Buildfile: test.xml

test2:
     [echo] is-uptodate = ${is-uptodate}

BUILD SUCCESSFUL
Total time: 2 seconds
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

It is as if <uptodate> does not set the property EVER.

Can anyone tell me what I'm doing wrong, or reproduce these results?
Thanks.


--
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