ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael J McGonagle <fnd...@rcnchicago.com>
Subject Re: Using the 'Uptodate' task
Date Thu, 14 Feb 2002 19:33:01 GMT
Michael J McGonagle wrote:
> 
> Michael J McGonagle wrote:
> >
> > Hello all,
> >
> > I am working with trying get target execution based on the files
> > timestamp. According to what I read about 'uptodate', this is what I
> > should need.
> 
> I moved all of the properties and the 'uptodate' task into an 'init'
> target, and that part seems to work now, I get the proper results from
> running the file twice. The first time it tells me that the "TargetFile"
> is not there to it does not set the property. The second time it tells
> me that the file IS there so it sets the attribute to 'true'.
> 

Alright, I have figured out my problem. I stumbled accross this
completely by accident.

I had written my original build.xml file as such:

<project name="myproject" default="mytarget">
    <target name="init">
        <uptodate property="file3.isBuilt" targetfile="file3.txt">
            <srcfiles dir="." includes="file1.txt, file2.txt" />
        </uptodate>
    </target>
    <target name="mytarget" depends="init" unless="${file3.isBuilt}">
        <echo>
            If you see this, the file3.txt needs rebuilding.
        </echo>
    </target>
</project>


The problem turned out that I was using 'unless="${file3.isBuilt}"' when
it should have been 'unless="file3.isBuilt"'.

Is it just a matter of the difference between testing for the
'exsistance of' and getting the 'value of'? If this is the case, I can
see why things were happening the way they were with my original code.
Both times it was getting a 'true' when it tested for the property. On
the one hand, it was true because the variable was not set, and in the
second, it is true because its VALUE was true, and I was asking for its
value and not its exsistance.

Thanks,

Mike

> Ok, now the rub, I put an 'unless' clause in my target that created the
> file I am testing for, but it still executes both times. Am I reading
> something wrong? Should I be using an 'if' instead?
> 
> I attached my updated file again,
> 
> Thanks,
> 
> Mike
> 
>   ------------------------------------------------------------------------
> <project name="test" default="audio">
>         <target name="init">
>                 <property name="sfront" value="sfront" />
> 
>                 <property name="filename" value="bach" />
>                 <property name="saolfile" value="${filename}.saol" />
>                 <property name="saslfile" value="${filename}.sasl" />
>                 <property name="midifile" value="${filename}.mid" />
>                 <property name="mp4file" value="${filename}.mp4" />
>                 <property name="aoutfile" value="${filename}.wav" />
> 
>                 <property name="aoutmode" value="-aout ${aoutfile}" />
>                 <property name="ainmode" value="" />
> 
>                 <property name="cc" value="gcc" />
>                 <property name="c_exec" value="${filename}" />
>                 <property name="c_optim" value="-O3" />
>                 <property name="cflags" value="${c_optim}" />
> 
>                 <property name="iolink" value="" />
>                 <property name="redirect" value="" />
> 
>                 <uptodate property="aoutfile_exsists" targetfile="${aoutfile}">
>                         <srcfiles dir="." includes="${saolfile}, ${saslfile}, ${midifile}"
/>
>                 </uptodate>
>         </target>
> 
>         <target name="audio" depends="init" unless="${aoutfile_exsists}">
>                 <exec executable="${sfront}">
>                         <arg line="${aoutmode} ${ainmode} -orc ${saolfile} -sco ${saslfile}
-midi ${midifile} -o ${c_exec}.c" />
>                 </exec>
>                 <exec executable="${cc}">
>                         <arg line="${cflags} ${c_exec}.c -lm ${iolink} -o ${c_exec}"
/>
>                 </exec>
>                 <exec executable="./${c_exec}">
>                         <arg line="${redirect}" />
>                 </exec>
>         </target>
> </project>
> 
>   ------------------------------------------------------------------------
> --
> To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

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