< : MatchingTask>

Description

This is an abstract task that should be used by all those tasks that require to include or exclude files based on pattern matching.

Parameters

Attribute Description Type Required?
defaultexcludes Sets whether default exclusions should be used or not. boolean ?
followsymlinks Sets whether or not symbolic links should be followed. boolean ?
casesensitive Sets case sensitivity of the file system boolean ?
excludes Sets the set of exclude patterns. Patterns may be separated by a comma or a space. String ?
includesfile Sets the name of the file containing the includes patterns. File ?
excludesfile Sets the name of the file containing the includes patterns. File ?
includes Sets the set of include patterns. Patterns may be separated by a comma or a space. String ?

Parameters accepted as nested elements

<patternset> ...

Named collection of include/exclude tags.

Moved out of MatchingTask to make it a standalone object that could be referenced (by scripts for example).

Attribute Description Type Required
includes Appends includes to the current list of include patterns. Patterns may be separated by a comma or a space. String ?
refid Makes this instance in effect a reference to another PatternSet instance.

You must not set another attribute or nest elements inside this element if you make it a reference.

Reference ?
excludesfile Sets the name of the file containing the excludes patterns. File ?
includesfile Sets the name of the file containing the includes patterns. File ?
excludes Appends excludes to the current list of exclude patterns. Patterns may be separated by a comma or a space. String ?

<exclude>

inner class to hold a name on list. "If" and "Unless" attributes may be used to invalidate the entry based on the existence of a property (typically set thru the use of the Available task).
Attribute Description Type Required
name Sets the name pattern. String ?
unless Sets the unless attribute. This attribute and the "if" attribute are used to validate the name, based in the existence of the property. String ?
if Sets the if attribute. This attribute and the "unless" attribute are used to validate the name, based in the existence of the property. String ?

<include>

inner class to hold a name on list. "If" and "Unless" attributes may be used to invalidate the entry based on the existence of a property (typically set thru the use of the Available task).
Attribute Description Type Required
name Sets the name pattern. String ?
unless Sets the unless attribute. This attribute and the "if" attribute are used to validate the name, based in the existence of the property. String ?
if Sets the if attribute. This attribute and the "unless" attribute are used to validate the name, based in the existence of the property. String ?

<custom> (Of type ExtendSelector )

Selector that selects files by forwarding the request on to other classes.
Attribute Description Type Required
classpath Set the classpath to load the classname specified using an attribute. Path ?
error String ?
classpathref Set the classpath to use for loading a custom selector by using a reference. Reference ?
refid Reference ?
classname Sets the classname of the custom selector. String ?

<present> (Of type PresentSelector )

Selector that filters files based on whether they appear in another directory tree. It can contain a mapper element, so isn't available as an ExtendSelector (since those parameters can't hold other elements).
Attribute Description Type Required
error String ?
targetdir The name of the file or directory which is checked for matching files. File ?
refid Reference ?
present This sets whether to select a file if its dest file is present. It could be a negate boolean, but by doing things this way, we get some documentation on how the system works. A user looking at the documentation should clearly understand that the ONLY files whose presence is being tested are those that already exist in the source directory, hence the lack of a destonly option. String ["srconly", "both"] ?

<none> (Of type NoneSelector )

This selector has a collection of other selectors. All of those selectors must refuse to select a file before the file is considered selected by this selector.
Attribute Description Type Required
error String ?
refid Reference ?

<not> (Of type NotSelector )

This selector has one other selectors whose meaning it inverts. It actually relies on NoneSelector for its implementation of the isSelected() method, but it adds a check to ensure there is only one other selector contained within.
Attribute Description Type Required
error String ?
refid Reference ?

<type> (Of type TypeSelector )

Selector that selects a certain kind of file: directory or regular.
Attribute Description Type Required
error String ?
refid Reference ?
type Set the type of file to require. String ["file", "dir"] ?

<modified> (Of type ModifiedSelector )

Selector class that uses Algorithm, Cache and Comparator for its work. The Algorithm is used for computing a hashvalue for a file. The Comparator decides whether to select or not. The Cache stores the other value for comparison by the Comparator in a persistent manner.

The ModifiedSelector is implemented as a CoreSelector and uses default values for all its attributes therefore the simpliest example is

   
       
           
       
   
 

The same example rewritten as CoreSelector with setting the all values (same as defaults are) would be

   
       
           
               
               
           
       
   
 

And the same rewritten as CustomSelector would be

   
       
           
               
               
               
               
               
               
           
       
   
 

All these three examples copy the files from src to dest using the ModifiedSelector. The ModifiedSelector uses the PropertyfileCache , the DigestAlgorithm and the EqualComparator for its work. The PropertyfileCache stores key-value-pairs in a simple java properties file. The filename is cache.properties. The update flag lets the selector update the values in the cache (and on first call creates the cache). The DigestAlgorithm computes a hashvalue using the java.security.MessageDigest class with its MD5-Algorithm and its standard provider. The new computed hashvalue and the stored one are compared by the EqualComparator which returns 'true' (more correct a value not equals zero (1)) if the values are not the same using simple String comparison.

A useful scenario for this selector is inside a build environment for homepage generation (e.g. with Apache Forrest).

 
      generate the site using forrest 
     

      upload the changed files 
     
         
             
         
     
 
 
Here all changed files are uploaded to the server. The ModifiedSelector saves therefore much upload time.

This selector supports the following nested param's:

namevaluesdescriptionrequired
cache propertyfile which cache implementation should be used
  • propertyfile - using java.util.Properties
no, defaults to 'propertyfile'
algorithm hashvalue | digest which algorithm implementation should be used
  • hashvalue - loads the file content into a String and uses its hashValue() method
  • digest - uses java.security.MessageDigest class
  • no, defaults to digest
    comparator equal | role which comparator implementation should be used
  • equal - simple comparison using String.equals()
  • role - uses java.text.RuleBasedCollator class
  • no, defaults to equal
    update true | false If set to true, the cache will be stored, otherwise the values will be lost. no, defaults to true
    seldirs true | false If set to true, directories will be selected otherwise not no, defaults to true
    cache.* depends on used cache value is stored and given to the Cache-Object for initialisation depends on used cache
    algorithm.* depends on used algorithm value is stored and given to the Algorithm-Object for initialisation depends on used algorithm
    comparator.* depends on used comparator value is stored and given to the Comparator-Object for initialisation depends on used comparator
    If another name is used a BuildException "Invalid parameter" is thrown.

    This selector uses reflection for setting the values of its three interfaces (using org.apache.tools.ant.IntrospectionHelper) therefore no special 'configuration interfaces' has to be implemented by new caches, algorithms or comparators. All present setXX methods can be used. E.g. the DigestAlgorithm can use a specified provider for computing its value. For selecting this there is a setProvider(String providername) method. So you can use a nested .

    Attribute Description Type Required
    comparator String ["equal", "rule"] ?
    seldirs Support for seldirs attribute. boolean ?
    algorithm String ["hashvalue", "digest"] ?
    cache String ["propertyfile"] ?
    error String ?
    refid Reference ?
    update Support for update attribute. boolean ?

    <or> (Of type OrSelector )

    This selector has a collection of other selectors, any of which have to select a file in order for this selector to select it.
    Attribute Description Type Required
    error String ?
    refid Reference ?

    <contains> (Of type ContainsSelector )

    Selector that filters files based on whether they contain a particular string.
    Attribute Description Type Required
    error String ?
    casesensitive Whether to ignore case in the string being searched. boolean ?
    refid Reference ?
    ignorewhitespace Whether to ignore whitespace in the string being searched. boolean ?
    text The string to search for within a file. String ?

    <depend> (Of type DependSelector )

    Selector that filters files based on whether they are newer than a matching file in another directory tree. It can contain a mapper element, so isn't available as an ExtendSelector (since those parameters can't hold other elements).
    Attribute Description Type Required
    error String ?
    targetdir File ?
    refid Reference ?
    granularity int ?

    <different> (Of type DifferentSelector )

    This selector selects files against a mapped set of target files, selecting all those files which are different. Files with different lengths are deemed different automatically Files with identical timestamps are viewed as matching by default, unless you specify otherwise. Contents are compared if the lengths are the same and the timestamps are ignored or the same, except if you decide to ignore contents to gain speed.

    This is a useful selector to work with programs and tasks that don't handle dependency checking properly; Even if a predecessor task always creates its output files, followup tasks can be driven off copies made with a different selector, so their dependencies are driven on the absolute state of the files, not a timestamp.

    Clearly, however, bulk file comparisons is inefficient; anything that can use timestamps is to be preferred. If this selector must be used, use it over as few files as possible, perhaps following it with an <uptodate;> to keep the descendent routines conditional.

    Attribute Description Type Required
    ignorecontents This flag tells the selector to ignore contents boolean ?
    error String ?
    targetdir File ?
    refid Reference ?
    ignorefiletimes This flag tells the selector to ignore file times in the comparison boolean ?
    granularity int ?

    <size> (Of type SizeSelector )

    Selector that filters files based on their size.
    Attribute Description Type Required
    when This specifies when the file should be selected, whether it be when the file matches a particular size, when it is smaller, or whether it is larger. String ["less", "more", "equal"] ?
    units Sets the units to use for the comparison. This is a little complicated because common usage has created standards that play havoc with capitalization rules. Thus, some people will use "K" for indicating 1000's, when the SI standard calls for "k". Others have tried to introduce "K" as a multiple of 1024, but that falls down when you reach "M", since "m" is already defined as 0.001.

    To get around this complexity, a number of standards bodies have proposed the 2^10 standard, and at least one has adopted it. But we are still left with a populace that isn't clear on how capitalization should work.

    We therefore ignore capitalization as much as possible. Completely mixed case is not possible, but all upper and lower forms are accepted for all long and short forms. Since we have no need to work with the 0.001 case, this practice works here.

    This function translates all the long and short forms that a unit prefix can occur in and translates them into a single multiplier.

    String ["K", "k", "kilo", "KILO", "Ki", "KI", "ki", "kibi", "KIBI", "M", "m", "mega", "MEGA", "Mi", "MI", "mi", "mebi", "MEBI", "G", "g", "giga", "GIGA", "Gi", "GI", "gi", "gibi", "GIBI", "T", "t", "tera", "TERA", "Ti", "TI", "ti", "tebi", "TEBI"] ?
    error String ?
    refid Reference ?
    value A size selector needs to know what size to base its selecting on. This will be further modified by the multiplier to get an actual size limit. long ?

    <majority> (Of type MajoritySelector )

    This selector is here just to shake up your thinking a bit. Don't get too caught up in boolean, there are other ways you can evaluate a collection of selectors. This one takes a vote of the selectors it contains, and majority wins. You could also have an "all-but-one" selector, a "weighted-average" selector, and so on. These are left as exercises for the reader (as are the usecases where this would be necessary).
    Attribute Description Type Required
    error String ?
    refid Reference ?
    allowtie A attribute to specify what will happen if number of yes votes is the same as the number of no votes defaults to true boolean ?

    <containsregexp> (Of type ContainsRegexpSelector )

    Selector that filters files based on a regular expression.
    Attribute Description Type Required
    error String ?
    refid Reference ?
    expression The regular expression used to search the file. String ?

    <filename> (Of type FilenameSelector )

    Selector that filters files based on the filename.
    Attribute Description Type Required
    error String ?
    casesensitive Whether to ignore case when checking filenames. boolean ?
    name The name of the file, or the pattern for the name, that should be used for selection. String ?
    refid Reference ?
    negate You can optionally reverse the selection of this selector, thereby emulating an <exclude> tag, by setting the attribute negate to true. This is identical to surrounding the selector with <not></not>. boolean ?

    <selector> (Of type SelectSelector )

    This selector just holds one other selector and forwards all requests to it. It exists so that there is a single selector type that can exist outside of any targets, as an element of project. It overrides all of the reference stuff so that it works as expected. Note that this is the only selector you can reference.
    Attribute Description Type Required
    error String ?
    refid Reference ?
    unless Sets the unless attribute to a property which cannot exist for the selector to select any files. String ?
    if Sets the if attribute to a property which must exist for the selector to select any files. String ?

    <includesfile>

    inner class to hold a name on list. "If" and "Unless" attributes may be used to invalidate the entry based on the existence of a property (typically set thru the use of the Available task).
    Attribute Description Type Required
    name Sets the name pattern. String ?
    unless Sets the unless attribute. This attribute and the "if" attribute are used to validate the name, based in the existence of the property. String ?
    if Sets the if attribute. This attribute and the "unless" attribute are used to validate the name, based in the existence of the property. String ?

    <date> (Of type DateSelector )

    Selector that chooses files based on their last modified date.
    Attribute Description Type Required
    refid Reference ?
    millis For users that prefer to express time in milliseconds since 1970 long ?
    checkdirs Should we be checking dates on directories? boolean ?
    datetime Sets the date. The user must supply it in MM/DD/YYYY HH:MM AM_PM format String ?
    granularity Sets the number of milliseconds leeway we will give before we consider a file not to have matched a date. int ?
    pattern Sets the pattern to be used for the SimpleDateFormat String ?
    when Sets the type of comparison to be done on the file's last modified date. String ["before", "after", "equal"] ?
    error String ?

    <excludesfile>

    inner class to hold a name on list. "If" and "Unless" attributes may be used to invalidate the entry based on the existence of a property (typically set thru the use of the Available task).
    Attribute Description Type Required
    name Sets the name pattern. String ?
    unless Sets the unless attribute. This attribute and the "if" attribute are used to validate the name, based in the existence of the property. String ?
    if Sets the if attribute. This attribute and the "unless" attribute are used to validate the name, based in the existence of the property. String ?

    <depth> (Of type DepthSelector )

    Selector that filters files based on the how deep in the directory tree they are.
    Attribute Description Type Required
    max The minimum depth below the basedir before a file is selected. int ?
    error String ?
    min The minimum depth below the basedir before a file is selected. int ?
    refid Reference ?

    <and> (Of type AndSelector )

    This selector has a collection of other selectors, all of which have to select a file in order for this selector to select it.
    Attribute Description Type Required
    error String ?
    refid Reference ?