ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Dawson <tdaw...@wamnet.com>
Subject proposed <uptodate> enhancement (implementation attached)
Date Tue, 20 Mar 2001 14:57:47 GMT
Hello,
 
I'd like to submit a change for Ant 1.4 to add a "value" attribute to the
<uptodate> task.

The reason is that there is a case where I'd like a variable to set to
"false" (rather than "true") if the given target file is up to date.  Here's
what I'm currently doing and why I think the proposed approach is nicer:

I like to make ample use of filtering with the <copy> task.  My filters are
set from properties files.  If any of the properties files have changed
since the last build, I need to set the overwrite attribute on <copy> to
"true", so that the file will be filtered and copied even though the source
file hasn't changed.

Currently to do this, I have to do a level of indirection with an extra
target.  Inside "init", I use <uptodate> in combination with <touch> to
determine whether any of the properties files have changed since the last
build.  Then I have to call another target with an "unless" in order to flip
the boolean value received from the <uptodate> task.

  <target name="init">
    [...]
    <uptodate property="buildconfig.uptodate" targetfile="${last.build.ts}">
      <srcfiles dir="." includes="*.properties"/>
    </uptodate>
    <touch file="${last.build.ts}"/>
    [...]
  </target>

  <target name="setOverwrite" unless="buildconfig.uptodate">
    <property name="overwrite" value="true"/>
  </target>

  <target name="compile"
          depends="init,setOverwrite,...">
    [...]
    <copy filtering="yes" todir="${classes.source}"
overwrite="${overwrite}">
      <fileset dir="${source.dir}">
        <include name="**/*.properties" />
      </fileset>
    </copy>
    [...]
  </target>

As you can see, this is pretty much a hack in order to get it to do what I
need.  If we add a value attribute to <uptodate>, then I can do away with
the setOverwrite target with the following:

  <target name="init">
    [...]
    <uptodate property="overwrite"
              value="false"
              targetfile="${last.build.ts}">
      <srcfiles dir="." includes="buildconfig*.properties"/>
    </uptodate>
    <touch file="${last.build.ts}"/>
    [...]
  </target>

And just use ${overwrite} inside my copy task -- much simpler and easier to
understand!

I'm not an ANT committer, so I'd like to ask someone who is to please
consider this submission and include it in the 1.4 tree if nobody rasies any
objections.

Thanks,

Tim Dawson
Chief Software Architect
WAM!NET, Inc.

 <<UpToDate.java>> 

Mime
View raw message