Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute ANT tasks on only files that have been modified

Tags:

eclipse

ant

I have a build script that does a number of things (minimize javascript, upload to amazon s3 etc). The minimize ANT task only operates on the javascript that I have modified and ignores the rest (I didn't write this script). I would like to do something similar for the amazon s3 task where only the updated content is upload in the task. Any leads on how to do this would be greatly appreciated.

like image 755
Akeem Avatar asked Jan 31 '09 00:01

Akeem


2 Answers

You can select a fileset with a modified date tag. The modified tag is insanely powerful, so check it out: Ant Selectors - Modified.

In order for it to tell what has changed, it can keep a cache in a property file, which updates after each successful build, unless you use the delayupdate attribute - so perhaps to test it, you can have:

<param name="commitUpdate" value="false" />
[...]
<ftp ...>
    <fileset dir="src">
        <modified delayupdate="${commitUpdate}" />
    </fileset>
</ftp>

And of course you could set that commitUpdate via a command-line param or something.

like image 67
Nathan Strutz Avatar answered Oct 26 '22 04:10

Nathan Strutz


You may want to consider the OutOfDate Ant Task provided by the Ant-contrib library. It allows you to set a sequential/parallel task to execute for each source file in a fileset. You can apply a file mapper to define the target files to test the source files against so only the files that have been modified run the specific sequential/parallel task.

Check out this SO thread:

How to execute an Ant task only when source files have been modified?

like image 1
ricosrealm Avatar answered Oct 26 '22 06:10

ricosrealm