Main Page | Class List | File List | Class Members | Related Pages

DoxygenTask.java

00001 // -*- Mode: Java; indent-tabs-mode: nil; c-basic-offset: 4; -*-
00002 /*
00003  * The Apache Software License, Version 1.1
00004  *
00005  * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
00006  * reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  *
00012  * 1. Redistributions of source code must retain the above copyright
00013  *    notice, this list of conditions and the following disclaimer.
00014  *
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in
00017  *    the documentation and/or other materials provided with the
00018  *    distribution.
00019  *
00020  * 3. The end-user documentation included with the redistribution, if
00021  *    any, must include the following acknowlegement:
00022  *       "This product includes software developed by the
00023  *        Apache Software Foundation (http://www.apache.org/)."
00024  *    Alternately, this acknowlegement may appear in the software itself,
00025  *    if and wherever such third-party acknowlegements normally appear.
00026  *
00027  * 4. The names "The Jakarta Project", "Ant", and "Apache Software
00028  *    Foundation" must not be used to endorse or promote products derived
00029  *    from this software without prior written permission. For written
00030  *    permission, please contact apache@apache.org.
00031  *
00032  * 5. Products derived from this software may not be called "Apache"
00033  *    nor may "Apache" appear in their names without prior written
00034  *    permission of the Apache Group.
00035  *
00036  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00037  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00038  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00039  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
00040  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00041  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00042  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00043  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00044  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00045  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00046  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00047  * SUCH DAMAGE.
00048  * ====================================================================
00049  *
00050  * This software consists of voluntary contributions made by many
00051  * individuals on behalf of the Apache Software Foundation.  For more
00052  * information on the Apache Software Foundation, please see
00053  * <http://www.apache.org/>.
00054  */
00055 //----------------------------------------------------------------------
00056 // $Header: /cvsroot/ant-doxygen/ant_task/src/org/doxygen/tools/DoxygenTask.java,v 1.8.4.8 2004/01/31 01:39:31 akkumar Exp $
00057 //
00058 package org.doxygen.tools;
00059 
00060 import org.apache.tools.ant.BuildException;
00061 import org.apache.tools.ant.Task;
00062 import org.apache.tools.ant.taskdefs.PumpStreamHandler;
00063 import org.apache.tools.ant.taskdefs.Execute;
00064 
00065 import java.util.ArrayList;
00066 import java.util.Enumeration;
00067 import java.util.Iterator;
00068 import java.util.List;
00069 import java.util.Map;
00070 import java.util.Properties;
00071 import java.util.Set;
00072 import java.util.TreeMap;
00073 import java.util.Vector;
00074 
00075 import java.io.BufferedReader;
00076 import java.io.File;
00077 import java.io.FileInputStream;
00078 import java.io.FileOutputStream;
00079 import java.io.IOException;
00080 import java.io.InputStreamReader;
00081 import java.io.PrintStream;
00082 
00110 public class DoxygenTask extends Task {
00111 
00116     public static final String CONFIG_FILE =
00117         System.getProperty("user.home") + File.separator + ".doxytmp";
00118 
00123     private DoxygenConfig conf; 
00124     
00129     private DoxygenProcess proc;
00130     
00131 
00135     private boolean verbose = false;
00136 
00137     
00142     private String versionCompatible = null;
00143     
00149     private String configFilename = null;
00150 
00151     //---------------------------------
00155     public DoxygenTask() {
00156         proc = new DoxygenProcess();
00157         conf = new DoxygenConfig();
00158     }
00159 
00160 
00161     //----------------------------------------------------------------------
00168     public final void execute() throws BuildException {
00169         proc.checkVersion(versionCompatible);
00170         System.out.println("Version check complete");
00171         if (configFilename == null ) {
00172             configFilename = CONFIG_FILE;
00173             proc.createConfig(configFilename);
00174         }
00175         conf.writeDoxygenConfig(configFilename);  // Then we update it.
00176         System.out.println("Created Config file");
00177         proc.executeDoxygenConfig(configFilename);
00178         
00179         // No need to delete the config. file at all. 
00180         //Let it be there for the user to know what was used.
00181     }
00182 
00183     //---------------------------------------------------------
00188     public final void setVersionCompatible(String newVersion) {
00189         versionCompatible = newVersion;
00190     }
00191 
00192 
00197     public final String getVersionCompatible() {
00198         return versionCompatible;
00199     }
00200     
00201     //======================================================================
00202     //          Ant Task related elements and nested elements.
00203     //======================================================================
00204 
00205     //----------------------------------------------------------------------
00217     public final void setVerbose(final boolean attr) { verbose = attr; }
00218 
00219 
00220     //----------------------------------------------------------------------
00238     public final void setConfigFilename(final String attr) {
00239         configFilename = attr;
00240     }
00241 
00242 
00243     //----------------------------------------------------------------------
00255     public final void setDoxygenPath(final String attr) { 
00256         proc.setDoxygenPath(attr); 
00257     }
00258 
00259 
00260     //----------------------------------------------------------------------
00272     public final Property createProperty() {
00273         Property p = new Property();
00274         conf.addNestedAttribute(p);
00275         return p;
00276     }
00277 
00278     //-----------------------------------------------
00283     public final void setConfig(String name, String value) {
00284         Property p = new Property();
00285         p.setName(name);
00286         p.setValue(value);
00287         conf.addNestedAttribute(p);
00288     }
00289 
00290     //-------------------------------------------------
00295     public Map getTaskAttributes() {
00296         return conf.getTaskAttributes();
00297     }
00298     //----------------------------------------------------------------------
00312     public final void activityLog(final boolean terseMessage,
00313                                   final String theMessage) {
00314         if  (theMessage != null) {
00315             if  (terseMessage || verbose) {
00316                 System.out.println(theMessage);
00317             }
00318         }
00319     }
00320 
00321     //----------------------------------------------------------------
00327     public static class Property {
00328 
00330         private String key;
00331 
00333         private String val;
00334 
00335         //------------------------------------------------------------
00342         public final String getName()  { return key; }
00343 
00344 
00345         //------------------------------------------------------------
00353         public final String getValue() { return val; }
00354 
00355 
00356         //------------------------------------------------------------
00364         public final void setName(final String theNewName) { key = theNewName; }
00365 
00366 
00367         //------------------------------------------------------------
00376         public final void setValue(final String theNewValue) {
00377             if  (theNewValue.toLowerCase().equals("true")) {
00378                 val = "YES";
00379             } else if (theNewValue.toLowerCase().equals("false")) {
00380                 val = "NO";
00381             } else { val = theNewValue; }
00382         }
00383 
00384 
00385         //------------------------------------------------------------
00393         public final String toString() {
00394             return "Property=["
00395                 + "key={" + key + "},"
00396                 + "value={" + val + "},"
00397                 + "]";
00398         }
00399     }
00400 }

Generated on Sat Jan 31 02:17:29 2004 for Ant-Doxygen by doxygen 1.3.4