From ant-dev-return-11469-apmail-jakarta-ant-dev-archive=jakarta.apache.org@jakarta.apache.org Wed Mar 14 14:06:51 2001 Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@jakarta.apache.org Received: (qmail 97918 invoked by uid 500); 14 Mar 2001 14:06:46 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: ant-dev@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list ant-dev@jakarta.apache.org Delivered-To: moderator for ant-dev@jakarta.apache.org Received: (qmail 45736 invoked from network); 14 Mar 2001 13:15:38 -0000 From: "Michael McCallum" To: ant-dev@jakarta.apache.org Date: Thu, 15 Mar 2001 02:15:26 +1300 MIME-Version: 1.0 Content-type: Multipart/Mixed; boundary=Message-Boundary-22887 Subject: [Patch] Re: Filter task feels wrong --> use FilterSets Reply-to: michael@spinsoftware.com Message-ID: <3AB025BE.31307.68E89C79@localhost> Priority: normal References: In-reply-to: X-mailer: Pegasus Mail for Win32 (v3.12c) X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N --Message-Boundary-22887 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body I thought they felt wrong too so I have implemented FilterSets. Moved all the code from around to a new FilterSet type. (out or project/filter task etc) Is backwards compatible with the filter task but has deprecation warnings. Can also use the filtersets to process the logs coming out of compilers. :) (when copying sources and then compiling one needs to have the error messages appearing in the right place.) eg copy srcs from source tree to build/src compile but error message are relative to build/src not source/home so... now error messages are relative to source/home after filtering :) On 9 Mar 2001, at 8:57, Barrie Treloar wrote: > On 8 Mar 2001, Stefan Bodewig wrote: > > > >From the Ant2 wish list: > > > > | * make usage of particular filters/filtersets explicit in copy tasks Done. use them like this... Also can use attribute filtersfile in filterset but not nested element yet. Am a little tired now so will do the documentation tomorrow. Michael p.s. This also includes the conditional patch I supplied earlier for the Exit task. --Message-Boundary-22887 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Text from file 'FilterSet.patch' ? ConditionalExit.patch ? test.xml ? FilterSet.patch ? lib/jakarta-ant-1.3-optional.jar ? src/main/org/apache/tools/ant/types/FilterSet.java Index: build.xml =================================================================== RCS file: /home/cvs/jakarta-ant/build.xml,v retrieving revision 1.142 diff -c -r1.142 build.xml *** build.xml 2001/03/09 11:45:11 1.142 --- build.xml 2001/03/14 13:00:40 *************** *** 181,186 **** --- 181,187 ---- + *************** *** 207,222 **** - - - --- 208,224 ---- + + + + + Index: src/main/org/apache/tools/ant/IntrospectionHelper.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/IntrospectionHelper.java,v retrieving revision 1.13 diff -c -r1.13 IntrospectionHelper.java *** src/main/org/apache/tools/ant/IntrospectionHelper.java 2001/01/20 13:41:56 1.13 --- src/main/org/apache/tools/ant/IntrospectionHelper.java 2001/03/14 13:04:20 *************** *** 227,233 **** as.set(p, element, value); } catch (IllegalAccessException ie) { // impossible as getMethods should only return public methods ! throw new BuildException(ie); } catch (InvocationTargetException ite) { Throwable t = ite.getTargetException(); if (t instanceof BuildException) { --- 227,235 ---- as.set(p, element, value); } catch (IllegalAccessException ie) { // impossible as getMethods should only return public methods ! throw new BuildException( "Impossible as getMethods should only return public methods " + ! attributeName + ! ": Actuall does happen if you have a public method on a private inner class", ie ); } catch (InvocationTargetException ite) { Throwable t = ite.getTargetException(); if (t instanceof BuildException) { Index: src/main/org/apache/tools/ant/Project.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v retrieving revision 1.55 diff -c -r1.55 Project.java *** src/main/org/apache/tools/ant/Project.java 2001/03/13 14:15:21 1.55 --- src/main/org/apache/tools/ant/Project.java 2001/03/14 13:04:20 *************** *** 54,59 **** --- 54,61 ---- package org.apache.tools.ant; + import org.apache.tools.ant.types.FilterSet; + import java.io.*; import java.util.*; import java.text.*; *************** *** 68,73 **** --- 70,76 ---- * file paths at runtime as well as defining various project properties. * * @author duncan@x180.com + * @author Michael McCallum */ public class Project { *************** *** 90,98 **** public static final String JAVA_1_2 = "1.2"; public static final String JAVA_1_3 = "1.3"; - public static final String TOKEN_START = "@"; - public static final String TOKEN_END = "@"; - private String name; private Hashtable properties = new Hashtable(); --- 93,98 ---- *************** *** 102,108 **** private Hashtable dataClassDefinitions = new Hashtable(); private Hashtable taskClassDefinitions = new Hashtable(); private Hashtable targets = new Hashtable(); ! private Hashtable filters = new Hashtable(); private File baseDir; private Vector listeners = new Vector(); --- 102,108 ---- private Hashtable dataClassDefinitions = new Hashtable(); private Hashtable taskClassDefinitions = new Hashtable(); private Hashtable targets = new Hashtable(); ! private FilterSet globalFilterSet = null; private File baseDir; private Vector listeners = new Vector(); *************** *** 296,310 **** return name; } ! public void addFilter(String token, String value) { if (token == null) return; ! log("Setting token to filter: " + token + " -> " + value, MSG_DEBUG); ! this.filters.put(token, value); ! } ! ! public Hashtable getFilters() { ! return filters; } // match basedir attribute in xml --- 296,310 ---- return name; } ! public void addFilter(String token, String value, Task task) { if (token == null) return; ! log("DEPRECATED user filterset - Setting token to filter: " + token + " -> " + value, MSG_DEBUG); ! if( globalFilterSet == null ) { ! globalFilterSet = new FilterSet( task ); ! } ! this.globalFilterSet.addFilter( token, value ); ! } // match basedir attribute in xml *************** *** 694,703 **** * * @throws IOException */ ! public void copyFile(String sourceFile, String destFile, boolean filtering, boolean overwrite, boolean preserveLastModified) throws IOException { ! copyFile(new File(sourceFile), new File(destFile), filtering, overwrite, preserveLastModified); } --- 694,703 ---- * * @throws IOException */ ! public void copyFile(String sourceFile, String destFile, FilterSet filterSet, boolean filtering, boolean overwrite, boolean preserveLastModified) throws IOException { ! copyFile(new File(sourceFile), new File(destFile), filterSet, filtering, overwrite, preserveLastModified); } *************** *** 731,737 **** */ public void copyFile(File sourceFile, File destFile, boolean filtering, boolean overwrite) throws IOException { ! copyFile(sourceFile, destFile, filtering, overwrite, false); } /** --- 731,737 ---- */ public void copyFile(File sourceFile, File destFile, boolean filtering, boolean overwrite) throws IOException { ! copyFile(sourceFile, destFile, null, filtering, overwrite, false); } /** *************** *** 743,749 **** * * @throws IOException */ ! public void copyFile(File sourceFile, File destFile, boolean filtering, boolean overwrite, boolean preserveLastModified) throws IOException { --- 743,749 ---- * * @throws IOException */ ! public void copyFile(File sourceFile, File destFile, FilterSet filterSet, boolean filtering, boolean overwrite, boolean preserveLastModified) throws IOException { *************** *** 759,765 **** parent.mkdirs(); } ! if (filtering) { BufferedReader in = new BufferedReader(new FileReader(sourceFile)); BufferedWriter out = new BufferedWriter(new FileWriter(destFile)); --- 759,770 ---- parent.mkdirs(); } ! // this should be removed along with globalFilter set when deprecation is final. ! if( filtering ) { ! filterSet = globalFilterSet; ! } ! ! if ( filterSet != null && filterSet.hasFilters() ) { BufferedReader in = new BufferedReader(new FileReader(sourceFile)); BufferedWriter out = new BufferedWriter(new FileWriter(destFile)); *************** *** 770,776 **** if (line.length() == 0) { out.newLine(); } else { ! newline = replace(line, filters); out.write(newline); out.newLine(); } --- 775,781 ---- if (line.length() == 0) { out.newLine(); } else { ! newline = filterSet.replaceTokens( line ); out.write(newline); out.newLine(); } *************** *** 839,889 **** } catch (Throwable other) { throw new BuildException("Exception setting the modification time " + "of " + file, other); - } - } - - /** - * Does replacement on the given string using the given token table. - * - * @returns the string with the token replaced. - */ - private String replace(String s, Hashtable tokens) { - int index = s.indexOf(TOKEN_START); - - if (index > -1) { - try { - StringBuffer b = new StringBuffer(); - int i = 0; - String token = null; - String value = null; - - do { - int endIndex = s.indexOf(TOKEN_END, - index + TOKEN_START.length() + 1); - if (endIndex == -1) { - break; - } - token = s.substring(index + TOKEN_START.length(), endIndex); - b.append(s.substring(i, index)); - if (tokens.containsKey(token)) { - value = (String) tokens.get(token); - log("Replacing: " + TOKEN_START + token + TOKEN_END + " -> " + value, MSG_VERBOSE); - b.append(value); - i = index + TOKEN_START.length() + token.length() + TOKEN_END.length(); - } else { - // just append TOKEN_START and search further - b.append(TOKEN_START); - i = index + TOKEN_START.length(); - } - } while ((index = s.indexOf(TOKEN_START, i)) > -1); - - b.append(s.substring(i)); - return b.toString(); - } catch (StringIndexOutOfBoundsException e) { - return s; - } - } else { - return s; } } --- 844,849 ---- Index: src/main/org/apache/tools/ant/taskdefs/Copy.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v retrieving revision 1.14 diff -c -r1.14 Copy.java *** src/main/org/apache/tools/ant/taskdefs/Copy.java 2001/01/22 21:15:09 1.14 --- src/main/org/apache/tools/ant/taskdefs/Copy.java 2001/03/14 13:04:21 *************** *** 73,78 **** --- 73,79 ---- * * @author Glenn McAllister glennm@ca.ibm.com * @author Stefan Bodewig + * @author Michael McCallum */ public class Copy extends Task { protected File file = null; // the source file *************** *** 91,96 **** --- 92,98 ---- protected Hashtable dirCopyMap = new Hashtable(); protected Mapper mapperElement = null; + protected FilterSet filterSet = null; /** * Sets a single source file to copy. *************** *** 124,133 **** --- 126,153 ---- * Sets filtering. */ public void setFiltering(boolean filtering) { + log( "*** DEPRECATED use filtersets instead", Project.MSG_ERR ); this.filtering = filtering; } /** + * Maybe creates a nested classpath element. + */ + public FilterSet createFilterset() { + if (filterSet == null) { + filterSet = new FilterSet( this ); + } + return filterSet; + } + + /** + * Set the a filter + */ + public FilterSet getFilterSet() { + return filterSet; + } + + /** * Overwrite any existing destination file(s). */ public void setOverwrite(boolean overwrite) { *************** *** 333,340 **** log("Copying " + fromFile + " to " + toFile, verbosity); project.copyFile(fromFile, ! toFile, ! filtering, forceOverwrite, preserveLastModified); } catch (IOException ioe) { --- 353,361 ---- log("Copying " + fromFile + " to " + toFile, verbosity); project.copyFile(fromFile, ! toFile, ! filterSet, ! filtering, forceOverwrite, preserveLastModified); } catch (IOException ioe) { Index: src/main/org/apache/tools/ant/taskdefs/Exit.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Exit.java,v retrieving revision 1.2 diff -c -r1.2 Exit.java *** src/main/org/apache/tools/ant/taskdefs/Exit.java 2001/01/03 14:18:30 1.2 --- src/main/org/apache/tools/ant/taskdefs/Exit.java 2001/03/14 13:04:22 *************** *** 55,79 **** package org.apache.tools.ant.taskdefs; import org.apache.tools.ant.*; /** * Just exit the active build, giving an additional message * if available. * * @author Nico Seessle */ public class Exit extends Task { ! private String message; ! public void setMessage(String value) { ! this.message = value; } ! public void execute() throws BuildException { ! if (message != null && message.length() > 0) { ! throw new BuildException(message); ! } else { ! throw new BuildException("No message"); } } } --- 55,138 ---- package org.apache.tools.ant.taskdefs; import org.apache.tools.ant.*; + import java.util.Enumeration; + import java.util.Hashtable; /** * Just exit the active build, giving an additional message * if available. + * + * Can supply conditional properties. + * With an if the task will exit if the property is set. + * With an unless the task will exit if the property is not set. * * @author Nico Seessle + * @author Michael McCallum */ public class Exit extends Task { ! ! /** The message to display. */ ! private String message_; ! ! /** The if value. Will exit if this value is set. */ ! private String ifProperty_; ! ! /** The unless value. Will exit if this value is not set. */ ! private String unlessProperty_; ! /** Test to see if the given property is set. ! * Returns true if we should exit. That is when there is an if condition and the property is set. ! * @param property The property to test. ! * @return true if we should fail of false if we should continue. */ ! private boolean testIfProperty( String property ) { ! // if its not set return true as we dont know if we should continue. ! if ( property == null || property.length() == 0 ) { ! return true; ! } ! return project.getProperty( property ) != null; } ! ! /** Test to see if the given property is set. ! * Returns true if we should exit. That is when there is an unless condition and the property is not set. ! * @param property The property to test. ! * @return true if we should fail of false if we should continue. */ ! private boolean testUnlessProperty( String property ) { ! // if its not set return true as we dont know if we should continue. ! if ( property == null || property.length() == 0 ) { ! return true; ! } ! return project.getProperty( property ) == null; ! } ! ! /** Set the message to display when executed. */ ! public void setMessage( String value ) { ! this.message_ = value; ! } ! ! /** Set the if property. Will exit if this value is set. ! * @param value The if value for conditional exiting. */ ! public void setIf( String value ) { ! this.ifProperty_ = value; ! } ! ! /** Set the unless property. Will exit if this value is not set. ! * @param value The unless value for conditional exiting. */ ! public void setUnless( String value ) { ! this.unlessProperty_ = value; ! } ! ! /** Execute this task. This will exit and print a message if the following conditions are met... ! * if value is set. ! * unless value is not set. */ public void execute() throws BuildException { ! if ( testUnlessProperty( unlessProperty_ ) && testIfProperty( ifProperty_ ) ) { ! if ( message_ != null && message_.length() > 0 ) { ! throw new BuildException(message_); ! } ! else { ! throw new BuildException("No message"); } + } } + } Index: src/main/org/apache/tools/ant/taskdefs/Filter.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Filter.java,v retrieving revision 1.8 diff -c -r1.8 Filter.java *** src/main/org/apache/tools/ant/taskdefs/Filter.java 2001/01/03 14:18:30 1.8 --- src/main/org/apache/tools/ant/taskdefs/Filter.java 2001/03/14 13:04:22 *************** *** 9,36 **** * are met: * * 1. Redistributions of source code must retain the above copyright ! * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright ! * notice, this list of conditions and the following disclaimer in ! * the documentation and/or other materials provided with the ! * distribution. * * 3. The end-user documentation included with the redistribution, if ! * any, must include the following acknowlegement: ! * "This product includes software developed by the ! * Apache Software Foundation (http://www.apache.org/)." ! * Alternately, this acknowlegement may appear in the software itself, ! * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Ant", and "Apache Software ! * Foundation" must not be used to endorse or promote products derived ! * from this software without prior written permission. For written ! * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache" ! * nor may "Apache" appear in their names without prior written ! * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES --- 9,36 ---- * are met: * * 1. Redistributions of source code must retain the above copyright ! * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright ! * notice, this list of conditions and the following disclaimer in ! * the documentation and/or other materials provided with the ! * distribution. * * 3. The end-user documentation included with the redistribution, if ! * any, must include the following acknowlegement: ! * "This product includes software developed by the ! * Apache Software Foundation (http://www.apache.org/)." ! * Alternately, this acknowlegement may appear in the software itself, ! * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Ant", and "Apache Software ! * Foundation" must not be used to endorse or promote products derived ! * from this software without prior written permission. For written ! * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache" ! * nor may "Apache" appear in their names without prior written ! * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *************** *** 54,133 **** package org.apache.tools.ant.taskdefs; ! import java.util.Enumeration; ! import java.util.Properties; import java.io.File; import java.io.FileInputStream; ! import org.apache.tools.ant.*; /** ! * This task sets a token filter that is used by the file copy methods ! * of the project to do token substitution, or sets mutiple tokens by ! * reading these from a file. ! * ! * @author Stefano Mazzocchi stefano@apache.org ! * @author Gero Vermaas gero@xs4all.nl */ public class Filter extends Task { ! private String token; ! private String value; ! private File filtersFile; ! ! public void setToken(String token) { ! this.token = token; ! } ! public void setValue(String value) { ! this.value = value; } ! public void setFiltersfile(File filtersFile) { ! this.filtersFile = filtersFile; } ! public void execute() throws BuildException { ! boolean isFiltersFromFile = filtersFile != null && token == null && value == null; ! boolean isSingleFilter = filtersFile == null && token != null && value != null; ! ! if (!isFiltersFromFile && !isSingleFilter) { ! throw new BuildException("both token and value parameters, or only a filtersFile parameter is required", location); ! } ! ! if (isSingleFilter) { ! project.addFilter(token, value); ! } ! ! if (isFiltersFromFile) { ! readFilters(); ! } ! } ! ! protected void readFilters() throws BuildException { ! log("Reading filters from " + filtersFile, Project.MSG_VERBOSE); ! FileInputStream in = null; ! try { ! Properties props = new Properties(); ! in = new FileInputStream(filtersFile); ! props.load(in); ! ! Project proj = getProject(); ! ! Enumeration enum = props.propertyNames(); ! while (enum.hasMoreElements()) { ! String strPropName = (String)enum.nextElement(); ! String strValue = props.getProperty(strPropName); ! proj.addFilter(strPropName, strValue); ! } ! } catch (Exception e) { ! throw new BuildException("Could not read filters from file: " + filtersFile); ! } finally { ! if (in != null) { ! try { ! in.close(); ! } catch (java.io.IOException ioex) {} ! } ! } } } --- 54,139 ---- package org.apache.tools.ant.taskdefs; ! // java io import java.io.File; import java.io.FileInputStream; + + // java util + import java.util.Enumeration; + import java.util.Properties; + + // ant core + import org.apache.tools.ant.BuildException; + import org.apache.tools.ant.Task; ! // ant types ! import org.apache.tools.ant.types.FilterSet; /** ! * This task sets a token filter that is used by the file copy methods of the ! * project to do token substitution, or sets mutiple tokens by reading these ! * from a file. ! * ! * @author Stefano Mazzocchi stefano@apache.org ! * @author Gero Vermaas gero@xs4all.nl ! * @author Michael McCallum */ public class Filter extends Task { ! private String token; ! private String value; ! private File filtersFile; ! ! /** ! * Sets the Token attribute of the Filter object ! * ! * @param token The new Token value ! */ ! public void setToken( String token ) { ! this.token = token; ! } ! ! /** ! * Sets the Value attribute of the Filter object ! * ! * @param value The new Value value ! */ ! public void setValue( String value ) { ! this.value = value; ! } ! ! /** ! * Sets the Filtersfile attribute of the Filter object ! * ! * @param filtersFile The new Filtersfile value ! */ ! public void setFiltersfile( File filtersFile ) { ! this.filtersFile = filtersFile; ! } ! ! /** ! * Description of the Method ! * ! * @exception BuildException Description of Exception ! */ ! public void execute() ! throws BuildException { ! boolean isFiltersFromFile = filtersFile != null && token == null && value == null; ! boolean isSingleFilter = filtersFile == null && token != null && value != null; ! if( !isFiltersFromFile && !isSingleFilter ) { ! throw new BuildException( "both token and value parameters, or only a filtersFile parameter is required", location ); } ! FilterSet filterSet = new FilterSet( this ); ! if( isSingleFilter ) { ! filterSet.addFilter( token, value ); } ! if( isFiltersFromFile ) { ! filterSet.readFiltersFromFile( filtersFile ); } + } + } + Index: src/main/org/apache/tools/ant/taskdefs/Javac.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javac.java,v retrieving revision 1.64 diff -c -r1.64 Javac.java *** src/main/org/apache/tools/ant/taskdefs/Javac.java 2001/01/12 14:08:50 1.64 --- src/main/org/apache/tools/ant/taskdefs/Javac.java 2001/03/14 13:04:22 *************** *** 93,98 **** --- 93,99 ---- * @author Robin Green greenrd@hotmail.com * @author Stefan Bodewig * @author J D Glanville + * @author Michael McCallum */ public class Javac extends MatchingTask { *************** *** 112,117 **** --- 113,119 ---- private String target; private Path bootclasspath; private Path extdirs; + private FilterSet filterSet; private boolean includeAntRuntime = true; private boolean includeJavaRuntime = false; *************** *** 161,166 **** --- 163,185 ---- */ public File getDestdir() { return destDir; + } + + /** + * Maybe creates a nested classpath element. + */ + public FilterSet createFilterset() { + if (filterSet == null) { + filterSet = new FilterSet( this ); + } + return filterSet; + } + + /** + * Set the a filter + */ + public FilterSet getFilterSet() { + return filterSet; } /** Index: src/main/org/apache/tools/ant/taskdefs/LogOutputStream.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/LogOutputStream.java,v retrieving revision 1.3 diff -c -r1.3 LogOutputStream.java *** src/main/org/apache/tools/ant/taskdefs/LogOutputStream.java 2001/01/03 14:18:30 1.3 --- src/main/org/apache/tools/ant/taskdefs/LogOutputStream.java 2001/03/14 13:04:22 *************** *** 56,61 **** --- 56,62 ---- import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; + import org.apache.tools.ant.types.FilterSet; import java.io.IOException; import java.io.OutputStream; *************** *** 70,75 **** --- 71,77 ---- * of data written to the stream. * * @author thomas.haas@softwired-inc.com + * @author Michael McCallum */ public class LogOutputStream extends OutputStream { *************** *** 79,84 **** --- 81,102 ---- private Task task; private int level = Project.MSG_INFO; + /** The set of filters applied to the lines that are logged. */ + private FilterSet filterSet_ = null; + + /** + * Creates a new instance of this class with a set of filters. + * + * @param task the task for whom to log + * @param level loglevel used to log data written to this stream. + * @param filterSet The filterset to process the logged lines with. + */ + public LogOutputStream(Task task, int level, FilterSet filterSet ) { + this.task = task; + this.level = level; + filterSet_ = filterSet; + } + /** * Creates a new instance of this class. * *************** *** 90,96 **** this.level = level; } - /** * Write the data to the buffer and flush the buffer, if a line * separator is detected. --- 108,113 ---- *************** *** 129,135 **** * @param line the line to log. */ protected void processLine(String line, int level) { ! task.log(line, level); } --- 146,157 ---- * @param line the line to log. */ protected void processLine(String line, int level) { ! if( filterSet_ == null ) { ! task.log( line, level ); ! } ! else { ! task.log( filterSet_.processLineStart( line ), level); ! } } Index: src/main/org/apache/tools/ant/taskdefs/LogStreamHandler.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/LogStreamHandler.java,v retrieving revision 1.2 diff -c -r1.2 LogStreamHandler.java *** src/main/org/apache/tools/ant/taskdefs/LogStreamHandler.java 2001/01/03 14:18:30 1.2 --- src/main/org/apache/tools/ant/taskdefs/LogStreamHandler.java 2001/03/14 13:04:22 *************** *** 56,61 **** --- 56,62 ---- import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; + import org.apache.tools.ant.types.FilterSet; import java.io.OutputStream; import java.io.InputStream; *************** *** 64,69 **** --- 65,71 ---- * Logs standard output and error of a subprocess to the log system of ant. * * @author thomas.haas@softwired-inc.com + * @author Michael McCallum */ public class LogStreamHandler extends PumpStreamHandler { *************** *** 77,82 **** --- 79,96 ---- public LogStreamHandler(Task task, int outlevel, int errlevel) { super(new LogOutputStream(task, outlevel), new LogOutputStream(task, errlevel)); + } + + /** + * Creates a new instance of this class. + * + * @param task the task for whom to log + * @param outlevel the loglevel used to log standard output + * @param errlevel the loglevel used to log standard error + * @param filterSet A set of filters to be applied to all lines being logged on this stream. + */ + public LogStreamHandler(Task task, int outlevel, int errlevel, FilterSet filterSet ) { + super( new LogOutputStream( task, outlevel, filterSet ), new LogOutputStream( task, errlevel, filterSet ) ); } } Index: src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java,v retrieving revision 1.3 diff -c -r1.3 DefaultCompilerAdapter.java *** src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java 2001/03/09 16:07:56 1.3 --- src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java 2001/03/14 13:04:23 *************** *** 69,74 **** --- 69,75 ---- * @author Robin Green greenrd@hotmail.com * @author Stefan Bodewig * @author J D Glanville + * @author Michael McCallum */ public abstract class DefaultCompilerAdapter implements CompilerAdapter { *************** *** 93,98 **** --- 94,102 ---- protected boolean includeAntRuntime; protected boolean includeJavaRuntime; + /** Filters to be applied to the output of the compiler. */ + protected FilterSet filterSet; + protected File[] compileList; protected static String lSep = System.getProperty("line.separator"); protected Javac attributes; *************** *** 116,121 **** --- 120,126 ---- location = attributes.getLocation(); includeAntRuntime = attributes.getIncludeantruntime(); includeJavaRuntime = attributes.getIncludejavaruntime(); + filterSet = attributes.getFilterSet(); } public Javac getJavac() { *************** *** 335,341 **** try { Execute exe = new Execute(new LogStreamHandler(attributes, Project.MSG_INFO, ! Project.MSG_WARN)); exe.setAntRun(project); exe.setWorkingDirectory(project.getBaseDir()); exe.setCommandline(commandArray); --- 340,347 ---- try { Execute exe = new Execute(new LogStreamHandler(attributes, Project.MSG_INFO, ! Project.MSG_WARN, ! filterSet)); exe.setAntRun(project); exe.setWorkingDirectory(project.getBaseDir()); exe.setCommandline(commandArray); Index: src/main/org/apache/tools/ant/types/defaults.properties =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/defaults.properties,v retrieving revision 1.2 diff -c -r1.2 defaults.properties *** src/main/org/apache/tools/ant/types/defaults.properties 2000/11/17 10:00:58 1.2 --- src/main/org/apache/tools/ant/types/defaults.properties 2001/03/14 13:04:46 *************** *** 1,4 **** ! path=org.apache.tools.ant.types.Path ! fileset=org.apache.tools.ant.types.FileSet ! patternset=org.apache.tools.ant.types.PatternSet ! mapper=org.apache.tools.ant.types.Mapper --- 1,5 ---- ! path=org.apache.tools.ant.types.Path ! fileset=org.apache.tools.ant.types.FileSet ! patternset=org.apache.tools.ant.types.PatternSet ! mapper=org.apache.tools.ant.types.Mapper ! filterset=org.apache.tools.ant.types.FilterSet --Message-Boundary-22887 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: ant-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: ant-dev-help@jakarta.apache.org --Message-Boundary-22887--