ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craeg K. Strong" <>
Subject [SUBMIT] New <dependset> task, a task to manage arbitrary dependencies between files
Date Wed, 18 Jul 2001 23:15:05 GMT
Enclosed please find the code and docs for a new proposed Ant task: 
a task to manage arbitrary dependencies between files.


The dependset task compares a set of source files with a set of target 
files. If any of the source files is more recent than any of the target 
files, all of the target files are removed.

Source files and target files are specified via nested FileSets. 
 Arbitrarily many source and target filesets may be specified, but at 
least one of each is required.

DependSet is useful to capture dependencies that are not or cannot be 
determined algorithmically. For example, the <style> task only compares 
the source XML file and XSLT stylesheet against the target file to 
determined whether to restyle the source. Using dependset you can extend 
this dependency checking to include a DTD or XSD file as well as other 
stylesheets imported by the main stylesheet.


There are many different options for how this could be implemented. 
 Since I am so lazy :-)  I decided
to reuse all of that wonderful functionality in the SourceFileScanner 
class.   It fits in principle--
since SourceFileScanner compares two sets of files and returns a 
restricted subset.  

The problem is that I needed to invert the logic in SourceFileScanner.   
The comparison algorithm is hardcoded
in SourceFileScanner to look for newer files, when in this case I 
actually want older files.  

If this were my own private project, I would have probably generalized 
SourceFileScanner and made two subclasses.
However, I wanted to avoid breaking backward compatibility.   Therefore, 
I chose to parameterize SourceFileScanner's
comparison algorithm.  By default it works as before, but you can invert 
it by choosing a different FileComparator
a la Strategy pattern.

You will notice that I also had to enhance MergingMapper slightly to 
accomodate multiple files.  This tiny change
does not break backward compatibility and (I hope) is still in keeping 
with the fundamental concept of the MergingMapper.

I am very interested in feedback on design, implementation, etc.



View raw message