task.getProject().addBuildListener(new BuildListener() { private int stackDepth = 0; public void buildFinished(BuildEvent event) { } public void buildStarted(BuildEvent event) { } public void targetStarted(BuildEvent event) { } public void targetFinished(BuildEvent event) { } public void taskStarted(BuildEvent event) { stackDepth++; } public void taskFinished(BuildEvent event) {      if (stackDepth==0) { Message.uninit(); event.getProject().removeBuildListener(this); } stackDepth--; } public void messageLogged(BuildEvent event) { } });
    public AntMessageImpl(Task task) {        _task = task;    }