[MNG-3511] Improve output when no goal is specified.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@674904 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2008-07-08 18:07:50 +00:00
parent cf01846d8d
commit 9cef694f17
3 changed files with 53 additions and 14 deletions

View File

@ -41,6 +41,7 @@ public final class CoreErrorTips
{
private static final List NO_GOALS_TIPS = Arrays.asList( new String[] {
"Introduction to the Build Lifecycle", "\t(http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html)",
"Maven in 5 Minutes guide (http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html)",
"Maven User's documentation (http://maven.apache.org/users/)",
"Maven Plugins page (http://maven.apache.org/plugins/)",

View File

@ -86,25 +86,39 @@ public class DefaultCoreErrorReporter
StringWriter writer = new StringWriter();
writer.write( NEWLINE );
writer.write( "You have not specified any goals or lifecycle phases for Maven to execute." );
writer.write( NEWLINE );
writer.write( "You must specify at least one goal or lifecycle phase to perform build steps." );
writer.write( NEWLINE );
writer.write( "The following list illustrates some commonly used build commands:" );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( "Either specify a goal or lifecycle phase on the command line" );
writer.write( " mvn clean" );
writer.write( NEWLINE );
writer.write( "(you may want to try \'package\' to get started), or configure the " );
writer.write( " Deletes any build output (e.g. class files or JARs)." );
writer.write( NEWLINE );
writer.write( "<defaultGoal/> element in the build section of your project POM." );
writer.write( " mvn test" );
writer.write( NEWLINE );
writer.write( " Runs the unit tests for the project." );
writer.write( NEWLINE );
writer.write( " mvn install" );
writer.write( NEWLINE );
writer.write( " Copies the project artifacts into your local repository." );
writer.write( NEWLINE );
writer.write( " mvn deploy" );
writer.write( NEWLINE );
writer.write( " Copies the project artifacts into the remote repository." );
writer.write( NEWLINE );
writer.write( " mvn site" );
writer.write( NEWLINE );
writer.write( " Creates project documentation (e.g. reports or Javadoc)." );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( "NOTE: You can also chain multiple goals/phases together, as in the following example:" );
writer.write( NEWLINE );
writer.write( "mvn clean package" );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( NEWLINE );
addTips( CoreErrorTips.getNoGoalsTips(), writer );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( "Use \"mvn -?\" to show general usage information about Maven's command line." );
writer.write( NEWLINE );
writer.write( NEWLINE );
registerBuildError( error, writer.toString() );
}
@ -116,7 +130,7 @@ public class DefaultCoreErrorReporter
{
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( "Some tips:" );
writer.write( "Please see:" );
for ( Iterator it = tips.iterator(); it.hasNext(); )
{
String tip = (String) it.next();
@ -125,6 +139,9 @@ public class DefaultCoreErrorReporter
writer.write( "\t- " );
writer.write( tip );
}
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( "for more information." );
}
}

View File

@ -125,7 +125,27 @@ public class DefaultLifecycleExecutor
if ( ( goals == null ) || goals.isEmpty() )
{
throw new NoGoalsSpecifiedException( "\n\nYou must specify at least one goal. Try 'install' to build or mvn -? for other options.\n See http://maven.apache.org for more information.\n\n" );
StringBuffer buffer = new StringBuffer( 1024 );
buffer.append( "\n\n" );
buffer.append( "You must specify at least one goal or lifecycle phase to perform build steps.\n" );
buffer.append( "The following list illustrates some commonly used build commands:\n\n" );
buffer.append( " mvn clean\n" );
buffer.append( " Deletes any build output (e.g. class files or JARs).\n" );
buffer.append( " mvn test\n" );
buffer.append( " Runs the unit tests for the project.\n" );
buffer.append( " mvn install\n" );
buffer.append( " Copies the project artifacts into your local repository.\n" );
buffer.append( " mvn deploy\n" );
buffer.append( " Copies the project artifacts into the remote repository.\n" );
buffer.append( " mvn site\n" );
buffer.append( " Creates project documentation (e.g. reports or Javadoc).\n\n" );
buffer.append( "Please see\n" );
buffer.append( "http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html\n" );
buffer.append( "for a complete description of available lifecycle phases.\n\n" );
buffer.append( "Use \"mvn -?\" to show general usage information about Maven's command line.\n\n" );
throw new NoGoalsSpecifiedException( buffer.toString() );
}
List taskSegments = segmentTaskListByAggregationNeeds(
@ -889,6 +909,7 @@ public class DefaultLifecycleExecutor
this.aggregate = aggregate;
}
@Override
public String toString()
{
StringBuffer message = new StringBuffer();