You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2006/05/28 12:03:04 UTC

DO NOT REPLY [Bug 39671] New: - BuildListener

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39671>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39671

           Summary: BuildListener
           Product: Ant
           Version: 1.6.5
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core
        AssignedTo: dev@ant.apache.org
        ReportedBy: philippe26@wanadoo.fr


I would like to dynamically modifiy a <junit> target.
For this i implement a buil listener.
The following code does not work.

public class AntListener implements BuildListener
  {
[...]

  public AntListener()
    {
    }

[...]

  public void taskStarted(BuildEvent event)
    {
    Task task = (Task) event.getSource();
    if (task instanceof UnknownElement)
      {
      taskStarted(((UnknownElement) task).getTask(), event);
      }
    }

  private void taskStarted(Task task, BuildEvent event)
    {
    if (task instanceof JUnitTask)  >>>>>>>>>>>>>>>> I NEVER SEE THE JunitTask 
      {
      taskStarted((JUnitTask) task, event);
      }
    }

  private void taskStarted(JUnitTask task, BuildEvent event)
    {
    [...] // some processing here
    }
  }


And i think its because in package org.apache.tools.ant.Target,
builder listeners are not notified in the right place. See below:

-----------------------------------------------------------------------
current code
-------------------------------------------------------------------------

    /**
     * Performs this task if it's still valid, or gets a replacement
     * version and performs that otherwise.
     *
     * Performing a task consists of firing a task started event,
     * configuring the task, executing it, and then firing task finished
     * event. If a runtime exception is thrown, the task finished event
     * is still fired, but with the exception as the cause.
     */
    public final void perform() {
        if (!invalid) {
            getProject().fireTaskStarted(this);   >>>>>>>>>>>> EVENT FIRED BUT
JUNIT TASK IS NOT BUILT
            Throwable reason = null;
            try {
                maybeConfigure(); 		  >>>>>>>>>>>> JUNIT TASK IS BUILT HERE
                execute();
            } catch (BuildException ex) {
                if (ex.getLocation() == Location.UNKNOWN_LOCATION) {
                    ex.setLocation(getLocation());
                }
                reason = ex;
                throw ex;
            } catch (Exception ex) {
                reason = ex;
                BuildException be = new BuildException(ex);
                be.setLocation(getLocation());
                throw be;
            } catch (Error ex) {
                reason = ex;
                throw ex;
            } finally {
                getProject().fireTaskFinished(this, reason);
            }
        } else {
            UnknownElement ue = getReplacement();
            Task task = ue.getTask();
            task.perform();
        }
    }

------------------------------------------------------------------------------
BUGFIX
------------------------------------------------------------------------------

    /**
     * Performs this task if it's still valid, or gets a replacement
     * version and performs that otherwise.
     *
     * Performing a task consists of firing a task started event,
     * configuring the task, executing it, and then firing task finished
     * event. If a runtime exception is thrown, the task finished event
     * is still fired, but with the exception as the cause.
     */
    public final void perform() {
        if (!invalid) {
            Throwable reason = null;
            try {
                maybeConfigure(); 		      >>>>>>>>>>>> JUNIT TASK IS BUILT HERE
                getProject().fireTaskStarted(this);   >>>>>>>>>>>> EVENT FIRED
BUT JUNIT TASK IS BUILT
                execute();
            } catch (BuildException ex) {
                if (ex.getLocation() == Location.UNKNOWN_LOCATION) {
                    ex.setLocation(getLocation());
                }
                reason = ex;
                throw ex;
            } catch (Exception ex) {
                reason = ex;
                BuildException be = new BuildException(ex);
                be.setLocation(getLocation());
                throw be;
            } catch (Error ex) {
                reason = ex;
                throw ex;
            } finally {
                getProject().fireTaskFinished(this, reason);
            }
        } else {
            UnknownElement ue = getReplacement();
            Task task = ue.getTask();
            task.perform();
        }
    }

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 39671] - BuildListeners are not notified at the right time

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39671>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39671





------- Additional Comments From mguillemot@yahoo.fr  2006-06-28 19:35 -------
I think that the idea is interesting... but that it would break some existing
usages.
An example of a scenario from (coming changes in) WebTest. WebTest makes an
heavy use of tasks to write automated functional Web Application test suites and
generate reports of the execution. In this reports, each task appears with the
parameters it became. WebTest uses a custom PropertyHelper to be able to show
the real attributes the tasks have received. As a PropertyHelper doesn't receive
any information on the task for which it expands properties (perhaps should I
open a new issue for this or is it to specific?), I need to guess what is the
"current" task thanks to a build listener. The change proposed here would
require a mofification in the logic of guessing the current task.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 39671] - BuildListeners are not notified at the right time

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39671>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39671


gudnabrsam@yahoo.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|BuildListener               |BuildListeners are not
                   |                            |notified at the right time




-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 39671] - BuildListener

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39671>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39671





------- Additional Comments From conor@apache.org  2006-06-27 18:02 -------
I'm reasonably happy with this change but just have a small reservation about
backward compatibility issues. Would it break any existing users?

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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