You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/01/25 13:36:21 UTC

svn commit: r737507 - /maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/post-build-script.apt.vm

Author: bentmann
Date: Sun Jan 25 12:36:20 2009
New Revision: 737507

URL: http://svn.apache.org/viewvc?rev=737507&view=rev
Log:
o Simplified example hook script (The Invoker Plugin automatically logs the exception stack trace. Besides, throwing an exception has the additional benefit of transporting the error message/condition to the summary output on the console)

Modified:
    maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/post-build-script.apt.vm

Modified: maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/post-build-script.apt.vm
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/post-build-script.apt.vm?rev=737507&r1=737506&r2=737507&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/post-build-script.apt.vm (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/post-build-script.apt.vm Sun Jan 25 12:36:20 2009
@@ -66,7 +66,7 @@
 -------------------
 
   Here is an example post build BeanShell script (<<<verify.bsh>>>) that checks for the existence of a JAR file after
-  the build has run.  If the JAR file does not exist, the script returns <<<false>>> which causes the Invoker Plugin to
+  the build has run.  If the JAR file does not exist, the script throws an exception which causes the Invoker Plugin to
   log that the build failed. More precisely, any return value which does not equal <<<true>>> will be interpreted as a
   failure condition. And of course, if the script exists abnormally due to an exception, the plugin will flag the
   corresponding build as a failure, too.
@@ -74,19 +74,10 @@
 -------------------
 import java.io.*;
 
-try
+File file = new File( basedir, "target/my-test-project-1.0-SNAPSHOT.jar" );
+if ( !file.isFile() )
 {
-    File file = new File( basedir, "target/my-test-project-1.0-SNAPSHOT.jar" );
-    if ( !file.isFile() )
-    {
-        System.err.println( "Could not find generated JAR: " + file );
-        return false;
-    }
-}
-catch( Throwable t )
-{
-    t.printStackTrace();
-    return false;
+    throw new FileNotFoundException( "Could not find generated JAR: " + file );
 }
 
 return true;