I have two directories, let's call them src
and build
. My build system works so that for all files with mtime more recent in src
than in build
it copies the file from src
to buid
and does some transformations (minification, versioning, etc.). Otherwise skips as the file is considered up to date.
This however poses a problem when source file is deleted, as its built version is still present in build
and gets into map file generated afterwards.
$ ls src
example1.js
example2.js
$ ant do-the-stuff
...
$ ls build
example1.js
example1-12345.min.js
example2.js
example2-23456.min.js
.map
$ cat .map
example1.js=example1-12345.min.js
example2.js=example2-23456.min.js
$ rm src/example2.js
$ ant do-the-stuff
...
$ cat .map
example1.js=example1-12345.min.js
example2.js=example2-23456.min.js
Is there a way to delete files not present in another directory with Ant? From set theory point of view it's a simple A\B operation.
This is what I have tried already but didn't work:
<delete dir="build">
<exclude name="src/*" />
</delete>
<delete dir="build">
<exclude>
<fileset name="src" />
</exclude>
</delete>
<delete dir="build">
<fileset dir="build/*">
<not>
<present targetdir="src" />
</not>
</fileset>
</delete>