in src/main/java/org/apache/easyant/core/EasyAntMain.java [487:544]
protected static void printTargets(Project project, boolean printSubTargets) {
// find the target with the longest name
int maxLength = 0;
Map<String, Target> ptargets = ProjectUtils.removeDuplicateTargets(project.getTargets());
String targetName;
String targetDescription;
// split the targets in top-level and sub-targets depending
// on the presence of a description
List<String> topNames = new ArrayList<String>();
List<String> topDescriptions = new ArrayList<String>();
List<String> subNames = new ArrayList<String>();
List<String> highLevelTargets = new ArrayList<String>();
List<String> highLevelTargetsDescriptions = new ArrayList<String>();
for (Target currentTarget : ptargets.values()) {
targetName = currentTarget.getName();
if (targetName.equals("")) {
continue;
}
targetDescription = currentTarget.getDescription();
// maintain a sorted list of targets
if (currentTarget instanceof ExtensionPoint && !currentTarget.getName().contains(":")) {
int pos = findTargetPosition(highLevelTargets, targetName);
highLevelTargets.add(pos, targetName);
highLevelTargetsDescriptions.add(pos, targetDescription);
} else if (targetDescription != null) {
int pos = findTargetPosition(topNames, targetName);
topNames.add(pos, targetName);
topDescriptions.add(pos, targetDescription);
} else {
int pos = findTargetPosition(subNames, targetName);
subNames.add(pos, targetName);
}
if (targetName.length() > maxLength) {
maxLength = targetName.length();
}
}
printTargets(project, highLevelTargets, highLevelTargetsDescriptions, "High level targets:", maxLength);
printTargets(project, topNames, topDescriptions, "Main targets:", maxLength);
// if there were no main targets, we list all subtargets
// as it means nothing has a description
if (topNames.isEmpty()) {
printSubTargets = true;
}
if (printSubTargets) {
printTargets(project, subNames, null, "Other targets:", maxLength);
} else {
project.log("Run easyant with '-v' or '--verbose' option to have the whole list of available targets / extension points");
}
String defaultTarget = project.getDefaultTarget();
if (defaultTarget != null && !"".equals(defaultTarget)) {
// shouldn't need to check but...
project.log("Default target: " + defaultTarget);
}
}