KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > forrest > eclipse > job > AntBuildListener


1 /*
2 * Copyright 2002-2005 The Apache Software Foundation or its licensors,
3 * as applicable.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */

17 package org.apache.forrest.eclipse.job;
18
19 import java.net.URL JavaDoc;
20
21 import org.apache.forrest.eclipse.ForrestPlugin;
22 import org.apache.log4j.Logger;
23 import org.apache.log4j.xml.DOMConfigurator;
24 import org.apache.tools.ant.BuildEvent;
25 import org.apache.tools.ant.BuildListener;
26 import org.eclipse.core.runtime.Path;
27 import org.eclipse.core.runtime.Platform;
28 import org.osgi.framework.Bundle;
29
30 /**
31  * A listener for Ant Builds, all events are logged to the standard logger.
32  */

33 public class AntBuildListener implements BuildListener{
34     /**
35      * Logger for this class
36      */

37     private static final Logger logger = Logger
38             .getLogger(AntBuildListener.class);
39
40     /**
41      *
42      */

43     public AntBuildListener() {
44         super();
45         Bundle bundle = Platform.getBundle(ForrestPlugin.ID);
46         URL JavaDoc log4jConf = Platform.find(bundle, new Path("conf/log4j.xml"));
47         DOMConfigurator.configure(log4jConf);
48     }
49
50     /* (non-Javadoc)
51      * @see org.apache.tools.ant.BuildListener#buildFinished(org.apache.tools.ant.BuildEvent)
52      */

53     public void buildFinished(BuildEvent event) {
54         logger.info("Ant Finished Build: " + event.getMessage());
55     }
56     
57     /* (non-Javadoc)
58      * @see org.apache.tools.ant.BuildListener#buildStarted(org.apache.tools.ant.BuildEvent)
59      */

60     public void buildStarted(BuildEvent event) {
61         logger.info("Ant Started Build: " + event.getMessage());
62     }
63     
64     /* (non-Javadoc)
65      * @see org.apache.tools.ant.BuildListener#messageLogged(org.apache.tools.ant.BuildEvent)
66      */

67     public void messageLogged(BuildEvent event) {
68         logger.info("Ant Message: " + event.getMessage());
69     }
70     
71     /* (non-Javadoc)
72      * @see org.apache.tools.ant.BuildListener#targetFinished(org.apache.tools.ant.BuildEvent)
73      */

74     public void targetFinished(BuildEvent event) {
75         logger.info("Ant Target Finished: " +
76                 event.getTarget().getName());
77     }
78     /* (non-Javadoc)
79      * @see org.apache.tools.ant.BuildListener#targetStarted(org.apache.tools.ant.BuildEvent)
80      */

81     public void targetStarted(BuildEvent event) {
82         logger.info("Ant Target Started: " +
83                 event.getTarget().getName());
84     }
85     
86     /* (non-Javadoc)
87      * @see org.apache.tools.ant.BuildListener#taskFinished(org.apache.tools.ant.BuildEvent)
88      */

89     public void taskFinished(BuildEvent event) {
90         logger.debug("Ant Task Finished: " + event.getTask().getTaskName());
91     }
92     
93     /* (non-Javadoc)
94      * @see org.apache.tools.ant.BuildListener#taskStarted(org.apache.tools.ant.BuildEvent)
95      */

96     public void taskStarted(BuildEvent event) {
97         logger.debug("Ant Task Started: " + event.getTask().getTaskName());
98
99     }
100 }
101
Popular Tags