Getting the Ant <modified> selector to work properly

谁都会走 提交于 2019-12-07 04:49:53

问题


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>


回答1:


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!



来源:https://stackoverflow.com/questions/3796124/getting-the-ant-modified-selector-to-work-properly

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!