ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant Main.java
Date Sat, 15 Sep 2001 04:08:11 GMT
donaldp     01/09/14 21:08:11

  Modified:    src/main/org/apache/tools/ant Main.java
  Log:
  Made the -projecthelp only print out targets that have coresponding descriptions unless
loglevel is verbose or debug.
  
  Don't you hate it when you forget to commit changes?
  
  Revision  Changes    Path
  1.46      +23 -25    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.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- Main.java	2001/08/18 14:59:39	1.45
  +++ Main.java	2001/09/15 04:08:11	1.46
  @@ -403,7 +403,7 @@
   
           final Project project = new Project();
           project.setCoreLoader(coreLoader);
  -        
  +
           Throwable error = null;
   
           try {
  @@ -416,7 +416,10 @@
               try {
                   System.setOut(new PrintStream(new DemuxOutputStream(project, false)));
                   System.setErr(new PrintStream(new DemuxOutputStream(project, true)));
  -                project.fireBuildStarted();
  +
  +                if (!projectHelp) {
  +                    project.fireBuildStarted();
  +                }
                   project.init();
                   project.setUserProperty("ant.version", getAntVersion());
   
  @@ -444,24 +447,24 @@
                   } catch (NullPointerException npe) {
                       throw new BuildException(noParserMessage, npe);
                   }
  +
  +                if (projectHelp) {
  +                    printDescription(project);
  +                    printTargets(project, msgOutputLevel > Project.MSG_INFO );
  +                    return;
  +                }
                   
                   // make sure that we have a target to execute
                   if (targets.size() == 0) {
                       targets.addElement(project.getDefaultTarget());
                   }
                   
  -                if (!projectHelp) {
  -                    project.executeTargets(targets);
  -                }
  +                project.executeTargets(targets);
               }
               finally {
                   System.setOut(out);
                   System.setErr(err);
               }
  -            if (projectHelp) {
  -                printDescription(project);
  -                printTargets(project);
  -            }
           }
           catch(RuntimeException exc) {
               error = exc;
  @@ -472,7 +475,9 @@
               throw err;
           }
           finally {
  -            project.fireBuildFinished(error);
  +            if (!projectHelp) {
  +                project.fireBuildFinished(error);
  +            }
           }
       }
   
  @@ -595,7 +600,7 @@
       /**
        * Print out a list of all targets in the current buildfile
        */
  -    private static void printTargets(Project project) {
  +    private static void printTargets(Project project, boolean printSubTargets) {
           // find the target with the longest name
           int maxLength = 0;
           Enumeration ptargets = project.getTargets().elements();
  @@ -626,23 +631,16 @@
               }
           }
   
  +        printTargets(topNames, topDescriptions, "Main targets:", maxLength);
  +        
  +        if( printSubTargets ) {
  +            printTargets(subNames, null, "Subtargets:", 0);
  +        }
  +
           String defaultTarget = project.getDefaultTarget();
           if (defaultTarget != null && !"".equals(defaultTarget)) { // shouldn't
need to check but...
  -            Vector defaultName = new Vector();
  -            Vector defaultDesc = null;
  -            defaultName.addElement(defaultTarget);
  -
  -            int indexOfDefDesc = topNames.indexOf(defaultTarget);
  -            if (indexOfDefDesc >= 0) {
  -                defaultDesc = new Vector();
  -                defaultDesc.addElement(topDescriptions.elementAt(indexOfDefDesc));
  -            }
  -            printTargets(defaultName, defaultDesc, "Default target:", maxLength);
  -
  +            System.out.println( "Default target: " + defaultTarget );
           }
  -
  -        printTargets(topNames, topDescriptions, "Main targets:", maxLength);
  -        printTargets(subNames, null, "Subtargets:", 0);
       }
   
       /**
  
  
  

Mime
View raw message