Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the Ant <modified> selector to work properly

Tags:

ant

I have a target in ANT that needs to run a compiler on a given set of files twice: once for debug, once for production. I only want to run the compiler if the source file has changed, so I set up a <modified> selector. However, since I need both the debug and prod task to run for a given modified file, I set the update property to false on the first run. I have something along the lines of:

<!-- Do the debug build -->
<apply executable="compiler">
    <fileset dir="${js.src.dir}" includes="*.js">
        <!-- don't update the cache so the prod build below works -->
        <modified update="false" 
            seldirs="true"
            cache="propertyfile"
            algorithm="digest"
            comparator="equal">
          <param name="cache.cachefile" value="cache.properties"/>
          <param name="algorithm.algorithm" value="md5"/>
        </modified>
    </fileset>
    <args for debug build/>
</apply>
<!-- Do the production build -->
<apply executable="compiler">
    <fileset dir="${js.src.dir}" includes="*.js">
        <modified update="true" 
            seldirs="true"
            cache="propertyfile"
            algorithm="digest"
            comparator="equal">
          <param name="cache.cachefile" value="cache.properties"/>
          <param name="algorithm.algorithm" value="md5"/>
        </modified>
    </fileset>
    <args for prod build/>
</apply>

However this is not working. My first call to the compiler ends up updating the cache anyway, and the second call gets skipped. What am I missing here?

UPDATE: I got around the problem by using the <depend> selector instead, but still curious how to accomplish the same using <modified>

like image 464
Abhijit Rao Avatar asked Sep 26 '10 00:09

Abhijit Rao


1 Answers

update is broken until apparently 1.8.0:

https://issues.apache.org/bugzilla/show_bug.cgi?id=32597

Only took about 5 years to fix!

like image 141
Andrew Avatar answered Nov 15 '22 07:11

Andrew