Madz
Madz

Reputation: 199

How to execute an Ant task only if a file is changed?

I have been trying to use the following code to get the task working only if the file is changed but it doesn't seem to work. The task is called irrespective of whether there is a change or not.

<target name ="widget-change" depends="configuration-for-widgets">
    <fileset dir="${src-location}">         
        <include name="com.myApp.MainClasses.myClassOne.java"/>
        <include name="com.myApp.MainClasses.myClassTwo.java"/>
        <modified update="true"/>
    </fileset>          
    <antcall target="gwt-compile"/>         
</target>

Upvotes: 1

Views: 1211

Answers (1)

ewan.chalmers
ewan.chalmers

Reputation: 16235

Are you using an ant version less that 1.8.0?

In Getting the Ant selector to work properly, the asker resolved by using a depend selector instead of modified.

In Ant bug 32958, an workaround suggested is to use a nested update param:

You may be able to work around this by using a nested

      <param name="update" value="false"/>

instead of the update attribute.

Upvotes: 1

Related Questions