Author: brianf
Date: Mon Jun 11 19:50:52 2007
New Revision: 546361

URL: http://svn.apache.org/viewvc?view=rev&rev=546361
Log:
MENFORCER-6: added message params to standard rules

Modified:
    maven/plugins/trunk/maven-enforcer-plugin/pom.xml
    maven/plugins/trunk/maven-enforcer-plugin/src/it/pom.xml
    
maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/AbstractVersionEnforcer.java
    
maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/EnforceMojo.java
    
maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/RequireOS.java
    
maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireJavaVersion.apt
    
maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireMavenVersion.apt
    maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireOS.apt
    
maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireProperty.apt

Modified: maven/plugins/trunk/maven-enforcer-plugin/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-enforcer-plugin/pom.xml?view=diff&rev=546361&r1=546360&r2=546361
==============================================================================
--- maven/plugins/trunk/maven-enforcer-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-enforcer-plugin/pom.xml Mon Jun 11 19:50:52 2007
@@ -57,7 +57,7 @@
                        <plugin>
                                <groupId>org.codehaus.mojo</groupId>
                                <artifactId>cobertura-maven-plugin</artifactId>
-                               <version>2.1</version>
+                               <version>2.0</version>
                                <executions>
                                        <execution>
                                                <phase>clean</phase>

Modified: maven/plugins/trunk/maven-enforcer-plugin/src/it/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-enforcer-plugin/src/it/pom.xml?view=diff&rev=546361&r1=546360&r2=546361
==============================================================================
--- maven/plugins/trunk/maven-enforcer-plugin/src/it/pom.xml (original)
+++ maven/plugins/trunk/maven-enforcer-plugin/src/it/pom.xml Mon Jun 11 
19:50:52 2007
@@ -25,7 +25,8 @@
                                                                        
<version>[1.3,1.6]</version>
                                                                
</requireJavaVersion>
                                                                
<requireMavenVersion>
-                                                                       
<version>2.0.6</version>
+                                                                       
<version>2.0.8</version>
+                                                                       
<message>You need 2.0.8!</message>
                                                                
</requireMavenVersion>
                                                                
<!--<myCustomRule implementation="org.apache.maven.shared.rule.myCustomRule">
                                                                        
<shouldIfail>false</shouldIfail>

Modified: 
maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/AbstractVersionEnforcer.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/AbstractVersionEnforcer.java?view=diff&rev=546361&r1=546360&r2=546361
==============================================================================
--- 
maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/AbstractVersionEnforcer.java
 (original)
+++ 
maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/AbstractVersionEnforcer.java
 Mon Jun 11 19:50:52 2007
@@ -54,7 +54,12 @@
      * @required
      */
     public String version = null;
-
+    
+    /**
+     * Specify an optional message to the user if the rule fails.
+     */
+    public String message = "";
+    
     /**
      * Compares the specified version to see if it is allowed by the defined
      * version range.
@@ -100,9 +105,12 @@
                     }
                     else
                     {
-                        String error = msg + " is not in the allowed range " + 
vr + ".";
+                        if (StringUtils.isEmpty( message ))
+                        {
+                            message = msg + " is not in the allowed range " + 
vr + ".";    
+                        }
 
-                        throw new EnforcerRuleException( error );
+                        throw new EnforcerRuleException( message );
                     }
                 }
                 catch ( InvalidVersionSpecificationException e )

Modified: 
maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/EnforceMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/EnforceMojo.java?view=diff&rev=546361&r1=546360&r2=546361
==============================================================================
--- 
maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/EnforceMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/EnforceMojo.java
 Mon Jun 11 19:50:52 2007
@@ -170,7 +170,7 @@
                     }
                     if ( fail )
                     {
-                        throw new MojoExecutionException( "Some rules have 
failed." );
+                        throw new MojoExecutionException( "Some Enforcer rules 
have failed. Look above for specific messages explaining why the rule failed." 
);
                     }
                 }
             }

Modified: 
maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/RequireOS.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/RequireOS.java?view=diff&rev=546361&r1=546360&r2=546361
==============================================================================
--- 
maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/RequireOS.java
 (original)
+++ 
maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/RequireOS.java
 Mon Jun 11 19:50:52 2007
@@ -36,12 +36,14 @@
 import org.codehaus.plexus.util.StringUtils;
 
 /**
- * This rule checks that the OS is allowed by combinations of family, name,
- * version and cpu architecture. The behavior is exactly the same as the Maven
- * Os profile activation so the same values are allowed here.
+ * This rule checks that the OS is allowed by combinations
+ * of family, name, version and cpu architecture. The
+ * behavior is exactly the same as the Maven Os profile
+ * activation so the same values are allowed here.
  * 
  * @author <a href="mailto:[EMAIL PROTECTED]">Brian Fox</a>
- * @version $Id$
+ * @version $Id: RequireOS.java 524303 2007-03-30 22:59:32Z
+ *          brianf $
  */
 public class RequireOS
     implements EnforcerRule
@@ -81,6 +83,12 @@
     public String arch = null;
 
     /**
+     * Specify an optional message to the user if the rule
+     * fails.
+     */
+    public String message = "";
+
+    /**
      * Display detected OS information.
      */
     public boolean display = false;
@@ -124,12 +132,14 @@
         {
             if ( !isAllowed() )
             {
-                String msg = ( "OS Arch: " + RequireOS.OS_ARCH + " Family: " + 
determineOsFamily() + " Name: "
-                    + RequireOS.OS_NAME + " Version: " + RequireOS.OS_VERSION 
+ " is not allowed by"
-                    + ( arch != null ? " Arch=" + arch : "" ) + ( family != 
null ? " Family=" + family : "" )
-                    + ( name != null ? " Name=" + name : "" ) + ( version != 
null ? " Version=" + version : "" ) );
-
-                throw new EnforcerRuleException( msg );
+                if ( StringUtils.isEmpty( message ) )
+                {
+                    message = ( "OS Arch: " + RequireOS.OS_ARCH + " Family: " 
+ determineOsFamily() + " Name: "
+                        + RequireOS.OS_NAME + " Version: " + 
RequireOS.OS_VERSION + " is not allowed by"
+                        + ( arch != null ? " Arch=" + arch : "" ) + ( family 
!= null ? " Family=" + family : "" )
+                        + ( name != null ? " Name=" + name : "" ) + ( version 
!= null ? " Version=" + version : "" ) );
+                }
+                throw new EnforcerRuleException( message );
             }
         }
         else
@@ -186,8 +196,9 @@
     }
 
     /**
-     * Helper method to determine if the current OS is allowed based on the
-     * injected values for family, name, version and arch.
+     * Helper method to determine if the current OS is
+     * allowed based on the injected values for family,
+     * name, version and arch.
      * 
      * @return true if the version is allowed.
      */
@@ -199,8 +210,8 @@
     }
 
     /**
-     * Helper method to check that at least one of family, name, version or 
arch
-     * is set.
+     * Helper method to check that at least one of family,
+     * name, version or arch is set.
      * 
      * @return true if all parameters are empty.
      */
@@ -212,9 +223,11 @@
     }
 
     /**
-     * Creates a Profile object that contains the activation information
+     * Creates a Profile object that contains the activation
+     * information
      * 
-     * @return a properly populated profile to be used for OS validation.
+     * @return a properly populated profile to be used for
+     *         OS validation.
      */
     private Profile createProfile()
     {
@@ -224,7 +237,8 @@
     }
 
     /**
-     * Creates an Activation object that contains the ActivationOS information.
+     * Creates an Activation object that contains the
+     * ActivationOS information.
      * 
      * @return a properly populated Activation object.
      */
@@ -237,7 +251,8 @@
     }
 
     /**
-     * Creates an ActivationOS object containing family, name, version and 
arch.
+     * Creates an ActivationOS object containing family,
+     * name, version and arch.
      * 
      * @return a properly populated ActivationOS object.
      */
@@ -254,7 +269,8 @@
     }
 
     /**
-     * Helper method to check if the given family is in the following list:
+     * Helper method to check if the given family is in the
+     * following list:
      * <ul>
      * <li>dos</li>
      * <li>mac</li>
@@ -268,11 +284,10 @@
      * <li>os/400</li>
      * </ul>
      * 
-     * Note: '!' is allowed at the beginning of the string and still considered
-     * valid.
+     * Note: '!' is allowed at the beginning of the string
+     * and still considered valid.
      * 
-     * @param theFamily
-     *            the family to check.
+     * @param theFamily the family to check.
      * @return true if one of the valid families.
      */
     public boolean isValidFamily( String theFamily )
@@ -293,8 +308,7 @@
     }
 
     /**
-     * @param theArch
-     *            the arch to set
+     * @param theArch the arch to set
      */
     public void setArch( String theArch )
     {
@@ -310,8 +324,7 @@
     }
 
     /**
-     * @param theFamily
-     *            the family to set
+     * @param theFamily the family to set
      */
     public void setFamily( String theFamily )
     {
@@ -327,8 +340,7 @@
     }
 
     /**
-     * @param theName
-     *            the name to set
+     * @param theName the name to set
      */
     public void setName( String theName )
     {
@@ -344,8 +356,7 @@
     }
 
     /**
-     * @param theVersion
-     *            the version to set
+     * @param theVersion the version to set
      */
     public void setVersion( String theVersion )
     {
@@ -361,8 +372,7 @@
     }
 
     /**
-     * @param theValidFamilies
-     *            the validFamilies to set
+     * @param theValidFamilies the validFamilies to set
      */
     public void setValidFamilies( Set theValidFamilies )
     {

Modified: 
maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireJavaVersion.apt
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireJavaVersion.apt?view=diff&rev=546361&r1=546360&r2=546361
==============================================================================
--- 
maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireJavaVersion.apt
 (original)
+++ 
maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireJavaVersion.apt
 Mon Jun 11 19:50:52 2007
@@ -20,7 +20,7 @@
   ------
   Brian Fox
   ------
-  Mar 2007
+  June 2007
   ------
 
 Require Java Version
@@ -28,6 +28,8 @@
    This rule enforces certain Java JDK versions. The rule uses the 
{{{versionRanges.html}Enforcer version range syntax}} to define allowed 
versions.
 
    The following parameters are supported by this rule:
+   
+   * message - an optional message to the user if the rule fails.
    
    * 
{{{../apidocs/org/apache/maven/plugin/enforcer/AbstractVersionEnforcer.html#version}version}}
 - {{{versionRanges.html}range}} of allowed JDKs.
    

Modified: 
maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireMavenVersion.apt
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireMavenVersion.apt?view=diff&rev=546361&r1=546360&r2=546361
==============================================================================
--- 
maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireMavenVersion.apt
 (original)
+++ 
maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireMavenVersion.apt
 Mon Jun 11 19:50:52 2007
@@ -20,7 +20,7 @@
   ------
   Brian Fox
   ------
-  Mar 2007
+  June 2007
   ------
 
 Require Maven Version
@@ -28,6 +28,8 @@
    This rule enforces certain Maven versions. The rule uses the 
{{{versionRanges.html}Enforcer version range syntax}} to define allowed 
versions.
 
    The following parameters are supported by this rule:
+   
+   * message - an optional message to the user if the rule fails.
    
    * 
{{{../apidocs/org/apache/maven/plugin/enforcer/AbstractVersionEnforcer.html#version}version}}
 - {{{versionRanges.html}range}} of allowed Maven versions.
    

Modified: 
maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireOS.apt
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireOS.apt?view=diff&rev=546361&r1=546360&r2=546361
==============================================================================
--- maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireOS.apt 
(original)
+++ maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireOS.apt 
Mon Jun 11 19:50:52 2007
@@ -20,7 +20,7 @@
   ------
   Brian Fox
   ------
-  Mar 2007
+  June 2007
   ------
 
 Require OS Version
@@ -30,6 +30,8 @@
 
 
    The following parameters are supported by this rule:
+
+   * message - an optional message to the user if the rule fails.
    
    * {{{../apidocs/org/apache/maven/plugin/enforcer/RequireOS.html#arch}arch}} 
- the cpu architecture.
    

Modified: 
maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireProperty.apt
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireProperty.apt?view=diff&rev=546361&r1=546360&r2=546361
==============================================================================
--- 
maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireProperty.apt
 (original)
+++ 
maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/requireProperty.apt
 Mon Jun 11 19:50:52 2007
@@ -20,7 +20,7 @@
   ------
   Brian Fox
   ------
-  Mar 2007
+  June 2007
   ------
 
 Require Property


Reply via email to