ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Nerrière <christian.nerri...@akazi.com>
Subject Re: "finally" task, listener problem
Date Fri, 20 Dec 2002 09:39:38 GMT
Hello,
For your requirement of buid end date/time, you can add a task which is a
build listener and when you receive the "build started" event you get
date/time from system and also when you receive "build finished". You just
have to print the date/time difference...?

Beware with listeners, I try to understand my "build finished event not
received" problem and after many tests, it seems that if I execute the
"listener task" in a task called by <antcall>, it never receives the event
"build finished"... Strange.
Christian.

----- Original Message -----
From: "Benoit Voisin" <benoit.voisin@ergoidp.dk>
To: "'Ant Users List'" <ant-user@jakarta.apache.org>
Sent: Thursday, December 19, 2002 6:32 PM
Subject: RE: "finally" task, listener problem


> I cannot answer your problem, but if someone goes in the ant code to
correct
> anything, I would find very usefull that the "Build Successfull in XX
> seconds" also contained a date/time. If I have time and other find it
> usefull I will probably try to submit a patch on that.
>
> Benoit
>
> -----Original Message-----
> From: Christian Nerrière [mailto:christian.nerriere@akazi.com]
> Sent: 19. december 2002 17:58
> To: ant-user@jakarta.apache.org
> Subject: "finally" task, listener problem
>
>
> Hello,
>
> I have got a problem with build listener : I have created a <finally> task
> to perform some tasks when build is finished. This tasks implements
> "TaskContainer" interface so it contains some sub-tasks to execute on
build
> end and it implements "BuildListener" interface too to receive the
"finished
> build" event. The code of this is relatively simple.
> When I use this task in the begin of build, it works good but when I use
it
> in the middle of the script (900 code lines), the "finished build" event
> seems to be never received by the task...
> Does someone has an idea about this ?
> Thanks.
> Christian.
>
> Following, the code of this very complex task :
>
> public class Finally
>   extends Task
>   implements BuildListener, TaskContainer {
>
>   private Vector _subTasks = new Vector();
>   private String _buildSuccessProperty = null;
>
>  /**
>   * Set attribute "buildSuccessProperty"
>   * @param onSuccessful
>   */
>   public void setBuildSuccessProperty( String buildSuccessProperty ) {
>     _buildSuccessProperty = buildSuccessProperty;
>   }
>
>  /**
>   * Signals that a build has finished.
>   * @param event
>   */
>   public void buildFinished(BuildEvent event) {
>
> trace("buildFinished");
>
>     Throwable e = event.getException();
>     if ( e == null ) {
>       trace( "build successful." );
>       if ( _buildSuccessProperty != null ) {
>         // Build has succeeded: set the success property
>         super.project.setProperty(_buildSuccessProperty, "true");
>         trace( "property ["+_buildSuccessProperty+"] set!" );
>       }
>     }
>     else {
>       e.printStackTrace();
>       trace( "build failed." );
>     }
>
>     for (int i=0 ; i< _subTasks.size() ; i++ ) {
>       Task task = (Task) _subTasks.get(i);
>       task.execute();
>     }
>   }
>
>  /**
>   * Signals that a build has started.
>   * @param event
>   */
>   public void buildStarted(BuildEvent event) {
>   }
>
>  /**
>   * Signals a message logging event.
>   * @param event
>   */
>   public void messageLogged(BuildEvent event) {
>   }
>
>  /**
>   * Signals that a target has finished.
>   * @param event
>   */
>   public void targetFinished(BuildEvent event) {
>     trace( "targetFinished" + event.getTarget());
>   }
>
>  /**
>   * Signals that a target is starting.
>   * @param event
>   */
>   public void targetStarted(BuildEvent event) {
>     trace( "targetStarted" + event.getTarget());
>   }
>
>  /**
>   * Signals that a task has finished.
>   * @param event
>   */
>   public void taskFinished(BuildEvent event) {
>     trace( "taskFinished" + event.getTask());
>   }
>
>  /**
>   * Signals that a task is starting.
>   * @param event
>   */
>   public void taskStarted(BuildEvent event) {
>     trace( "taskStarted" + event.getTask());
>   }
>
>  /**
>   * Task execution.
>   * @throws BuildException
>   */
>   public void execute() throws BuildException {
>
>     getProject().addBuildListener( this );
>     trace( "execute: build listener added" );
>   }
>
>  /**
>   * Adds a task to this task container
>   * @param task
>   * @see org.apache.tools.ant.TaskContainer
>   */
>   public void addTask(Task task) {
>
>    _subTasks.add(task);
>   }
>
>  /**
>   * Trace method.
>   * @param message
>   */
>   public void trace( String message ) {
>     getProject().log( this, message, Project.MSG_VERBOSE );
>   }
>
>
> --
> To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message