ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Kavanagh <...@dotech.com>
Subject copy task addition
Date Mon, 26 May 2003 14:23:06 GMT
I just signed on to contribute something we found useful.

We wanted to filter files based on the project properties. This is 
because we do something like this in the top of our build.xml file;

    <property file="${user.home}/.membership-build.properties" />
    <property file="${user.home}/.build.properties" />
    <property file="${basedir}/.build.properties" />

So, we couldn't use properties pulled from any arbitrary files without 
modifying the copy task. So, what I did was to add a propsFiltering flag 
that uses the project properties as a filter set. Here is the diff of 
the Copy.java file from the 1.5.3-1 src dist. We've used this and it 
works great!

David

74a75
 > import java.util.Iterator;
106a108,110
 >       // DAK: filter from props
 >     protected boolean propsFiltering = false;
 >       // DAK
225a230,238
 >       // DAK: filter from props
 >     /**
 >      * If true, enables props filtering.
 >      */
 >     public void setPropsFiltering(boolean propsFiltering) {
 >         this.propsFiltering = propsFiltering;
 >     }
 >       // DAK
 >
521a535,545
 >                }
 >                // DAK: filter from props
 >                if (propsFiltering) {
 >                    FilterSet props = new FilterSet();
 >                    Hashtable projectProps = getProject().getProperties();
 >                    Iterator iter = projectProps.keySet().iterator();
 >                    while (iter.hasNext()) {
 >                        String name = (String)iter.next();
 >                        props.addFilter(name, 
(String)projectProps.get(name));
 >                    }
 >                    executionFilters.addFilterSet(props);
522a547
 >               // DAK:


Mime
View raw message