Browse Source

Clean up recorder map when subbuild finishes, PR 20053

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278014 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 20 years ago
parent
commit
c03d0db2e3
1 changed files with 99 additions and 2 deletions
  1. +99
    -2
      src/main/org/apache/tools/ant/taskdefs/Recorder.java

+ 99
- 2
src/main/org/apache/tools/ant/taskdefs/Recorder.java View File

@@ -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 @@ import org.apache.tools.ant.types.EnumeratedAttribute;
* @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 @@ public class Recorder extends Task {
//////////////////////////////////////////////////////////////////////
// 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 @@ public class Recorder extends Task {
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 @@ public class Recorder extends Task {
recorder.closeFile();
}
}
recorder.setEmacsMode(emacsMode);
}

//////////////////////////////////////////////////////////////////////
@@ -231,5 +242,91 @@ public class Recorder extends Task {
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);
}
}


Loading…
Cancel
Save