diff --git a/WHATSNEW b/WHATSNEW
index 62cdff51a..d010bb580 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -35,7 +35,7 @@ behavior has been dropped.
Other changes:
--------------
-* New tasks: antstructure, cab, execon, fail, ftp, genkey, junit, sql, javacc, jjtree, starteam.
+* New tasks: antstructure, cab, execon, fail, ftp, genkey, jlink, junit, sql, javacc, jjtree, starteam.
* New tasks mparse pending documentation.
diff --git a/build.xml b/build.xml
index 8adf90967..6fc425e35 100644
--- a/build.xml
+++ b/build.xml
@@ -131,7 +131,7 @@
-
To more options are -quiet which instructs Ant to print less +
Two more options are -quiet which instructs Ant to print less information on the console when running. The option -verbose on the other hand makes Ant print more information on the console.
-It is also possible to specify the target that should be executed. Default -the target that is mentioned in the default attribute of the project is -used. This can be overridden by adding the target name to the end of the -commandline.
+It is also possible to specify one or more targets that should be executed. When omitted the target that is mentioned in the default attribute of the project is +used.
+The -projecthelp option gives a list of this projects targets. First those with a description and then those without one.
Commandline option summary:
-ant [options] [target] +ant [options] [target [target2 [target3] ...]] Options: -help print this message +-projecthelp print project help information -version print the version information and exit -quiet be extra quiet -verbose be extra verbose +-emacs produce logging information without adornments -logfile <file> use given file for log +-logger <classname> the class which is to perform logging -listener <classname> add an instance of class as a project listener -buildfile <file> use given buildfile -D<property>=<value> use value for given property@@ -302,6 +304,7 @@ href="#tstamp">tstamp tasks in a so called initialization target, on which all other targets depend. Make sure that target is always the first one in the depends list of the other targets. In this manual, most initialization targets have the name "init". +The optional description attribute can be used to provide a one line description of this target that is printed by the -projecthelp commandline option.
A target has the following attributes:
No | ||
description | +a short description of this targets function. | +No | +
A task is a piece of code that can be executed.
diff --git a/src/main/org/apache/tools/ant/Main.java b/src/main/org/apache/tools/ant/Main.java index 03f4a070c..a5ecd68b0 100644 --- a/src/main/org/apache/tools/ant/Main.java +++ b/src/main/org/apache/tools/ant/Main.java @@ -95,7 +95,7 @@ public class Main { /** * The Ant logger class. There may be only one logger. It will have the - * right to use the 'out' PrintStream. The class must implements the BuildLogger + * right to use the 'out' PrintStream. The class must implements the BuildLogger * interface */ private String loggerClassname = null; @@ -114,7 +114,7 @@ public class Main { * Indicates we should only parse and display the project help information */ private boolean projectHelp = false; - + /** * Command line entry point. This method kicks off the building * of a project object and executes a build using either a given @@ -276,7 +276,7 @@ public class Main { try { addBuildListeners(project); project.fireBuildStarted(); - + project.init(); // set user-define properties @@ -355,12 +355,12 @@ public class Main { logger = (BuildLogger)(Class.forName(loggerClassname).newInstance()); } catch (ClassCastException e) { - System.err.println("The specified logger class " + loggerClassname + + System.err.println("The specified logger class " + loggerClassname + " does not implement the BuildLogger interface"); throw new RuntimeException(); } catch (Exception e) { - System.err.println("Unable to instantiate specified logger class " + + System.err.println("Unable to instantiate specified logger class " + loggerClassname + " : " + e.getClass().getName()); throw new RuntimeException(); } @@ -368,12 +368,12 @@ public class Main { else { logger = new DefaultLogger(); } - + logger.setMessageOutputLevel(msgOutputLevel); logger.setOutputPrintStream(out); logger.setErrorPrintStream(err); logger.setEmacsMode(emacsMode); - + return logger; } @@ -383,7 +383,7 @@ public class Main { private static void printUsage() { String lSep = System.getProperty("line.separator"); StringBuffer msg = new StringBuffer(); - msg.append("ant [options] [target]" + lSep); + msg.append("ant [options] [target [target2 [target3] ...]]" + lSep); msg.append("Options: " + lSep); msg.append(" -help print this message" + lSep); msg.append(" -projecthelp print project help information" + lSep); @@ -422,49 +422,78 @@ public class Main { System.err.println("Could not load the version information."); } } - + /** * Print out a list of all targets in the current buildfile */ private static void printTargets(Project project) { - // find the target with the longest name and - // filter out the targets with no description + // find the target with the longest name int maxLength = 0; Enumeration ptargets = project.getTargets().elements(); String targetName; String targetDescription; Target currentTarget; - Vector names = new Vector(); - Vector descriptions = new Vector(); + // split the targets in top-level and sub-targets depending + // on the presence of a description + Vector topNames = new Vector(); + Vector topDescriptions = new Vector(); + Vector subNames = new Vector(); while (ptargets.hasMoreElements()) { currentTarget = (Target)ptargets.nextElement(); targetName = currentTarget.getName(); targetDescription = currentTarget.getDescription(); + // maintain a sorted list of targets if (targetDescription == null) { - targetDescription = ""; - } - - names.addElement(targetName); - descriptions.addElement(targetDescription); + int pos = findTargetPosition(subNames, targetName); + subNames.insertElementAt(targetName, pos); + } else { + int pos = findTargetPosition(topNames, targetName); + topNames.insertElementAt(targetName, pos); + topDescriptions.insertElementAt(targetDescription, pos); if (targetName.length() > maxLength) { maxLength = targetName.length(); } } + } + printTargets(topNames, topDescriptions, "Main targets:", maxLength); + printTargets(subNames, null, "Subtargets:", 0); + } + /** + * Search for the insert position to keep names a sorted list of Strings + */ + private static int findTargetPosition(Vector names, String name) { + int res = names.size(); + for (int i=0; i