ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Recorder.java
Date Thu, 17 Mar 2005 15:13:10 GMT
bodewig     2005/03/17 07:13:09

  Modified:    src/main/org/apache/tools/ant/taskdefs Recorder.java
  Log:
  Clean up recorder map when subbuild finishes, PR 20053
  
  Revision  Changes    Path
  1.26      +99 -2     ant/src/main/org/apache/tools/ant/taskdefs/Recorder.java
  
  Index: Recorder.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Recorder.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- Recorder.java	6 Jan 2005 17:22:44 -0000	1.25
  +++ Recorder.java	17 Mar 2005 15:13:09 -0000	1.26
  @@ -17,8 +17,10 @@
   package org.apache.tools.ant.taskdefs;
   
   import java.util.Hashtable;
  +import org.apache.tools.ant.BuildEvent;
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
  +import org.apache.tools.ant.SubBuildListener;
   import org.apache.tools.ant.Task;
   import org.apache.tools.ant.types.EnumeratedAttribute;
   
  @@ -40,7 +42,7 @@
    * @since Ant 1.4
    * @ant.task name="record" category="utility"
    */
  -public class Recorder extends Task {
  +public class Recorder extends Task implements SubBuildListener {
   
       //////////////////////////////////////////////////////////////////////
       // ATTRIBUTES
  @@ -66,6 +68,15 @@
       //////////////////////////////////////////////////////////////////////
       // CONSTRUCTORS / INITIALIZERS
   
  +    /**
  +     * Overridden so we can add the task as build listener.
  +     *
  +     * @since Ant 1.7
  +     */
  +    public void init() {
  +        getProject().addBuildListener(this);
  +    }
  +
       //////////////////////////////////////////////////////////////////////
       // ACCESSOR METHODS
   
  @@ -153,6 +164,7 @@
           RecorderEntry recorder = getRecorder(filename, getProject());
           // set the values on the recorder
           recorder.setMessageOutputLevel(loglevel);
  +        recorder.setEmacsMode(emacsMode);
           if (start != null) {
               if (start.booleanValue()) {
                   recorder.reopenFile();
  @@ -162,7 +174,6 @@
                   recorder.closeFile();
               }
           }
  -        recorder.setEmacsMode(emacsMode);
       }
   
       //////////////////////////////////////////////////////////////////////
  @@ -231,5 +242,91 @@
           return entry;
       }
   
  +    /**
  +     * Empty implementation required by SubBuildListener interface.
  +     *
  +     * @since Ant 1.7
  +     */
  +    public void buildStarted(BuildEvent event) {
  +    }
  +
  +    /**
  +     * Empty implementation required by SubBuildListener interface.
  +     *
  +     * @since Ant 1.7
  +     */
  +    public void subBuildStarted(BuildEvent event) {
  +    }
  +
  +    /**
  +     * Empty implementation required by SubBuildListener interface.
  +     *
  +     * @since Ant 1.7
  +     */
  +    public void targetStarted(BuildEvent event) {
  +    }
  +
  +    /**
  +     * Empty implementation required by SubBuildListener interface.
  +     *
  +     * @since Ant 1.7
  +     */
  +    public void targetFinished(BuildEvent event) {
  +    }
  +
  +    /**
  +     * Empty implementation required by SubBuildListener interface.
  +     *
  +     * @since Ant 1.7
  +     */
  +    public void taskStarted(BuildEvent event) {
  +    }
  +
  +    /**
  +     * Empty implementation required by SubBuildListener interface.
  +     *
  +     * @since Ant 1.7
  +     */
  +    public void taskFinished(BuildEvent event) {
  +    }
  +
  +    /**
  +     * Empty implementation required by SubBuildListener interface.
  +     *
  +     * @since Ant 1.7
  +     */
  +    public void messageLogged(BuildEvent event) {
  +    }
  +
  +    /**
  +     * Cleans recorder registry.
  +     *
  +     * @since Ant 1.7
  +     */
  +    public void buildFinished(BuildEvent event) {
  +        cleanup();
  +    }
  +
  +    /**
  +     * Cleans recorder registry, if this is the subbuild the task has
  +     * been created in.
  +     *
  +     * @since Ant 1.7
  +     */
  +    public void subBuildFinished(BuildEvent event) {
  +        if (event.getProject() == getProject()) {
  +            cleanup();
  +        }
  +    }
  +
  +    /**
  +     * cleans recorder registry and removes itself from BuildListener list.
  +     *
  +     * @since Ant 1.7
  +     */
  +    private void cleanup() {
  +        recorderEntries.clear();
  +        getProject().removeBuildListener(this);
  +    }
   }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message