plynch 2002/07/18 17:29:04
Modified: src/java/org/apache/maven/app Maven.java
Log:
o Fixing a bug in displayGoals() that put the start of a plugin at the end of the
previous plugin
o General rework of displayGoals()
Revision Changes Path
1.74 +135 -90 jakarta-turbine-maven/src/java/org/apache/maven/app/Maven.java
Index: Maven.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/app/Maven.java,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- Maven.java 17 Jul 2002 18:17:32 -0000 1.73
+++ Maven.java 19 Jul 2002 00:29:04 -0000 1.74
@@ -442,14 +442,14 @@
{
this.projectVerifier = projectVerifier;
}
-
+
/**
* Get the project verifier.
*/
public ProjectVerifier getProjectVerifier()
{
return projectVerifier;
- }
+ }
/** Retrieve a property.
*
@@ -498,10 +498,10 @@
* reading the project descriptor.
* @throws MalformedURLException If any of the the URLs denoting
* the local or remote repositories is malformed.
- * @throws DescriptorException when there are errors creating the
+ * @throws DescriptorException when there are errors creating the
* descriptor from a file
*/
- public void initializeCore(String[] args) throws
+ public void initializeCore(String[] args) throws
ParseException, IOException, MalformedURLException,Exception
{
@@ -542,7 +542,7 @@
getJellyContext().setVariable( "maven.mode.online",
Boolean.TRUE );
}
- }
+ }
/** Load the maven project descriptor.
*
@@ -600,7 +600,7 @@
this.jellyContext.setVariable("maven.project.buildFile.url",
getProjectBuildFile().toURL());
}
-
+
this.jellyContext.setVariable("projectFileName", getProjectFileName());
}
@@ -640,7 +640,7 @@
/**
* Initialize the IO streams.
- *
+ *
* @throws IOException on error creating XML output and handling System.err
* and out
*/
@@ -690,7 +690,7 @@
/**
* Initialise the jelly script that drives the build
- *
+ *
* @throws Exception when any error occurs
*/
private void initializeDriver() throws Exception
@@ -769,128 +769,172 @@
};
Collections.sort(list, comparator);
- Iterator goalIter = list.iterator();
- Goal eachGoal = null;
-
- String description = null;
-
- boolean hadDesc = false;
- boolean hasBlanks = false;
+ Iterator goalIter = list.iterator();
+ Goal eachGoal = null;
+ int wrapIndent = 30;
String lastPluginName = "";
+ String msgPrefix = "";
+ String goalDescription = null;
+ String goalName = null;
+ String pluginName;
+ boolean hasDesc = false;
+ boolean newPlugin = false;
+ boolean firstLine = true;
+ boolean haveGoalsWithNoDescription = false;
- int wrapIndent;
- String msgPrefix;
- boolean isFirst = true;
while (goalIter.hasNext())
{
- eachGoal = (Goal) goalIter.next();
- description = eachGoal.getDescription();
- String goalName = eachGoal.getName();
-
- String pluginName = "";
- boolean isMain = false;
- boolean newPackage = false;
+ eachGoal = (Goal) goalIter.next(); // goal object
+ goalDescription = eachGoal.getDescription();
+ goalName = eachGoal.getName(); // ex. java:jar
StringTokenizer st = new StringTokenizer(goalName, ":");
- pluginName = st.nextToken();
+ pluginName = st.nextToken(); //ex. java
+ newPlugin = !pluginName.equals(lastPluginName);
- if (pluginName.equals(goalName))
+ /*
+ * prepare the description
+ */
+ if(goalDescription == null)
{
- isMain = true;
- newPackage = true;
+ hasDesc = false;
}
-
- if (!pluginName.equals(lastPluginName))
+ else
{
- newPackage = true;
- lastPluginName = pluginName;
+ goalDescription = goalDescription.trim();
+ hasDesc = goalDescription.length() != 0;
}
- if (description == null)
+
+ if (newPlugin)
{
- hasBlanks = true;
- continue;
- }
+ // starting new section
+ lastPluginName = pluginName;
- hadDesc = true;
+ if(st.hasMoreTokens())
+ {
+ // uh oh we have no default goal defined
+ wrapIndent = 30;
+ msgPrefix = " " + st.nextToken() + " ";
+ if (msgPrefix.trim().length() == 0)
+ {
+ msgPrefix = " ( NO GOAL NAME ) ";
+ }
+ msgPrefix = format(msgPrefix, wrapIndent, '.') + " ";
+ // +1 pad for space on the end
+ wrapIndent++;
+
+ /*
+ * if the goal found for a new plugin is not the default
+ * goal, then we make the plugin description something that
+ * makes clear there is no default goal defined
+ */
+ msgPrefix = pluginName
+ + "] ( NO DEFAULT GOAL )\n"
+ + msgPrefix;
+ }
+ else
+ {
+ // we are dealing with the default goal
+ msgPrefix = pluginName + "]";
- if (isMain && newPackage)
- {
- if (!isFirst)
+ if(hasDesc)
+ {
+ msgPrefix += " : ";
+ wrapIndent = msgPrefix.length();
+ }
+ }
+
+ // the first line of display goals should not start a new line
+ if(firstLine)
{
- System.out.println();
+ msgPrefix = "[" + msgPrefix;
+ firstLine = false;
+ }
+ else
+ {
+ msgPrefix = "\n[" + msgPrefix;
}
- isFirst = false;
- msgPrefix = "[" + pluginName + "] : ";
- // the indent here is dynamic
- wrapIndent = msgPrefix.length();
- }
- else if (isMain)
- {
- wrapIndent = 30;
- msgPrefix = "o " + format(goalName + " ", wrapIndent, '.')
- + " ";
- // add 3 for spaces and 'o' used to pad the message
- wrapIndent += 3;
+ if(hasDesc)
+ {
+ System.out.println(msgPrefix
+ + wrapConsoleMessage(goalDescription, wrapIndent,
+ CONSOLE_WIDTH));
+ }
+ else
+ {
+ System.out.println(msgPrefix + " ( NO DESCRIPTION ) ");
+ }
}
else
{
- if (newPackage)
+ if(hasDesc)
{
- if (isFirst)
+ wrapIndent = 30; // where the indent begins for all goals
+ // protect against a plugin called "plugin:"
+ if(st.hasMoreTokens())
{
- msgPrefix = "[";
- isFirst = false;
+ // not a new plugin so also not the first line of plugin
section
+ // and not a goal with just a plugin name; there must be
nextToken
+ msgPrefix = " " + st.nextToken() + " ";
+ //protect against empty goal names
+ if (msgPrefix.trim().length() == 0)
+ {
+ msgPrefix = " ( NO GOAL ) ";
+ }
+
}
else
{
- msgPrefix = "\n[";
+ msgPrefix = " ( NO GOAL ) ";
}
- msgPrefix += pluginName + "]\n";
+
+ msgPrefix = format(msgPrefix, wrapIndent, '.') + " ";
+ wrapIndent += 1; // for spaces used to pad the prefix
+
+ System.out.println(msgPrefix
+ + wrapConsoleMessage(goalDescription, wrapIndent,
+ CONSOLE_WIDTH));
}
else
{
- msgPrefix = "";
+ haveGoalsWithNoDescription = true;
}
-
- wrapIndent = 30;
- String shortName =
- goalName.substring(pluginName.length() + 1,
- goalName.length());
-
- msgPrefix = msgPrefix + " "
- + format(shortName + " ", wrapIndent, '.')
- + " ";
- // add 3 for spaces used to pad the message
- wrapIndent += 3;
}
-
-
- System.out.println(msgPrefix
- + wrapConsoleMessage(description, wrapIndent, CONSOLE_WIDTH));
}
-
- if (hasBlanks)
+ if (haveGoalsWithNoDescription)
{
System.out.println();
- System.out.println("Non documented goals");
-
+ System.out.println();
+ System.out.println("Non documented goals : ");
+ System.out.println();
goalIter = list.iterator();
while (goalIter.hasNext())
{
eachGoal = (Goal) goalIter.next();
- description = eachGoal.getDescription();
+ goalDescription = eachGoal.getDescription();
+
+ /*
+ * prepare the description
+ */
+ if(goalDescription == null)
+ {
+ hasDesc = false;
+ }
+ else
+ {
+ hasDesc = goalDescription.trim().length() != 0;
+ }
- if (description == null)
+ if (goalDescription == null)
{
System.out.println(" " + eachGoal.getName());
}
}
}
-
}
@@ -1274,9 +1318,9 @@
}
/**
- * Add the specified properties to the
+ * Add the specified properties to the
* {@link #getJellyContext() jelly context}
- *
+ *
* @param props the {@link Properties} to add
*/
private void integrateProps(Properties props)
@@ -1328,7 +1372,7 @@
}
}
}
-
+
/**
* Create project verifier
*/
@@ -1419,9 +1463,9 @@
projectVerifier.setProxyUserName(getProperty("maven.proxy.username"));
projectVerifier.setProxyPassword(getProperty("maven.proxy.password"));
}
-
+
return projectVerifier;
- }
+ }
/**
* Verify a project. Basically make sure the dependencies are
@@ -1446,7 +1490,7 @@
/**
* Prints the Project header to System.out
- *
+ *
* @param mavenProject the project the print
*/
private void printConsoleProjectHeader(Project mavenProject)
@@ -1547,7 +1591,7 @@
{
failed = true;
System.err.println("INTERNAL ERROR");
- System.err.println("Reference made to goal '" + e.getGoal().getName()
+ System.err.println("Reference made to goal '" + e.getGoal().getName()
+ "' which has no definition.");
System.out.println("");
return;
@@ -1702,4 +1746,5 @@
getInstance().doMain(args);
}
}
+
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>