ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1032931 - /ant/core/trunk/src/main/org/apache/tools/ant/Main.java
Date Tue, 09 Nov 2010 11:35:57 GMT
Author: hibou
Date: Tue Nov  9 11:35:56 2010
New Revision: 1032931

URL: http://svn.apache.org/viewvc?rev=1032931&view=rev
Log:
If there is -d, debug mode, make the -p, project help, print the dependencies of the targets
This will help debugging extension points

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/Main.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/Main.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/Main.java?rev=1032931&r1=1032930&r2=1032931&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/Main.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/Main.java Tue Nov  9 11:35:56 2010
@@ -795,7 +795,8 @@ public class Main implements AntMain {
 
                 if (projectHelp) {
                     printDescription(project);
-                    printTargets(project, msgOutputLevel > Project.MSG_INFO);
+                    printTargets(project, msgOutputLevel > Project.MSG_INFO,
+                            msgOutputLevel > Project.MSG_VERBOSE);
                     return;
                 }
 
@@ -1080,7 +1081,8 @@ public class Main implements AntMain {
      * @param printSubTargets Whether or not subtarget names should also be
      *                        printed.
      */
-    private static void printTargets(Project project, boolean printSubTargets) {
+    private static void printTargets(Project project, boolean printSubTargets,
+            boolean printDependencies) {
         // find the target with the longest name
         int maxLength = 0;
         Map ptargets = removeDuplicateTargets(project.getTargets());
@@ -1091,7 +1093,9 @@ public class Main implements AntMain {
         // on the presence of a description
         Vector topNames = new Vector();
         Vector topDescriptions = new Vector();
+        Vector/*<Enumeration<String>>*/ topDependencies = new Vector();
         Vector subNames = new Vector();
+        Vector/*<Enumeration<String>>*/ subDependencies = new Vector();
 
         for (Iterator i = ptargets.values().iterator(); i.hasNext();) {
             currentTarget = (Target) i.next();
@@ -1104,6 +1108,9 @@ public class Main implements AntMain {
             if (targetDescription == null) {
                 int pos = findTargetPosition(subNames, targetName);
                 subNames.insertElementAt(targetName, pos);
+                if (printDependencies) {
+                    subDependencies.insertElementAt(currentTarget.getDependencies(), pos);
+                }
             } else {
                 int pos = findTargetPosition(topNames, targetName);
                 topNames.insertElementAt(targetName, pos);
@@ -1111,18 +1118,21 @@ public class Main implements AntMain {
                 if (targetName.length() > maxLength) {
                     maxLength = targetName.length();
                 }
+                if (printDependencies) {
+                    topDependencies.insertElementAt(currentTarget.getDependencies(), pos);
+                }
             }
         }
 
-        printTargets(project, topNames, topDescriptions, "Main targets:",
-                     maxLength);
+        printTargets(project, topNames, topDescriptions, topDependencies,
+                "Main targets:", maxLength);
         //if there were no main targets, we list all subtargets
         //as it means nothing has a description
         if (topNames.size() == 0) {
             printSubTargets = true;
         }
         if (printSubTargets) {
-            printTargets(project, subNames, null, "Other targets:", 0);
+            printTargets(project, subNames, null, subDependencies, "Other targets:", 0);
         }
 
         String defaultTarget = project.getDefaultTarget();
@@ -1165,6 +1175,9 @@ public class Main implements AntMain {
      *                     no descriptions are displayed.
      *                     If non-<code>null</code>, this should have
      *                     as many elements as <code>names</code>.
+     * @param topDependencies The list of dependencies for each target.
+     *                        The dependencies are listed as a non null
+     *                        enumeration of String.
      * @param heading The heading to display.
      *                Should not be <code>null</code>.
      * @param maxlen The maximum length of the names of the targets.
@@ -1173,7 +1186,8 @@ public class Main implements AntMain {
      *               <i>are</i> shorter than this).
      */
     private static void printTargets(Project project, Vector names,
-                                     Vector descriptions, String heading,
+                                     Vector descriptions, Vector dependencies,
+                                     String heading,
                                      int maxlen) {
         // now, start printing the targets and their descriptions
         String lSep = System.getProperty("line.separator");
@@ -1193,6 +1207,19 @@ public class Main implements AntMain {
                 msg.append(descriptions.elementAt(i));
             }
             msg.append(lSep);
+            if (!dependencies.isEmpty()) {
+                Enumeration deps = (Enumeration) dependencies.elementAt(i);
+                if (deps.hasMoreElements()) {
+                    msg.append("   depends of: ");
+                    while (deps.hasMoreElements()) {
+                        msg.append(deps.nextElement());
+                        if (deps.hasMoreElements()) {
+                            msg.append(", ");
+                        }
+                    }
+                    msg.append(lSep);                
+                }
+            }
         }
         project.log(msg.toString(), Project.MSG_WARN);
     }



Mime
View raw message