org.apache.maven.cli
Class App

java.lang.Object
  extended byorg.apache.maven.cli.App

public class App
extends java.lang.Object

The CLI wrapper for controlling MavenSession processes which are encapsulated in the MavenSession bean.

Version:
$Id: App.java 530196 2007-04-18 23:04:51Z aheritier $
Author:
Jason van Zyl
To Do:
Separate the computation of the available goals from the display of the goals. The goal computation logic needs to be moved out of this class and be placed in MavenSession.java proper., All logging needs to be done via commons-logging. No System.err.* and Jelly needs to be taught to take a logger. In an attempt to isolate everything in MavenSession.java.

Field Summary
static java.lang.String POM_FILE_NAME
          Default file name for an XML-based POM.
 
Constructor Summary
App()
          Constructor.
 
Method Summary
protected  void displayGoals()
          Display helpful information regarding all documented goals.
protected  void displayGoals(boolean pluginOnly, java.lang.String plugin)
          Display helpful information regarding all documented goals.
 void doMain(java.lang.String[] args, java.util.Date fullStart)
          Perform main operations in a non-static method.
protected  void exit(int status)
          To allow subclasses stop the app from exiting
protected  java.lang.String format(java.lang.String orig, int width, char pad)
          Produce a formatted/padded string.
protected static java.lang.String formatTime(long ms)
          Format a time string.
protected  org.apache.commons.cli.CommandLine getCli()
          Get the CLI parser.
 MavenJellyContext getRootContext()
          Retrieve the Jelly rootContext.
 void initialize(java.lang.String[] args)
          Perform initialization.
protected  void initializeRootContext()
          Initialize the IO streams.
 void initializeSystemProperties()
          Setup any system properties that have been specified on the CLI.
static void main(java.lang.String[] args)
          Main CLI entry point for MavenSession.
protected  void printConsoleMavenHeader()
          Prints the MavenSession header.
protected  void setCli(org.apache.commons.cli.CommandLine commandLine)
          Set the cli parser.
 void setRootContext(MavenJellyContext rootContext)
          Set Jelly rootContext.
protected  java.lang.String wrapConsoleMessage(java.lang.String msg, int wrapIndent, int lineWidth)
          Nicely wraps a message for console output, using a word BreakIterator instance to determine wrapping breaks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POM_FILE_NAME

public static final java.lang.String POM_FILE_NAME
Default file name for an XML-based POM.

See Also:
Constant Field Values
Constructor Detail

App

public App()
Constructor.

Method Detail

main

public static void main(java.lang.String[] args)
Main CLI entry point for MavenSession.

Parameters:
args - CLI arguments.

formatTime

protected static java.lang.String formatTime(long ms)
Format a time string.

Parameters:
ms - Duration in ms.
Returns:
String The formatted time string.

doMain

public void doMain(java.lang.String[] args,
                   java.util.Date fullStart)
Perform main operations in a non-static method.

Parameters:
args - Arguments passed in from main().
fullStart - Date the mavenSession process was started.

getRootContext

public MavenJellyContext getRootContext()
Retrieve the Jelly rootContext.

Returns:
The Jelly rootContext.

initialize

public void initialize(java.lang.String[] args)
                throws org.apache.commons.cli.ParseException,
                       java.net.MalformedURLException,
                       java.io.IOException
Perform initialization.

Parameters:
args - The command-line arguments.
Throws:
org.apache.commons.cli.ParseException - If there is an error parsing the command-line.
java.io.IOException - If there is an error while reading the project descriptor.
java.net.MalformedURLException - If any of the the URLs denoting the local or remote repositories is malformed.

initializeSystemProperties

public void initializeSystemProperties()
Setup any system properties that have been specified on the CLI.


setRootContext

public void setRootContext(MavenJellyContext rootContext)
Set Jelly rootContext.

Parameters:
rootContext - The mavenSession jelly rootContext.

displayGoals

protected void displayGoals()
Display helpful information regarding all documented goals.


displayGoals

protected void displayGoals(boolean pluginOnly,
                            java.lang.String plugin)
Display helpful information regarding all documented goals.

Parameters:
pluginOnly - show information for the given plugin only
plugin - plugin to show info for

exit

protected void exit(int status)
To allow subclasses stop the app from exiting

Parameters:
status - the value to exit with

format

protected java.lang.String format(java.lang.String orig,
                                  int width,
                                  char pad)
Produce a formatted/padded string.

Parameters:
orig - The string to format.
width - The width of the resulting formatted string.
pad - The trailing pad character.
Returns:
The formatted string, or the original string if the length is already >= width.

getCli

protected org.apache.commons.cli.CommandLine getCli()
Get the CLI parser.

Returns:
CommandLine The command line parser.

initializeRootContext

protected void initializeRootContext()
                              throws java.io.IOException
Initialize the IO streams.

Throws:
java.io.IOException - on error creating XML output and handling System.err and out

printConsoleMavenHeader

protected void printConsoleMavenHeader()
Prints the MavenSession header.


setCli

protected void setCli(org.apache.commons.cli.CommandLine commandLine)
Set the cli parser.

Parameters:
commandLine - The command line parser.

wrapConsoleMessage

protected java.lang.String wrapConsoleMessage(java.lang.String msg,
                                              int wrapIndent,
                                              int lineWidth)
Nicely wraps a message for console output, using a word BreakIterator instance to determine wrapping breaks.

Parameters:
msg - the string message for the console
wrapIndent - the number of characters to indent all lines after the first one
lineWidth - the console width that determines where to wrap
Returns:
the message wrapped for the console


Copyright © 2001-2008 Apache Software Foundation. All Rights Reserved.