ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sbaill...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant Diagnostics.java Main.java
Date Fri, 28 Jun 2002 23:10:03 GMT
sbailliez    2002/06/28 16:10:03

  Modified:    src/main/org/apache/tools/ant Tag: ANT_15_BRANCH
                        Diagnostics.java Main.java
  Log:
  My sincere apologies to Erik and Steve for officially ruining completely the layout on page
27...
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +78 -44    jakarta-ant/src/main/org/apache/tools/ant/Attic/Diagnostics.java
  
  Index: Diagnostics.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Attic/Diagnostics.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- Diagnostics.java	28 Jun 2002 11:45:23 -0000	1.1.2.3
  +++ Diagnostics.java	28 Jun 2002 23:10:03 -0000	1.1.2.4
  @@ -56,12 +56,13 @@
   import java.io.File;
   import java.io.FilenameFilter;
   import java.io.PrintStream;
  +import java.io.InputStream;
  +import java.io.IOException;
   import java.util.Enumeration;
  +import java.util.Properties;
   import java.lang.reflect.Method;
   import java.lang.reflect.InvocationTargetException;
   
  -import org.apache.tools.ant.util.JavaEnvUtils;
  -
   /**
    * A little diagnostic helper that output some information that may help
    * in support. It should quickly give correct information about the
  @@ -193,31 +194,62 @@
           out.println("-------------------------------------------");
           out.println(" ANT_HOME/lib jar listing");
           out.println("-------------------------------------------");
  -        File[] libs = listLibraries();
  -        for (int i = 0; i < libs.length; i++){
  -            out.println(libs[i].getName()
  -                    + " (" + libs[i].length() + " bytes)");
  -        }
  +        doReportLibraries(out);
  +
  +        out.println();
  +        out.println("-------------------------------------------");
  +        out.println(" Tasks availability");
  +        out.println("-------------------------------------------");
  +        doReportTasksAvailability(out);
   
  -/*
           out.println();
           out.println("-------------------------------------------");
  -        out.println(" Core tasks availability");
  +        out.println(" org.apache.env.Which diagnostics");
           out.println("-------------------------------------------");
  -        Properties props = new Properties();
  -        InputStream is = Main.class.getResourceAsStream("org/apache/tools/ant/taskdefs/default.properties");
  +        doReportWhich(out);
   
           out.println();
           out.println("-------------------------------------------");
  -        out.println(" Optional tasks availability");
  +        out.println(" System properties");
           out.println("-------------------------------------------");
  -*/
  +        doReportSystemProperties(out);
  +
           out.println();
  +    }
  +
  +    /**
  +     * Report a listing of system properties existing in the current vm.
  +     * @param out the stream to print the properties to.
  +     */
  +    private static void doReportSystemProperties(PrintStream out){
  +        for( Enumeration keys = System.getProperties().keys();
  +            keys.hasMoreElements(); ){
  +            String key = (String)keys.nextElement();
  +            out.println(key + " : " + System.getProperty(key));
  +        }
  +    }
  +
  +
  +    /**
  +     * Report the content of ANT_HOME/lib directory
  +     * @param out the stream to print the content to
  +     */
  +    private static void doReportLibraries(PrintStream out){
  +        File[] libs = listLibraries();
  +        for (int i = 0; i < libs.length; i++){
  +            out.println(libs[i].getName()
  +                    + " (" + libs[i].length() + " bytes)");
  +        }
  +    }
  +
  +
  +    /**
  +     * Call org.apache.env.Which if available
  +     * @param out the stream to print the content to.
  +     */
  +    private static void doReportWhich(PrintStream out){
           Throwable error = null;
           try {
  -            out.println("-------------------------------------------");
  -            out.println(" org.apache.env.Which diagnostics");
  -            out.println("-------------------------------------------");
               Class which = Class.forName("org.apache.env.Which");
               Method method = which.getMethod("main", new Class[]{ String[].class });
               method.invoke(null, new Object[]{new String[]{}});
  @@ -234,40 +266,42 @@
               out.println("Error while running org.apache.env.Which");
               error.printStackTrace();
           }
  -
  -        out.println();
  -        out.println("-------------------------------------------");
  -        out.println(" System properties");
  -        out.println("-------------------------------------------");
  -        for( Enumeration keys = System.getProperties().keys();
  -            keys.hasMoreElements(); ){
  -            String key = (String)keys.nextElement();
  -            out.println(key + " : " + System.getProperty(key));
  -        }
  -
  -        out.println();
       }
   
  -/*
  -    private void doReportTasksAvailability(PrintStream out, InputStream in) {
  +    /**
  +     * Create a report about non-available tasks that are defined in the
  +     * mapping but could not be found via lookup. It might generally happen
  +     * because Ant requires multiple libraries to compile and one of them
  +     * was missing when compiling Ant.
  +     * @param out the stream to print the tasks report to
  +     * @param is the stream defining the mapping task name/classname, can be
  +     * <tt>null</tt> for a missing stream (ie mapping).
  +     */
  +    private static void doReportTasksAvailability(PrintStream out){
  +        InputStream is = Main.class.getResourceAsStream("/org/apache/tools/ant/taskdefs/defaults.properties");
           if (is == null) {
               out.println("None available");
           } else {
  -            props.load(is);
  -            for (Enumeration keys = props.keys(); keys.hasMoreElements();){
  -                String key = (String)keys.nextElement();
  -                String classname = props.getProperty(key);
  -                try {
  -                    Class.forName(classname);
  -                    props.remove(key);
  -                } catch (ClassNotFoundException e){
  -                    out.println(classname + " : Not Available");
  +            Properties props = new Properties();
  +            try {
  +                props.load(is);
  +                for (Enumeration keys = props.keys(); keys.hasMoreElements();){
  +                    String key = (String)keys.nextElement();
  +                    String classname = props.getProperty(key);
  +                    try {
  +                        Class.forName(classname);
  +                        props.remove(key);
  +                    } catch (ClassNotFoundException e){
  +                        out.println(key + " : Not Available");
  +                    }
                   }
  +                if (props.size() == 0){
  +                    out.println("All defined tasks are available");
  +                }
  +            } catch (IOException e){
  +                out.println(e.getMessage());
               }
  -            if (props.size() == 0){
  -                out.println("All defined tasks are available");
  -            }          
  -        }      
  -    } */
  +        }
  +    }
   
   }
  
  
  
  1.65.2.6  +2 -0      jakarta-ant/src/main/org/apache/tools/ant/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Main.java,v
  retrieving revision 1.65.2.5
  retrieving revision 1.65.2.6
  diff -u -r1.65.2.5 -r1.65.2.6
  --- Main.java	26 Jun 2002 23:14:31 -0000	1.65.2.5
  +++ Main.java	28 Jun 2002 23:10:03 -0000	1.65.2.6
  @@ -735,6 +735,8 @@
           msg.append("  -help                  print this message" + lSep);
           msg.append("  -projecthelp           print project help information" + lSep);
           msg.append("  -version               print the version information and exit" +
lSep);
  +        msg.append("  -diagnostics           print information that might be helpful to"
+ lSep);
  +        msg.append("                         diagnose or report problems." + lSep);
           msg.append("  -quiet, -q             be extra quiet" + lSep);
           msg.append("  -verbose, -v           be extra verbose" + lSep);
           msg.append("  -debug                 print debugging information" + lSep);
  
  
  

--
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