dion 2003/08/20 20:40:03
Modified: src/java/org/apache/maven/cli App.java
Log:
- Change System.out to log.info
- Checkstyle fixes
- Minor code changes
Revision Changes Path
1.34 +41 -30 maven/src/java/org/apache/maven/cli/App.java
Index: App.java
===================================================================
RCS file: /home/cvs/maven/src/java/org/apache/maven/cli/App.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- App.java 20 Aug 2003 06:10:28 -0000 1.33
+++ App.java 21 Aug 2003 03:40:03 -0000 1.34
@@ -62,6 +62,8 @@
import org.apache.commons.cli.ParseException;
import org.apache.commons.jelly.JellyException;
import org.apache.commons.jelly.XMLOutput;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.maven.MavenUtils;
import org.apache.maven.MavenSession;
import org.apache.maven.NoGoalException;
@@ -185,7 +187,7 @@
/** Working dir option. */
private static final String WORKING_DIR = "d";
-
+
// ------------------------------------------------------------
// C L A S S M E M B E R S
// ------------------------------------------------------------
@@ -209,8 +211,12 @@
/** MavenSession Jelly rootContext. */
private MavenJellyContext rootContext;
+ /** the session to run builds */
private MavenSession mavenSession;
+ /** logger for output */
+ private Log log = LogFactory.getLog(App.class);
+
/** Constructor. */
public App()
{
@@ -276,7 +282,7 @@
* the local or remote repositories is malformed.
* @throws Exception If any other exceptions occur.
*/
- public void initialize( String[] args )
+ public void initialize( final String[] args )
throws ParseException, IOException, MalformedURLException, Exception
{
setCli( CLIManager.parse( args ) );
@@ -317,7 +323,7 @@
{
descriptorFile = new File( descriptorName );
}
- System.setProperty("user.dir",
descriptorFile.getParentFile().getCanonicalPath());
+ System.setProperty("user.dir",
descriptorFile.getParentFile().getCanonicalPath());
}
else
{
@@ -345,7 +351,7 @@
if ( getCli().hasOption( WORKING_DIR ) )
{
String workingDir = getCli().getOptionValue(WORKING_DIR);
- System.setProperty("user.dir", workingDir);
+ System.setProperty("user.dir", workingDir);
}
// We will assume here that there might not be a project.xml file present
@@ -353,7 +359,7 @@
// the user.dir system property.
MavenJellyContext c = MavenUtils.createContext( new File(
System.getProperty("user.dir") ) );
setRootContext( c );
-
+
if ( getCli().hasOption( DEBUG ) )
{
getRootContext().setXMLOutput( output );
@@ -450,7 +456,7 @@
* @param args Arguments passed in from main().
* @param fullStart Date the mavenSession process was started.
*/
- public void doMain( String[] args, Date fullStart )
+ public void doMain( final String[] args, final Date fullStart )
{
boolean done = false;
int returnCode = RC_OK;
@@ -461,14 +467,14 @@
}
catch ( ParseException e )
{
- System.err.println( e.getLocalizedMessage() );
+ log.info( e.getLocalizedMessage() );
CLIManager.displayHelp();
returnCode = RC_BAD_ARG;
done = true;
}
catch ( IOException e )
{
- System.err.println( e.getLocalizedMessage() );
+ log.info( e.getLocalizedMessage() );
returnCode = RC_INIT_ERROR;
done = true;
}
@@ -481,7 +487,7 @@
if ( done )
{
- System.out.println( "" );
+ log.info( "" );
exit( returnCode );
return;
}
@@ -489,7 +495,7 @@
if ( getCli().hasOption( DISPLAY_HELP ) )
{
CLIManager.displayHelp();
- System.out.println( "" );
+ log.info( "" );
exit( returnCode );
return;
}
@@ -497,7 +503,7 @@
if ( getCli().hasOption( DISPLAY_INFO ) )
{
CLIManager.displayInfo();
- System.out.println( "" );
+ log.info( "" );
exit( returnCode );
return;
}
@@ -505,12 +511,12 @@
if ( getCli().hasOption( DISPLAY_VERSION ) )
{
printConsoleMavenHeader();
- System.out.println( "" );
+ log.info( "" );
exit( returnCode );
return;
}
- if ( getCli().hasOption( CONSOLE_BANNER ) == false )
+ if ( !getCli().hasOption( CONSOLE_BANNER ) )
{
printConsoleMavenHeader();
System.out.println();
@@ -618,10 +624,10 @@
long fullDiff = fullStop.getTime() - fullStart.getTime();
- System.out.println( "Total time: " + formatTime( fullDiff ) );
- System.out.println( "Finished at: " + fullStop );
-
- System.out.println( "" );
+ log.info( "Total time: " + formatTime( fullDiff ) );
+ log.info( "Finished at: " + fullStop );
+
+ log.info( "" );
exit( returnCode );
}
@@ -779,10 +785,10 @@
*/
protected void displayGoals()
{
- System.out.println();
+ log.info("");
String title = "Available [Plugins] / Goals";
- System.out.println( title );
- System.out.println( format( "", title.length(), '`' ) );
+ log.info( title );
+ log.info( format( "", title.length(), '`' ) );
Set goals = mavenSession.getAllGoalNames();
@@ -801,14 +807,15 @@
};
Collections.sort( list, comparator );
- int wrapIndent = 30;
+ int defaultWrapIndent = 30;
+ int wrapIndent = defaultWrapIndent;
String msgPrefix = "";
boolean hasDesc = false;
boolean firstLine = true;
boolean haveGoalsWithNoDescription = false;
String lastPluginName = "";
- for ( Iterator i = list.iterator(); i.hasNext(); )
+ for ( Iterator i = list.iterator(); i.hasNext();)
{
String goalName = (String) i.next(); // goal name
String goalDescription = mavenSession.getGoalDescription( goalName );
@@ -836,7 +843,7 @@
if ( st.hasMoreTokens() )
{
// uh oh we have no default goal defined
- wrapIndent = 30;
+ wrapIndent = defaultWrapIndent;
msgPrefix = " " + st.nextToken() + " ";
if ( msgPrefix.trim().length() == 0 )
{
@@ -891,7 +898,7 @@
{
if ( hasDesc )
{
- wrapIndent = 30; // where the indent begins for all goals
+ wrapIndent = defaultWrapIndent; // where the indent begins for
all goals
// protect against a plugin called "plugin:"
if ( st.hasMoreTokens() )
{
@@ -942,7 +949,7 @@
System.out.println( "Non documented goals : " );
System.out.println();
- for ( Iterator i = list.iterator(); i.hasNext(); )
+ for ( Iterator i = list.iterator(); i.hasNext();)
{
String goalName = (String) i.next();
@@ -1084,8 +1091,10 @@
{
return min + " minutes " + secs + " seconds";
}
-
- return ( min > 0 ? min + " minutes" : " " ) + secs + " seconds";
+ else
+ {
+ return secs + " seconds";
+ }
}
/**
@@ -1093,7 +1102,7 @@
*
* @param args CLI arguments.
*/
- public static void main( String[] args )
+ public static void main( final String[] args )
{
Date start = new Date();
App app = new App();
@@ -1103,8 +1112,10 @@
/**
* To allow subclasses stop the app from exiting
+ * @param status the value to exit with
*/
- protected void exit(int status) {
+ protected void exit(final int status)
+ {
System.exit(status);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]