ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs TaskOutputStream.java
Date Tue, 04 Jul 2000 18:18:12 GMT
rubys       00/07/04 11:18:12

  Modified:    src/main/org/apache/tools/ant Project.java
                        ProjectHelper.java
  Added:       src/main/org/apache/tools/ant/taskdefs TaskOutputStream.java
  Removed:     src/main/org/apache/tools/ant TaskOutputStream.java
  Log:
  Various cleanups
  1) Nomenclature: nested elements, not nested properties
  2) Run task instead of
  
  Revision  Changes    Path
  1.24      +7 -11     jakarta-ant/src/main/org/apache/tools/ant/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- Project.java	2000/07/03 12:10:26	1.23
  +++ Project.java	2000/07/04 18:18:01	1.24
  @@ -430,12 +430,12 @@
           Vector sortedTargets = topoSort(targetName, targets);
   
           int curidx = 0;
  -        String curtarget;
  +        Target curtarget;
   
           do {
  -            curtarget = (String) sortedTargets.elementAt(curidx++);
  -            runTarget(curtarget, targets);
  -        } while (!curtarget.equals(targetName));
  +            curtarget = (Target) sortedTargets.elementAt(curidx++);
  +            runTarget(curtarget);
  +        } while (!curtarget.getName().equals(targetName));
       }
   
       public File resolveFile(String fileName) {
  @@ -679,14 +679,10 @@
       // Given a string defining a target name, and a Hashtable
       // containing the "name to Target" mapping, pick out the
       // Target and execute it.
  -    private final void runTarget(String target, Hashtable targets)
  +    public void runTarget(Target target)
           throws BuildException {
   
  -        currentTarget = (Target)targets.get(target);
  -        if (currentTarget == null) {
  -            throw new RuntimeException("Unexpected missing target `"+target+
  -                                       "' in this project.");
  -        }
  +        currentTarget = target;
   
           try {
               fireTargetStarted();
  @@ -803,7 +799,7 @@
               throw new RuntimeException("Unexpected internal error: expected to pop "+root+"
but got "+p);
           }
           state.put(root, VISITED);
  -        ret.addElement(root);
  +        ret.addElement(target);
       }
   
       private static BuildException makeCircularException(String end, Stack stk) {
  
  
  
  1.15      +6 -4      jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java
  
  Index: ProjectHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ProjectHelper.java	2000/06/24 15:16:59	1.14
  +++ ProjectHelper.java	2000/07/04 18:18:02	1.15
  @@ -327,9 +327,11 @@
   
           public void init(String tag, AttributeList attrs) throws SAXParseException {
               task = project.createTask(tag);
  +            project.currentTask = task;
               configure(task, attrs);
               task.setLocation(new Location(buildFile.toString(), locator.getLineNumber(),
locator.getColumnNumber()));
               task.init();
  +            project.currentTask = null;
   
               // Top level tasks don't have associated targets
               if (target != null) {
  @@ -355,20 +357,20 @@
           }
   
           public void startElement(String name, AttributeList attrs) throws SAXParseException
{
  -            new NestedPropertyHandler(this, task).init(name, attrs);
  +            new NestedElementHandler(this, task).init(name, attrs);
           }
       }
   
       /**
        * Handler for all nested properties.
        */
  -    private class NestedPropertyHandler extends AbstractHandler {
  +    private class NestedElementHandler extends AbstractHandler {
           private DocumentHandler parentHandler;
   
           private Object target;
           private Object child;
   
  -        public NestedPropertyHandler(DocumentHandler parentHandler, Object target) {
  +        public NestedElementHandler(DocumentHandler parentHandler, Object target) {
               super(parentHandler);
   
               this.target = target;
  @@ -393,7 +395,7 @@
           }
   
           public void startElement(String name, AttributeList attrs) throws SAXParseException
{
  -            new NestedPropertyHandler(this, child).init(name, attrs);
  +            new NestedElementHandler(this, child).init(name, attrs);
           }
       }
   
  
  
  
  1.1                  jakarta-ant/src/main/org/apache/tools/ant/taskdefs/TaskOutputStream.java
  
  Index: TaskOutputStream.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * 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", "Tomcat", 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
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.tools.ant.taskdefs;
  
  import org.apache.tools.ant.*;
  import java.io.*;
  
  /**
   * Redirects text written to a stream thru the standard
   * ant logging mechanism. This class is useful for integrating
   * with tools that write to System.out and System.err. For example,
   * the following will cause all text written to System.out to be
   * logged with "info" priority:
   * <pre>System.setOut(new PrintStream(new TaskOutputStream(project, Project.MSG_INFO)));</pre>
   *
   * @author James Duncan Davidson (duncan@x180.com)
   */
  
  public class TaskOutputStream extends OutputStream {
  
      private Project project;
      private StringBuffer line;
      private int msgOutputLevel;
  
      /**
       * Constructs a new JavacOutputStream with the given project
       * as the output source for messages.
       */
  
      TaskOutputStream(Project project, int msgOutputLevel) {
          this.project = project;
          this.msgOutputLevel = msgOutputLevel;
  
          line = new StringBuffer();
      }
  
      /**
       * Write a character to the output stream. This method looks
       * to make sure that there isn't an error being reported and
       * will flush each line of input out to the project's log stream.
       */
  
      public void write(int c) throws IOException {
          char cc = (char)c;
          if (cc == '\r' || cc == '\n') {
              // line feed
              if (line.length() > 0) {
                  processLine();
              }
          } else {
              line.append(cc);
          }
      }
  
      /**
       * Processes a line of input and determines if an error occured.
       */
  
      private void processLine() {
          String s = line.toString();
          project.log(s, msgOutputLevel);
          line = new StringBuffer();
      }
  }
  
  
  
  

Mime
View raw message