Author: jdcasey
Date: Tue Jul  8 11:07:50 2008
New Revision: 674904

URL: http://svn.apache.org/viewvc?rev=674904&view=rev
Log:
[MNG-3511] Improve output when no goal is specified.

Modified:
    
maven/components/trunk/maven-core/src/main/java/org/apache/maven/errors/CoreErrorTips.java
    
maven/components/trunk/maven-core/src/main/java/org/apache/maven/errors/DefaultCoreErrorReporter.java
    
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java

Modified: 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/errors/CoreErrorTips.java
URL: 
http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/errors/CoreErrorTips.java?rev=674904&r1=674903&r2=674904&view=diff
==============================================================================
--- 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/errors/CoreErrorTips.java
 (original)
+++ 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/errors/CoreErrorTips.java
 Tue Jul  8 11:07:50 2008
@@ -41,6 +41,7 @@
 {
 
     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/)",

Modified: 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/errors/DefaultCoreErrorReporter.java
URL: 
http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/errors/DefaultCoreErrorReporter.java?rev=674904&r1=674903&r2=674904&view=diff
==============================================================================
--- 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/errors/DefaultCoreErrorReporter.java
 (original)
+++ 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/errors/DefaultCoreErrorReporter.java
 Tue Jul  8 11:07:50 2008
@@ -86,25 +86,39 @@
         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( "Either specify a goal or lifecycle phase on the command 
line" );
+        writer.write( "The following list illustrates some commonly used build 
commands:" );
         writer.write( NEWLINE );
-        writer.write( "(you may want to try \'package\' to get started), or 
configure the " );
         writer.write( NEWLINE );
-        writer.write( "<defaultGoal/> element in the build section of your 
project POM." );
+        writer.write( "  mvn clean" );
         writer.write( NEWLINE );
+        writer.write( "    Deletes any build output (e.g. class files or 
JARs)." );
         writer.write( NEWLINE );
+        writer.write( "  mvn test" );
         writer.write( NEWLINE );
-        writer.write( "NOTE: You can also chain multiple goals/phases 
together, as in the following example:" );
+        writer.write( "    Runs the unit tests for the project." );
         writer.write( NEWLINE );
-        writer.write( "mvn clean package" );
+        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 );
-
         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 @@
         {
             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 @@
                 writer.write( "\t- " );
                 writer.write( tip );
             }
+            writer.write( NEWLINE );
+            writer.write( NEWLINE );
+            writer.write( "for more information." );
         }
     }
 

Modified: 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: 
http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=674904&r1=674903&r2=674904&view=diff
==============================================================================
--- 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
 (original)
+++ 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
 Tue Jul  8 11:07:50 2008
@@ -125,7 +125,27 @@
 
         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 @@
             this.aggregate = aggregate;
         }
 
+        @Override
         public String toString()
         {
             StringBuffer message = new StringBuffer();


Reply via email to