ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Hatcher" <ehatc...@apache.org>
Subject Re: cvs commit: jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant Vindico.java XMLListener.java
Date Sun, 03 Feb 2002 03:01:39 GMT
Scott,

Would your XMLListener be better at home in Ant's CVS?  Is it a replacement
for XMLLogger (yes, which is inappropriately named - and I'm going to
convert it to an actual BuildLogger soon)?

I just can't help but cringe with code duplication or cut-and-pasting - so
if your XMListener is a plug-in replacement for our XMLLogger then we'd
gladly replace ours and you could use it from Ant's codebase instead.

    Erik

----- Original Message -----
From: <sanders@apache.org>
To: <jakarta-alexandria-cvs@apache.org>
Sent: Saturday, February 02, 2002 9:53 PM
Subject: cvs commit:
jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant
Vindico.java XMLListener.java


> sanders     02/02/02 18:53:01
>
>   Added:       proposal/vindico/src/java/org/apache/alexandria/ant
>                         Vindico.java XMLListener.java
>   Removed:     proposal/vindico/src/java/org/apache/alexandria
Vindico.java
>   Log:
>   Created a faster XMLListener than the DOM based one
>   in Ant.
>
>   Revision  Changes    Path
>   1.1
jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant/Vindi
co.java
>
>   Index: Vindico.java
>   ===================================================================
>   /*
>    * $Header:
/home/cvs/jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria
/ant/Vindico.java,v 1.1 2002/02/03 02:53:01 sanders Exp $
>    * $Revision: 1.1 $
>    * $Date: 2002/02/03 02:53:01 $
>    *
>    * ====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
>    * reserved.
>    *
>    * Redistribution and use in source and binary forms, with or without
>    * modification, are permitted provided that the following conditions
>    * are met:
>    *
>    * 1. Redistributions of source code must retain the above copyright
>    *    notice, this list of conditions and the following disclaimer.
>    *
>    * 2. Redistributions in binary form must reproduce the above copyright
>    *    notice, this list of conditions and the following disclaimer in
>    *    the documentation and/or other materials provided with the
>    *    distribution.
>    *
>    * 3. The end-user documentation included with the redistribution, if
>    *    any, must include the following acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
itself,
>    *    if and wherever such third-party acknowlegements normally appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", and "Apache Software
>    *    Foundation" must not be used to endorse or promote products
derived
>    *    from this software without prior written permission. For written
>    *    permission, please contact apache@apache.org.
>    *
>    * 5. Products derived from this software may not be called "Apache"
>    *    nor may "Apache" appear in their names without prior written
>    *    permission of the Apache Group.
>    *
>    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>    * SUCH DAMAGE.
>    * ====================================================================
>    *
>    * This software consists of voluntary contributions made by many
>    * individuals on behalf of the Apache Software Foundation.  For more
>    * information on the Apache Software Foundation, please see
>    * <http://www.apache.org/>.
>    *
>    */
>   package org.apache.alexandria.ant;
>
>
>   import org.apache.alexandria.exc.VindicoException;
>   import org.apache.alexandria.om.Workspace;
>   import org.apache.alexandria.om.WorkspaceLoader;
>   import org.apache.tools.ant.BuildException;
>   import org.apache.tools.ant.Task;
>
>
>   /**
>    * Vindico provides ...
>    *
>    * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
>    * @version $Revision: 1.1 $ $Date: 2002/02/03 02:53:01 $
>    */
>   public class Vindico extends Task {
>
>       private String workspace;
>
>       public String getWorkspace() {
>           return workspace;
>       }
>
>       public void setWorkspace(String workspace) {
>           this.workspace = workspace;
>       }
>
>       public void execute() throws BuildException {
>           Workspace space = new Workspace();
>           space = WorkspaceLoader.loadWorkspace(space, workspace);
>           String basedir = space.getBasedir();
>           this.getProject().setProperty("vindico.basedir", basedir);
>           try {
>               space.execute();
>           } catch (VindicoException ve) {
>               throw new BuildException(ve.getMessage(), ve);
>           }
>       }
>   }
>
>
>
>   1.1
jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant/XMLLi
stener.java
>
>   Index: XMLListener.java
>   ===================================================================
>   /*
>    * $Header:
/home/cvs/jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria
/ant/XMLListener.java,v 1.1 2002/02/03 02:53:01 sanders Exp $
>    * $Revision: 1.1 $
>    * $Date: 2002/02/03 02:53:01 $
>    *
>    * ====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
>    * reserved.
>    *
>    * Redistribution and use in source and binary forms, with or without
>    * modification, are permitted provided that the following conditions
>    * are met:
>    *
>    * 1. Redistributions of source code must retain the above copyright
>    *    notice, this list of conditions and the following disclaimer.
>    *
>    * 2. Redistributions in binary form must reproduce the above copyright
>    *    notice, this list of conditions and the following disclaimer in
>    *    the documentation and/or other materials provided with the
>    *    distribution.
>    *
>    * 3. The end-user documentation included with the redistribution, if
>    *    any, must include the following acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
itself,
>    *    if and wherever such third-party acknowlegements normally appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", and "Apache Software
>    *    Foundation" must not be used to endorse or promote products
derived
>    *    from this software without prior written permission. For written
>    *    permission, please contact apache@apache.org.
>    *
>    * 5. Products derived from this software may not be called "Apache"
>    *    nor may "Apache" appear in their names without prior written
>    *    permission of the Apache Group.
>    *
>    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>    * SUCH DAMAGE.
>    * ====================================================================
>    *
>    * This software consists of voluntary contributions made by many
>    * individuals on behalf of the Apache Software Foundation.  For more
>    * information on the Apache Software Foundation, please see
>    * <http://www.apache.org/>.
>    *
>    */
>   package org.apache.alexandria.ant;
>
>
>   import java.io.FileWriter;
>   import java.io.StringWriter;
>   import java.io.PrintWriter;
>   import java.text.ChoiceFormat;
>   import java.text.MessageFormat;
>   import java.text.SimpleDateFormat;
>   import java.util.Date;
>
>   import org.apache.alexandria.util.XMLHelper;
>   import org.apache.tools.ant.BuildEvent;
>   import org.apache.tools.ant.BuildListener;
>
>
>   /**
>    * XMLListener provides ...
>    *
>    * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
>    * @version $Revision: 1.1 $ $Date: 2002/02/03 02:53:01 $
>    */
>   public class XMLListener implements BuildListener {
>
>       private XMLHelper helper;
>       private FileWriter writer;
>       private long startTime;
>
>
>       private static String[] priorities = new String[]{"ERROR", "WARN",
"INFO", "VERBOSE", "DEBUG"};
>
>       /**
>        * Code borrowed from Ant's DefaultLogger since it was private
>        */
>       private final static MessageFormat MINUTE_SECONDS =
>               new MessageFormat("Total time: {0}{1}.");
>
>       private final static double[] LIMITS = {0, 1, 2};
>
>       private final static String[] MINUTES_PART =
>               {"", "1 minute, ", "{0,number} minutes, "};
>
>       private final static String[] SECONDS_PART =
>               {"no seconds", "1 second", "{1,number} seconds"};
>
>       private final static ChoiceFormat MINUTES_FORMAT =
>               new ChoiceFormat(LIMITS, MINUTES_PART);
>
>       private final static ChoiceFormat SECONDS_FORMAT =
>               new ChoiceFormat(LIMITS, SECONDS_PART);
>
>       static {
>           MINUTE_SECONDS.setFormat(0, MINUTES_FORMAT);
>           MINUTE_SECONDS.setFormat(1, SECONDS_FORMAT);
>       }
>
>       private final static SimpleDateFormat TIME_FORMAT =
>               new SimpleDateFormat("HH:mm");
>
>       /**
>        * Code borrowed from Ant's DefaultLogger since it was protected
>        */
>       protected static String formatTime(long millis) {
>           long seconds = millis / 1000;
>           long minutes = seconds / 60;
>
>           Object[] args = {
>               new Long(minutes),
>               new Long(seconds % 60)
>           };
>
>           return MINUTE_SECONDS.format(args);
>       }
>
>       /**
>        * Taken from Ant's StringUtils.
>        */
>       public static String getStackTrace(Throwable t) {
>           StringWriter sw = new StringWriter();
>           PrintWriter pw = new PrintWriter(sw, true);
>           t.printStackTrace(pw);
>           pw.flush();
>           pw.close();
>           return sw.toString();
>       }
>
>
>       public void buildStarted(BuildEvent event) {
>           startTime = System.currentTimeMillis();
>           writer = new
FileWriter(event.getProject().getProperty("vindico.log.file"));
>           helper = new XMLHelper(writer);
>           helper.element("ant-build");
>       }
>
>       public void buildFinished(BuildEvent event) {
>           long endTime = System.currentTimeMillis();
>           long totalTime = endTime - startTime;
>           helper.attribute("start-time", TIME_FORMAT.format(new
Date(startTime)));
>           helper.attribute("end-time", TIME_FORMAT.format(new
Date(endTime)));
>           helper.attribute("total-time", formatTime(startTime));
>           helper.element("build-stats", true);
>
>           if (event.getException() != null) {
>               helper.attribute("exception",
event.getException().toString());
>               helper.element("build-error");
>
>               Throwable t = event.getException();
>               helper.element("stack-trace", getStackTrace(t), true);
>
>               helper.popElement();
>           }
>
>           helper.popElement(); //root element
>           writer.close();
>       }
>
>       public void targetStarted(BuildEvent event) {
>           helper.attribute("name", event.getTarget().getName());
>           helper.element("target");
>       }
>
>       public void targetFinished(BuildEvent event) {
>           helper.popElement();
>       }
>
>       public void taskStarted(BuildEvent event) {
>           helper.attribute("name", event.getTask().getTaskName());
>           //FIXME - Should we add the Ant Location info here?
>           helper.element("task");
>       }
>
>       public void taskFinished(BuildEvent event) {
>           helper.popElement();
>       }
>
>       public void messageLogged(BuildEvent event) {
>           helper.attribute("priority", priorities[event.getPriority()]);
>           helper.element("message", event.getMessage(), true);
>       }
>   }
>
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:alexandria-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:alexandria-dev-help@jakarta.apache.org>
>
>


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


Mime
View raw message