Return-Path: Delivered-To: apmail-maven-m2-dev-archive@www.apache.org Received: (qmail 30669 invoked from network); 30 Sep 2004 15:48:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 30 Sep 2004 15:48:56 -0000 Received: (qmail 28935 invoked by uid 500); 30 Sep 2004 15:48:56 -0000 Delivered-To: apmail-maven-m2-dev-archive@maven.apache.org Received: (qmail 28909 invoked by uid 500); 30 Sep 2004 15:48:56 -0000 Mailing-List: contact m2-dev-help@maven.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: List-Id: "Maven 2 Developers List" Reply-To: "Maven 2 Developers List" Delivered-To: mailing list m2-dev@maven.apache.org Received: (qmail 28893 invoked by uid 500); 30 Sep 2004 15:48:56 -0000 Delivered-To: apmail-maven-components-cvs@apache.org Received: (qmail 28884 invoked by uid 99); 30 Sep 2004 15:48:55 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Thu, 30 Sep 2004 08:48:55 -0700 Received: (qmail 30637 invoked by uid 1162); 30 Sep 2004 15:48:54 -0000 Date: 30 Sep 2004 15:48:54 -0000 Message-ID: <20040930154854.30636.qmail@minotaur.apache.org> From: jvanzyl@apache.org To: maven-components-cvs@apache.org Subject: cvs commit: maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase GoalAttainmentPhase.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N jvanzyl 2004/09/30 08:48:54 Modified: maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase GoalAttainmentPhase.java Log: o perform some minimal validation of the plugin configuration parameters to make sure they are not null when the parameter is required. throw an exception is the parameter that is required is null. Revision Changes Path 1.3 +25 -6 maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase/GoalAttainmentPhase.java Index: GoalAttainmentPhase.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase/GoalAttainmentPhase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- GoalAttainmentPhase.java 30 Sep 2004 15:09:48 -0000 1.2 +++ GoalAttainmentPhase.java 30 Sep 2004 15:48:54 -0000 1.3 @@ -121,17 +121,36 @@ Object value = OgnlProjectValueExtractor.evaluate( expression, context ); - //@todo: mojo parameter validation - // This is the place where parameter validation should be performed. - //if ( value == null && parameter.isRequired() ) - //{ - //} + // ---------------------------------------------------------------------- + // We will perform a basic check here for parameters values that are + // required. Required parameters can't be null so we throw an + // Exception in the case where they are. We probably want some pluggable + // mechanism here but this will catch the most obvious of + // misconfigurations. + // ---------------------------------------------------------------------- + + if ( value == null && parameter.isRequired() ) + { + throw new PluginConfigurationException( createPluginParameterRequiredMessage( goal, parameter ) ); + } map.put( key, value ); } } return map; + } + + private String createPluginParameterRequiredMessage( MojoDescriptor mojo, Parameter parameter ) + { + StringBuffer message = new StringBuffer(); + + message.append( "The " + parameter.getName() ). + append( " is required for the execution of the " ). + append( mojo.getId() ). + append( " mojo and cannot be null." ); + + return message.toString(); } private void releaseComponents( MojoDescriptor goal, PluginExecutionRequest request, MavenGoalExecutionContext context )