You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2008/03/03 00:41:28 UTC

svn commit: r632882 [3/7] - in /maven/enforcer/trunk: ./ enforcer-api/ enforcer-api/src/custom-rule-sample/ enforcer-api/src/custom-rule-sample/src/ enforcer-api/src/custom-rule-sample/src/main/java/org/apache/maven/enforcer/rule/ enforcer-api/src/main...

Propchange: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireFilesDontExist.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireFilesExist.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireFilesExist.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireFilesExist.java (original)
+++ maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireFilesExist.java Sun Mar  2 15:41:23 2008
@@ -1,19 +1,19 @@
-package org.apache.maven.plugins.enforcer;
-
-import java.io.File;
-
-public class RequireFilesExist
-    extends AbstractRequireFiles
-{
-
-    boolean checkFile( File file )
-    {
-        return file.exists();
-    }
-
-    String getErrorMsg()
-    {
-        return "Some required files are missing:\n";
-    }
-
-}
+package org.apache.maven.plugins.enforcer;
+
+import java.io.File;
+
+public class RequireFilesExist
+    extends AbstractRequireFiles
+{
+
+    boolean checkFile( File file )
+    {
+        return file.exists();
+    }
+
+    String getErrorMsg()
+    {
+        return "Some required files are missing:\n";
+    }
+
+}

Propchange: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireFilesExist.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireJavaVersion.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireJavaVersion.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireJavaVersion.java (original)
+++ maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireJavaVersion.java Sun Mar  2 15:41:23 2008
@@ -1,103 +1,103 @@
-package org.apache.maven.plugins.enforcer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.commons.lang.SystemUtils;
-import org.apache.maven.artifact.versioning.ArtifactVersion;
-import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
-import org.apache.maven.enforcer.rule.api.EnforcerRule;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
-import org.apache.maven.plugin.logging.Log;
-import org.codehaus.plexus.util.StringUtils;
-
-/**
- * This rule checks that the Java version is allowed.
- * 
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * @version $Id$
- */
-public class RequireJavaVersion
-    extends AbstractVersionEnforcer
-{
-
-    public void execute( EnforcerRuleHelper helper )
-        throws EnforcerRuleException
-    {
-        String java_version = SystemUtils.JAVA_VERSION_TRIMMED;
-        Log log = helper.getLog();
-
-        log.debug( "Detected Java String: " + java_version );
-        java_version = normalizeJDKVersion( java_version );
-        log.debug( "Normalized Java String: " + java_version );
-
-        ArtifactVersion detectedJdkVersion = new DefaultArtifactVersion( java_version );
-
-        log.debug( "Parsed Version: Major: " + detectedJdkVersion.getMajorVersion() + " Minor: " +
-            detectedJdkVersion.getMinorVersion() + " Incremental: " + detectedJdkVersion.getIncrementalVersion() +
-            " Build: " + detectedJdkVersion.getBuildNumber() + " Qualifier: " + detectedJdkVersion.getQualifier() );
-
-        enforceVersion( helper.getLog(), "JDK", version, detectedJdkVersion );
-    }
-
-    /**
-     * Converts a jdk string from 1.5.0-11b12 to a single 3 digit version like 1.5.0-11
-     * 
-     * @param theJdkVersion to be converted.
-     * @return the converted string.
-     */
-    public static String normalizeJDKVersion( String theJdkVersion )
-    {
-
-        theJdkVersion = theJdkVersion.replaceAll( "_|-", "." );
-        String tokenArray[] = StringUtils.split( theJdkVersion, "." );
-        List tokens = Arrays.asList( tokenArray );
-        StringBuffer buffer = new StringBuffer( theJdkVersion.length() );
-
-        Iterator iter = tokens.iterator();
-        for ( int i = 0; i < tokens.size() && i < 4; i++ )
-        {
-            String section = (String) iter.next();
-            section = section.replaceAll( "[^0-9]", "" );
-
-            if ( StringUtils.isNotEmpty( section ) )
-            {
-                buffer.append( Integer.parseInt( section ) );
-
-                if ( i != 2 )
-                {
-                    buffer.append( '.' );
-                }
-                else
-                {
-                    buffer.append( '-' );
-                }
-            }
-        }
-
-        String version = buffer.toString();
-        version = StringUtils.stripEnd( version, "-" );
-        return StringUtils.stripEnd( version, "." );
-    }
-}
+package org.apache.maven.plugins.enforcer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.lang.SystemUtils;
+import org.apache.maven.artifact.versioning.ArtifactVersion;
+import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
+import org.apache.maven.enforcer.rule.api.EnforcerRule;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+import org.apache.maven.plugin.logging.Log;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * This rule checks that the Java version is allowed.
+ * 
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ * @version $Id$
+ */
+public class RequireJavaVersion
+    extends AbstractVersionEnforcer
+{
+
+    public void execute( EnforcerRuleHelper helper )
+        throws EnforcerRuleException
+    {
+        String java_version = SystemUtils.JAVA_VERSION_TRIMMED;
+        Log log = helper.getLog();
+
+        log.debug( "Detected Java String: " + java_version );
+        java_version = normalizeJDKVersion( java_version );
+        log.debug( "Normalized Java String: " + java_version );
+
+        ArtifactVersion detectedJdkVersion = new DefaultArtifactVersion( java_version );
+
+        log.debug( "Parsed Version: Major: " + detectedJdkVersion.getMajorVersion() + " Minor: " +
+            detectedJdkVersion.getMinorVersion() + " Incremental: " + detectedJdkVersion.getIncrementalVersion() +
+            " Build: " + detectedJdkVersion.getBuildNumber() + " Qualifier: " + detectedJdkVersion.getQualifier() );
+
+        enforceVersion( helper.getLog(), "JDK", version, detectedJdkVersion );
+    }
+
+    /**
+     * Converts a jdk string from 1.5.0-11b12 to a single 3 digit version like 1.5.0-11
+     * 
+     * @param theJdkVersion to be converted.
+     * @return the converted string.
+     */
+    public static String normalizeJDKVersion( String theJdkVersion )
+    {
+
+        theJdkVersion = theJdkVersion.replaceAll( "_|-", "." );
+        String tokenArray[] = StringUtils.split( theJdkVersion, "." );
+        List tokens = Arrays.asList( tokenArray );
+        StringBuffer buffer = new StringBuffer( theJdkVersion.length() );
+
+        Iterator iter = tokens.iterator();
+        for ( int i = 0; i < tokens.size() && i < 4; i++ )
+        {
+            String section = (String) iter.next();
+            section = section.replaceAll( "[^0-9]", "" );
+
+            if ( StringUtils.isNotEmpty( section ) )
+            {
+                buffer.append( Integer.parseInt( section ) );
+
+                if ( i != 2 )
+                {
+                    buffer.append( '.' );
+                }
+                else
+                {
+                    buffer.append( '-' );
+                }
+            }
+        }
+
+        String version = buffer.toString();
+        version = StringUtils.stripEnd( version, "-" );
+        return StringUtils.stripEnd( version, "." );
+    }
+}

Propchange: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireJavaVersion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireMavenVersion.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireMavenVersion.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireMavenVersion.java (original)
+++ maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireMavenVersion.java Sun Mar  2 15:41:23 2008
@@ -1,57 +1,57 @@
-package org.apache.maven.plugins.enforcer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.artifact.versioning.ArtifactVersion;
-import org.apache.maven.enforcer.rule.api.EnforcerRule;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
-import org.apache.maven.execution.RuntimeInformation;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-
-/**
- * This rule checks that the Maven version is allowd.
- * 
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * @version $Id$
- */
-public class RequireMavenVersion
-    extends AbstractVersionEnforcer
-{
-
-    public void execute( EnforcerRuleHelper helper )
-        throws EnforcerRuleException
-    {
-        try
-        {
-            RuntimeInformation rti = (RuntimeInformation) helper.getComponent( RuntimeInformation.class );
-            ArtifactVersion detectedMavenVersion = rti.getApplicationVersion();
-            helper.getLog().debug( "Detected Maven Version: " + detectedMavenVersion );
-            enforceVersion( helper.getLog(), "Maven", this.version, detectedMavenVersion );
-        }
-        catch ( ComponentLookupException e )
-        {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
-
-    }
-
-}
+package org.apache.maven.plugins.enforcer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.artifact.versioning.ArtifactVersion;
+import org.apache.maven.enforcer.rule.api.EnforcerRule;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+import org.apache.maven.execution.RuntimeInformation;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+/**
+ * This rule checks that the Maven version is allowd.
+ * 
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ * @version $Id$
+ */
+public class RequireMavenVersion
+    extends AbstractVersionEnforcer
+{
+
+    public void execute( EnforcerRuleHelper helper )
+        throws EnforcerRuleException
+    {
+        try
+        {
+            RuntimeInformation rti = (RuntimeInformation) helper.getComponent( RuntimeInformation.class );
+            ArtifactVersion detectedMavenVersion = rti.getApplicationVersion();
+            helper.getLog().debug( "Detected Maven Version: " + detectedMavenVersion );
+            enforceVersion( helper.getLog(), "Maven", this.version, detectedMavenVersion );
+        }
+        catch ( ComponentLookupException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+    }
+
+}

Propchange: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireMavenVersion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireNoRepositories.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireNoRepositories.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireNoRepositories.java (original)
+++ maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireNoRepositories.java Sun Mar  2 15:41:23 2008
@@ -1,134 +1,134 @@
-package org.apache.maven.plugins.enforcer;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.enforcer.rule.api.EnforcerRule;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
-import org.apache.maven.model.Model;
-import org.apache.maven.plugins.enforcer.utils.EnforcerRuleUtils;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-
-/**
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- */
-public class RequireNoRepositories
-    extends AbstractStandardEnforcerRule
-{
-
-    public void execute( EnforcerRuleHelper helper )
-        throws EnforcerRuleException
-    {
-        EnforcerRuleUtils utils = new EnforcerRuleUtils( helper );
-
-        MavenProject project;
-        try
-        {
-            project = (MavenProject) helper.evaluate( "${project}" );
-
-            List models =
-                utils.getModelsRecursively( project.getGroupId(), project.getArtifactId(), project.getVersion(),
-                                            new File( project.getBasedir(), "pom.xml" ) );
-
-            List badModels = checkModels( models );
-
-            // if anything was found, log it then append the
-            // optional message.
-            if ( !badModels.isEmpty() )
-            {
-                StringBuffer newMsg = new StringBuffer();
-                newMsg.append( "Some poms have repositories defined:\n" );
-                Iterator iter = badModels.iterator();
-                while ( iter.hasNext() )
-                {
-                    Model model = (Model) iter.next();
-                    newMsg.append( model.getGroupId() + ":" + model.getArtifactId() + " version:" + model.getVersion() +
-                        "\n" );
-                }
-                if ( StringUtils.isNotEmpty( message ) )
-                {
-                    newMsg.append( message );
-                }
-
-                throw new EnforcerRuleException( newMsg.toString() );
-            }
-
-        }
-        catch ( ExpressionEvaluationException e )
-        {
-            throw new EnforcerRuleException( e.getLocalizedMessage() );
-        }
-        catch ( ArtifactResolutionException e )
-        {
-            throw new EnforcerRuleException( e.getLocalizedMessage() );
-        }
-        catch ( ArtifactNotFoundException e )
-        {
-            throw new EnforcerRuleException( e.getLocalizedMessage() );
-        }
-        catch ( IOException e )
-        {
-            throw new EnforcerRuleException( e.getLocalizedMessage() );
-        }
-        catch ( XmlPullParserException e )
-        {
-            throw new EnforcerRuleException( e.getLocalizedMessage() );
-        }
-    }
-
-    private List checkModels( List models )
-    {
-        List badModels = new ArrayList();
-
-        Iterator iter = models.iterator();
-        while ( iter.hasNext() )
-        {
-            Model model = (Model) iter.next();
-            List repos = model.getRepositories();
-            if ( repos != null && !repos.isEmpty() )
-            {
-                badModels.add( model );
-            }
-        }
-        return badModels;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#getCacheId()
-     */
-    public String getCacheId()
-    {
-        return "0";
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isCacheable()
-     */
-    public boolean isCacheable()
-    {
-        return false;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isResultValid(org.apache.maven.enforcer.rule.api.EnforcerRule)
-     */
-    public boolean isResultValid( EnforcerRule theCachedRule )
-    {
-        return false;
-    }
-}
+package org.apache.maven.plugins.enforcer;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.enforcer.rule.api.EnforcerRule;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+import org.apache.maven.model.Model;
+import org.apache.maven.plugins.enforcer.utils.EnforcerRuleUtils;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+/**
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ */
+public class RequireNoRepositories
+    extends AbstractStandardEnforcerRule
+{
+
+    public void execute( EnforcerRuleHelper helper )
+        throws EnforcerRuleException
+    {
+        EnforcerRuleUtils utils = new EnforcerRuleUtils( helper );
+
+        MavenProject project;
+        try
+        {
+            project = (MavenProject) helper.evaluate( "${project}" );
+
+            List models =
+                utils.getModelsRecursively( project.getGroupId(), project.getArtifactId(), project.getVersion(),
+                                            new File( project.getBasedir(), "pom.xml" ) );
+
+            List badModels = checkModels( models );
+
+            // if anything was found, log it then append the
+            // optional message.
+            if ( !badModels.isEmpty() )
+            {
+                StringBuffer newMsg = new StringBuffer();
+                newMsg.append( "Some poms have repositories defined:\n" );
+                Iterator iter = badModels.iterator();
+                while ( iter.hasNext() )
+                {
+                    Model model = (Model) iter.next();
+                    newMsg.append( model.getGroupId() + ":" + model.getArtifactId() + " version:" + model.getVersion() +
+                        "\n" );
+                }
+                if ( StringUtils.isNotEmpty( message ) )
+                {
+                    newMsg.append( message );
+                }
+
+                throw new EnforcerRuleException( newMsg.toString() );
+            }
+
+        }
+        catch ( ExpressionEvaluationException e )
+        {
+            throw new EnforcerRuleException( e.getLocalizedMessage() );
+        }
+        catch ( ArtifactResolutionException e )
+        {
+            throw new EnforcerRuleException( e.getLocalizedMessage() );
+        }
+        catch ( ArtifactNotFoundException e )
+        {
+            throw new EnforcerRuleException( e.getLocalizedMessage() );
+        }
+        catch ( IOException e )
+        {
+            throw new EnforcerRuleException( e.getLocalizedMessage() );
+        }
+        catch ( XmlPullParserException e )
+        {
+            throw new EnforcerRuleException( e.getLocalizedMessage() );
+        }
+    }
+
+    private List checkModels( List models )
+    {
+        List badModels = new ArrayList();
+
+        Iterator iter = models.iterator();
+        while ( iter.hasNext() )
+        {
+            Model model = (Model) iter.next();
+            List repos = model.getRepositories();
+            if ( repos != null && !repos.isEmpty() )
+            {
+                badModels.add( model );
+            }
+        }
+        return badModels;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#getCacheId()
+     */
+    public String getCacheId()
+    {
+        return "0";
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isCacheable()
+     */
+    public boolean isCacheable()
+    {
+        return false;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isResultValid(org.apache.maven.enforcer.rule.api.EnforcerRule)
+     */
+    public boolean isResultValid( EnforcerRule theCachedRule )
+    {
+        return false;
+    }
+}

Propchange: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireNoRepositories.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireOS.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireOS.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireOS.java (original)
+++ maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireOS.java Sun Mar  2 15:41:23 2008
@@ -1,364 +1,364 @@
-package org.apache.maven.plugins.enforcer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Iterator;
-
-import org.apache.maven.model.Activation;
-import org.apache.maven.model.ActivationOS;
-import org.apache.maven.model.Profile;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.profiles.activation.OperatingSystemProfileActivator;
-import org.codehaus.plexus.util.Os;
-import org.codehaus.plexus.util.StringUtils;
-import org.apache.maven.enforcer.rule.api.EnforcerRule;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
-
-/**
- * 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:brianf@apache.org">Brian Fox</a>
- * @version $Id$
- */
-public class RequireOS
-    extends AbstractStandardEnforcerRule
-{
-
-    /**
-     * The OS family type desired<br />
-     * Possible values:<br />
-     * <ul>
-     * <li>dos</li>
-     * <li>mac</li>
-     * <li>netware</li>
-     * <li>os/2</li>
-     * <li>tandem</li>
-     * <li>unix</li>
-     * <li>windows</li>
-     * <li>win9x</li>
-     * <li>z/os</li>
-     * <li>os/400</li>
-     * </ul>
-     */
-    public String family = null;
-
-    /**
-     * Runtime information containing Maven Version.
-     */
-    public String name = null;
-
-    /**
-     * Runtime information containing Maven Version.
-     */
-    public String version = null;
-
-    /**
-     * Runtime information containing Maven Version.
-     */
-    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;
-
-    public RequireOS()
-    {
-
-    }
-
-    public void execute( EnforcerRuleHelper helper )
-        throws EnforcerRuleException
-    {
-
-        displayOSInfo( helper.getLog(), display );
-
-        if ( allParamsEmpty() )
-        {
-            throw new EnforcerRuleException(
-                                             "All parameters can not be empty. You must pick at least one of (family, name, version, arch) or use -Denforcer.os.display=true to see the current OS information." );
-        }
-
-        if ( isValidFamily( this.family ) )
-        {
-            if ( !isAllowed() )
-            {
-                if ( StringUtils.isEmpty( message ) )
-                {
-                    message =
-                        ( "OS Arch: " + Os.OS_ARCH + " Family: " + Os.OS_FAMILY + " Name: " + Os.OS_NAME +
-                            " Version: " + Os.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
-        {
-            StringBuffer buffer = new StringBuffer( 50 );
-            Iterator iter = Os.getValidFamilies().iterator();
-            while ( iter.hasNext() )
-            {
-                buffer.append( iter.next() );
-                buffer.append( ", " );
-            }
-            String help = StringUtils.stripEnd( buffer.toString().trim(), "." );
-            throw new EnforcerRuleException( "Invalid Family type used. Valid family types are: " + help );
-        }
-    }
-
-    /**
-     * Log the current OS information
-     * 
-     * @param log
-     */
-    public void displayOSInfo( Log log, boolean info )
-    {
-        String string =
-            "OS Info: Arch: " + Os.OS_ARCH + " Family: " + Os.OS_FAMILY + " Name: " + Os.OS_NAME + " Version: " +
-                Os.OS_VERSION;
-
-        if ( !info )
-        {
-            log.debug( string );
-        }
-        else
-        {
-            log.info( string );
-        }
-    }
-
-    /**
-     * 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.
-     */
-    public boolean isAllowed()
-    {
-        OperatingSystemProfileActivator activator = new OperatingSystemProfileActivator();
-
-        return activator.isActive( createProfile() );
-    }
-
-    /**
-     * Helper method to check that at least one of family, name, version or arch is set.
-     * 
-     * @return true if all parameters are empty.
-     */
-    public boolean allParamsEmpty()
-    {
-        return ( StringUtils.isEmpty( family ) && StringUtils.isEmpty( arch ) && StringUtils.isEmpty( name ) && StringUtils.isEmpty( version ) );
-
-    }
-
-    /**
-     * Creates a Profile object that contains the activation information
-     * 
-     * @return a properly populated profile to be used for OS validation.
-     */
-    private Profile createProfile()
-    {
-        Profile profile = new Profile();
-        profile.setActivation( createActivation() );
-        return profile;
-    }
-
-    /**
-     * Creates an Activation object that contains the ActivationOS information.
-     * 
-     * @return a properly populated Activation object.
-     */
-    private Activation createActivation()
-    {
-        Activation activation = new Activation();
-        activation.setActiveByDefault( false );
-        activation.setOs( createOsBean() );
-        return activation;
-    }
-
-    /**
-     * Creates an ActivationOS object containing family, name, version and arch.
-     * 
-     * @return a properly populated ActivationOS object.
-     */
-    private ActivationOS createOsBean()
-    {
-        ActivationOS os = new ActivationOS();
-
-        os.setArch( arch );
-        os.setFamily( family );
-        os.setName( name );
-        os.setVersion( version );
-
-        return os;
-    }
-
-    /**
-     * Helper method to check if the given family is in the following list:
-     * <ul>
-     * <li>dos</li>
-     * <li>mac</li>
-     * <li>netware</li>
-     * <li>os/2</li>
-     * <li>tandem</li>
-     * <li>unix</li>
-     * <li>windows</li>
-     * <li>win9x</li>
-     * <li>z/os</li>
-     * <li>os/400</li>
-     * </ul>
-     * Note: '!' is allowed at the beginning of the string and still considered valid.
-     * 
-     * @param theFamily the family to check.
-     * @return true if one of the valid families.
-     */
-    public boolean isValidFamily( String theFamily )
-    {
-
-        // in case they are checking !family
-        theFamily = StringUtils.stripStart( theFamily, "!" );
-
-        return ( StringUtils.isEmpty( theFamily ) || Os.getValidFamilies().contains( theFamily ) );
-    }
-
-    /**
-     * @return the arch
-     */
-    public String getArch()
-    {
-        return this.arch;
-    }
-
-    /**
-     * @param theArch the arch to set
-     */
-    public void setArch( String theArch )
-    {
-        this.arch = theArch;
-    }
-
-    /**
-     * @return the family
-     */
-    public String getFamily()
-    {
-        return this.family;
-    }
-
-    /**
-     * @param theFamily the family to set
-     */
-    public void setFamily( String theFamily )
-    {
-        this.family = theFamily;
-    }
-
-    /**
-     * @return the name
-     */
-    public String getName()
-    {
-        return this.name;
-    }
-
-    /**
-     * @param theName the name to set
-     */
-    public void setName( String theName )
-    {
-        this.name = theName;
-    }
-
-    /**
-     * @return the version
-     */
-    public String getVersion()
-    {
-        return this.version;
-    }
-
-    /**
-     * @param theVersion the version to set
-     */
-    public void setVersion( String theVersion )
-    {
-        this.version = theVersion;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#getCacheId()
-     */
-    public String getCacheId()
-    {
-        // return the hashcodes of all the parameters
-        StringBuffer b = new StringBuffer();
-        if ( StringUtils.isNotEmpty( version ) )
-        {
-            b.append( version.hashCode() );
-        }
-        if ( StringUtils.isNotEmpty( name ) )
-        {
-            b.append( name.hashCode() );
-        }
-        if ( StringUtils.isNotEmpty( arch ) )
-        {
-            b.append( arch.hashCode() );
-        }
-        if ( StringUtils.isNotEmpty( family ) )
-        {
-            b.append( family.hashCode() );
-        }
-        return b.toString();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isCacheable()
-     */
-    public boolean isCacheable()
-    {
-        // the os is not going to change between projects in the same build.
-        return true;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isResultValid(org.apache.maven.enforcer.rule.api.EnforcerRule)
-     */
-    public boolean isResultValid( EnforcerRule theCachedRule )
-    {
-        // i will always return the hash of the parameters as my id. If my parameters are the same, this
-        // rule must always have the same result.
-        return true;
-    }
-}
+package org.apache.maven.plugins.enforcer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Iterator;
+
+import org.apache.maven.model.Activation;
+import org.apache.maven.model.ActivationOS;
+import org.apache.maven.model.Profile;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.profiles.activation.OperatingSystemProfileActivator;
+import org.codehaus.plexus.util.Os;
+import org.codehaus.plexus.util.StringUtils;
+import org.apache.maven.enforcer.rule.api.EnforcerRule;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+
+/**
+ * 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:brianf@apache.org">Brian Fox</a>
+ * @version $Id$
+ */
+public class RequireOS
+    extends AbstractStandardEnforcerRule
+{
+
+    /**
+     * The OS family type desired<br />
+     * Possible values:<br />
+     * <ul>
+     * <li>dos</li>
+     * <li>mac</li>
+     * <li>netware</li>
+     * <li>os/2</li>
+     * <li>tandem</li>
+     * <li>unix</li>
+     * <li>windows</li>
+     * <li>win9x</li>
+     * <li>z/os</li>
+     * <li>os/400</li>
+     * </ul>
+     */
+    public String family = null;
+
+    /**
+     * Runtime information containing Maven Version.
+     */
+    public String name = null;
+
+    /**
+     * Runtime information containing Maven Version.
+     */
+    public String version = null;
+
+    /**
+     * Runtime information containing Maven Version.
+     */
+    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;
+
+    public RequireOS()
+    {
+
+    }
+
+    public void execute( EnforcerRuleHelper helper )
+        throws EnforcerRuleException
+    {
+
+        displayOSInfo( helper.getLog(), display );
+
+        if ( allParamsEmpty() )
+        {
+            throw new EnforcerRuleException(
+                                             "All parameters can not be empty. You must pick at least one of (family, name, version, arch) or use -Denforcer.os.display=true to see the current OS information." );
+        }
+
+        if ( isValidFamily( this.family ) )
+        {
+            if ( !isAllowed() )
+            {
+                if ( StringUtils.isEmpty( message ) )
+                {
+                    message =
+                        ( "OS Arch: " + Os.OS_ARCH + " Family: " + Os.OS_FAMILY + " Name: " + Os.OS_NAME +
+                            " Version: " + Os.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
+        {
+            StringBuffer buffer = new StringBuffer( 50 );
+            Iterator iter = Os.getValidFamilies().iterator();
+            while ( iter.hasNext() )
+            {
+                buffer.append( iter.next() );
+                buffer.append( ", " );
+            }
+            String help = StringUtils.stripEnd( buffer.toString().trim(), "." );
+            throw new EnforcerRuleException( "Invalid Family type used. Valid family types are: " + help );
+        }
+    }
+
+    /**
+     * Log the current OS information
+     * 
+     * @param log
+     */
+    public void displayOSInfo( Log log, boolean info )
+    {
+        String string =
+            "OS Info: Arch: " + Os.OS_ARCH + " Family: " + Os.OS_FAMILY + " Name: " + Os.OS_NAME + " Version: " +
+                Os.OS_VERSION;
+
+        if ( !info )
+        {
+            log.debug( string );
+        }
+        else
+        {
+            log.info( string );
+        }
+    }
+
+    /**
+     * 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.
+     */
+    public boolean isAllowed()
+    {
+        OperatingSystemProfileActivator activator = new OperatingSystemProfileActivator();
+
+        return activator.isActive( createProfile() );
+    }
+
+    /**
+     * Helper method to check that at least one of family, name, version or arch is set.
+     * 
+     * @return true if all parameters are empty.
+     */
+    public boolean allParamsEmpty()
+    {
+        return ( StringUtils.isEmpty( family ) && StringUtils.isEmpty( arch ) && StringUtils.isEmpty( name ) && StringUtils.isEmpty( version ) );
+
+    }
+
+    /**
+     * Creates a Profile object that contains the activation information
+     * 
+     * @return a properly populated profile to be used for OS validation.
+     */
+    private Profile createProfile()
+    {
+        Profile profile = new Profile();
+        profile.setActivation( createActivation() );
+        return profile;
+    }
+
+    /**
+     * Creates an Activation object that contains the ActivationOS information.
+     * 
+     * @return a properly populated Activation object.
+     */
+    private Activation createActivation()
+    {
+        Activation activation = new Activation();
+        activation.setActiveByDefault( false );
+        activation.setOs( createOsBean() );
+        return activation;
+    }
+
+    /**
+     * Creates an ActivationOS object containing family, name, version and arch.
+     * 
+     * @return a properly populated ActivationOS object.
+     */
+    private ActivationOS createOsBean()
+    {
+        ActivationOS os = new ActivationOS();
+
+        os.setArch( arch );
+        os.setFamily( family );
+        os.setName( name );
+        os.setVersion( version );
+
+        return os;
+    }
+
+    /**
+     * Helper method to check if the given family is in the following list:
+     * <ul>
+     * <li>dos</li>
+     * <li>mac</li>
+     * <li>netware</li>
+     * <li>os/2</li>
+     * <li>tandem</li>
+     * <li>unix</li>
+     * <li>windows</li>
+     * <li>win9x</li>
+     * <li>z/os</li>
+     * <li>os/400</li>
+     * </ul>
+     * Note: '!' is allowed at the beginning of the string and still considered valid.
+     * 
+     * @param theFamily the family to check.
+     * @return true if one of the valid families.
+     */
+    public boolean isValidFamily( String theFamily )
+    {
+
+        // in case they are checking !family
+        theFamily = StringUtils.stripStart( theFamily, "!" );
+
+        return ( StringUtils.isEmpty( theFamily ) || Os.getValidFamilies().contains( theFamily ) );
+    }
+
+    /**
+     * @return the arch
+     */
+    public String getArch()
+    {
+        return this.arch;
+    }
+
+    /**
+     * @param theArch the arch to set
+     */
+    public void setArch( String theArch )
+    {
+        this.arch = theArch;
+    }
+
+    /**
+     * @return the family
+     */
+    public String getFamily()
+    {
+        return this.family;
+    }
+
+    /**
+     * @param theFamily the family to set
+     */
+    public void setFamily( String theFamily )
+    {
+        this.family = theFamily;
+    }
+
+    /**
+     * @return the name
+     */
+    public String getName()
+    {
+        return this.name;
+    }
+
+    /**
+     * @param theName the name to set
+     */
+    public void setName( String theName )
+    {
+        this.name = theName;
+    }
+
+    /**
+     * @return the version
+     */
+    public String getVersion()
+    {
+        return this.version;
+    }
+
+    /**
+     * @param theVersion the version to set
+     */
+    public void setVersion( String theVersion )
+    {
+        this.version = theVersion;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#getCacheId()
+     */
+    public String getCacheId()
+    {
+        // return the hashcodes of all the parameters
+        StringBuffer b = new StringBuffer();
+        if ( StringUtils.isNotEmpty( version ) )
+        {
+            b.append( version.hashCode() );
+        }
+        if ( StringUtils.isNotEmpty( name ) )
+        {
+            b.append( name.hashCode() );
+        }
+        if ( StringUtils.isNotEmpty( arch ) )
+        {
+            b.append( arch.hashCode() );
+        }
+        if ( StringUtils.isNotEmpty( family ) )
+        {
+            b.append( family.hashCode() );
+        }
+        return b.toString();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isCacheable()
+     */
+    public boolean isCacheable()
+    {
+        // the os is not going to change between projects in the same build.
+        return true;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isResultValid(org.apache.maven.enforcer.rule.api.EnforcerRule)
+     */
+    public boolean isResultValid( EnforcerRule theCachedRule )
+    {
+        // i will always return the hash of the parameters as my id. If my parameters are the same, this
+        // rule must always have the same result.
+        return true;
+    }
+}

Propchange: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireOS.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireProperty.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireProperty.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireProperty.java (original)
+++ maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireProperty.java Sun Mar  2 15:41:23 2008
@@ -1,139 +1,139 @@
-package org.apache.maven.plugins.enforcer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.enforcer.rule.api.EnforcerRule;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
-import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
-import org.codehaus.plexus.util.StringUtils;
-
-/**
- * This rule checks that certain properties are set.
- * 
- * @author Paul Gier
- */
-public class RequireProperty
-    extends AbstractStandardEnforcerRule
-{
-
-    /**
-     * Specify the required property.
-     * 
-     * @parameter
-     * @required
-     */
-    public String property = null;
-
-    /**
-     * Match the property value to a given regular expresssion. Defaults to null (any value is ok).
-     * 
-     * @parameter
-     */
-    public String regex = null;
-
-    /**
-     * Specify a warning message if the regular expression is not matched.
-     * 
-     * @parameter
-     */
-    public String regexMessage = null;
-
-    /**
-     * Execute the rule.
-     */
-    public void execute( EnforcerRuleHelper helper )
-        throws EnforcerRuleException
-    {
-        Object propValue = null;
-        try
-        {
-            propValue = helper.evaluate( "${" + property + "}" );
-        }
-        catch ( ExpressionEvaluationException eee )
-        {
-            throw new EnforcerRuleException( "Unable to evaluate property: " + property, eee );
-        }
-
-        // Check that the property is not null or empty string
-        if ( propValue == null )
-        {
-            if ( message == null )
-            {
-                message = "Property \"" + property + "\" is required for this build.";
-            }
-            throw new EnforcerRuleException( message );
-        }
-        // If there is a regex, check that the property matches it
-        if ( regex != null && !propValue.toString().matches( regex ) )
-        {
-            if ( regexMessage == null )
-            {
-                regexMessage =
-                    "Property \"" + property + "\" evaluates to \"" + propValue + "\".  " +
-                        "This does not match the regular expression \"" + regex + "\"";
-            }
-            throw new EnforcerRuleException( regexMessage );
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#getCacheId()
-     */
-    public String getCacheId()
-    {
-        // return the hashcodes of all the parameters
-        StringBuffer b = new StringBuffer();
-        if ( StringUtils.isNotEmpty( property ) )
-        {
-            b.append( property.hashCode() );
-        }
-        if ( StringUtils.isNotEmpty( regex ) )
-        {
-            b.append( regex.hashCode() );
-        }
-        return b.toString();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isCacheable()
-     */
-    public boolean isCacheable()
-    {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isResultValid(org.apache.maven.enforcer.rule.api.EnforcerRule)
-     */
-    public boolean isResultValid( EnforcerRule theCachedRule )
-    {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-}
+package org.apache.maven.plugins.enforcer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.enforcer.rule.api.EnforcerRule;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * This rule checks that certain properties are set.
+ * 
+ * @author Paul Gier
+ */
+public class RequireProperty
+    extends AbstractStandardEnforcerRule
+{
+
+    /**
+     * Specify the required property.
+     * 
+     * @parameter
+     * @required
+     */
+    public String property = null;
+
+    /**
+     * Match the property value to a given regular expresssion. Defaults to null (any value is ok).
+     * 
+     * @parameter
+     */
+    public String regex = null;
+
+    /**
+     * Specify a warning message if the regular expression is not matched.
+     * 
+     * @parameter
+     */
+    public String regexMessage = null;
+
+    /**
+     * Execute the rule.
+     */
+    public void execute( EnforcerRuleHelper helper )
+        throws EnforcerRuleException
+    {
+        Object propValue = null;
+        try
+        {
+            propValue = helper.evaluate( "${" + property + "}" );
+        }
+        catch ( ExpressionEvaluationException eee )
+        {
+            throw new EnforcerRuleException( "Unable to evaluate property: " + property, eee );
+        }
+
+        // Check that the property is not null or empty string
+        if ( propValue == null )
+        {
+            if ( message == null )
+            {
+                message = "Property \"" + property + "\" is required for this build.";
+            }
+            throw new EnforcerRuleException( message );
+        }
+        // If there is a regex, check that the property matches it
+        if ( regex != null && !propValue.toString().matches( regex ) )
+        {
+            if ( regexMessage == null )
+            {
+                regexMessage =
+                    "Property \"" + property + "\" evaluates to \"" + propValue + "\".  " +
+                        "This does not match the regular expression \"" + regex + "\"";
+            }
+            throw new EnforcerRuleException( regexMessage );
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#getCacheId()
+     */
+    public String getCacheId()
+    {
+        // return the hashcodes of all the parameters
+        StringBuffer b = new StringBuffer();
+        if ( StringUtils.isNotEmpty( property ) )
+        {
+            b.append( property.hashCode() );
+        }
+        if ( StringUtils.isNotEmpty( regex ) )
+        {
+            b.append( regex.hashCode() );
+        }
+        return b.toString();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isCacheable()
+     */
+    public boolean isCacheable()
+    {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isResultValid(org.apache.maven.enforcer.rule.api.EnforcerRule)
+     */
+    public boolean isResultValid( EnforcerRule theCachedRule )
+    {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+}

Propchange: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireProperty.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseDeps.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseDeps.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseDeps.java (original)
+++ maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseDeps.java Sun Mar  2 15:41:23 2008
@@ -1,65 +1,65 @@
-package org.apache.maven.plugins.enforcer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
-import org.apache.maven.plugin.logging.Log;
-
-/**
- * This rule checks that no snapshots are included.
- * 
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * @version $Id$
- */
-public class RequireReleaseDeps
-    extends AbstractBanDependencies
-{
-
-    /**
-     * Checks the set of dependencies to see if any snapshots are included
-     * 
-     * @param dependencies
-     * @return
-     * @throws EnforcerRuleException
-     */
-    protected Set checkDependencies( Set dependencies, Log log )
-        throws EnforcerRuleException
-    {
-        Set foundExcludes = new HashSet();
-
-        Iterator DependencyIter = dependencies.iterator();
-        while ( DependencyIter.hasNext() )
-        {
-            Artifact artifact = (Artifact) DependencyIter.next();
-
-            if ( artifact.isSnapshot() )
-            {
-                foundExcludes.add( artifact );
-            }
-        }
-
-        return foundExcludes;
-    }
-}
+package org.apache.maven.plugins.enforcer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.plugin.logging.Log;
+
+/**
+ * This rule checks that no snapshots are included.
+ * 
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ * @version $Id$
+ */
+public class RequireReleaseDeps
+    extends AbstractBanDependencies
+{
+
+    /**
+     * Checks the set of dependencies to see if any snapshots are included
+     * 
+     * @param dependencies
+     * @return
+     * @throws EnforcerRuleException
+     */
+    protected Set checkDependencies( Set dependencies, Log log )
+        throws EnforcerRuleException
+    {
+        Set foundExcludes = new HashSet();
+
+        Iterator DependencyIter = dependencies.iterator();
+        while ( DependencyIter.hasNext() )
+        {
+            Artifact artifact = (Artifact) DependencyIter.next();
+
+            if ( artifact.isSnapshot() )
+            {
+                foundExcludes.add( artifact );
+            }
+        }
+
+        return foundExcludes;
+    }
+}

Propchange: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseDeps.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseVersion.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseVersion.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseVersion.java (original)
+++ maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseVersion.java Sun Mar  2 15:41:23 2008
@@ -1,76 +1,76 @@
-package org.apache.maven.plugins.enforcer;
-
-import org.apache.maven.enforcer.rule.api.EnforcerRule;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
-
-/**
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a> This rule checks that the current project is not a snapshot
- */
-public class RequireReleaseVersion
-    extends AbstractStandardEnforcerRule
-{
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#execute(org.apache.maven.enforcer.rule.api.EnforcerRuleHelper)
-     */
-    public void execute( EnforcerRuleHelper theHelper )
-        throws EnforcerRuleException
-    {
-        try
-        {
-            MavenProject project = (MavenProject) theHelper.evaluate( "${project}" );
-
-            if ( project.getArtifact().isSnapshot() )
-            {
-                StringBuffer buf = new StringBuffer();
-                if ( message != null )
-                {
-                    buf.append( message + "\n" );
-                }
-                buf.append( "This project cannot be a snapshot:" + project.getArtifact().getId() );
-                throw new EnforcerRuleException( buf.toString() );
-            }
-        }
-        catch ( ExpressionEvaluationException e )
-        {
-            throw new EnforcerRuleException( "Unable to retrieve the project.", e );
-        }
-
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#getCacheId()
-     */
-    public String getCacheId()
-    {
-        return "0";
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isCacheable()
-     */
-    public boolean isCacheable()
-    {
-        return false;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isResultValid(org.apache.maven.enforcer.rule.api.EnforcerRule)
-     */
-    public boolean isResultValid( EnforcerRule theCachedRule )
-    {
-        return false;
-    }
-
-}
+package org.apache.maven.plugins.enforcer;
+
+import org.apache.maven.enforcer.rule.api.EnforcerRule;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
+
+/**
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a> This rule checks that the current project is not a snapshot
+ */
+public class RequireReleaseVersion
+    extends AbstractStandardEnforcerRule
+{
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#execute(org.apache.maven.enforcer.rule.api.EnforcerRuleHelper)
+     */
+    public void execute( EnforcerRuleHelper theHelper )
+        throws EnforcerRuleException
+    {
+        try
+        {
+            MavenProject project = (MavenProject) theHelper.evaluate( "${project}" );
+
+            if ( project.getArtifact().isSnapshot() )
+            {
+                StringBuffer buf = new StringBuffer();
+                if ( message != null )
+                {
+                    buf.append( message + "\n" );
+                }
+                buf.append( "This project cannot be a snapshot:" + project.getArtifact().getId() );
+                throw new EnforcerRuleException( buf.toString() );
+            }
+        }
+        catch ( ExpressionEvaluationException e )
+        {
+            throw new EnforcerRuleException( "Unable to retrieve the project.", e );
+        }
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#getCacheId()
+     */
+    public String getCacheId()
+    {
+        return "0";
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isCacheable()
+     */
+    public boolean isCacheable()
+    {
+        return false;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isResultValid(org.apache.maven.enforcer.rule.api.EnforcerRule)
+     */
+    public boolean isResultValid( EnforcerRule theCachedRule )
+    {
+        return false;
+    }
+
+}

Propchange: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseVersion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java (original)
+++ maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java Sun Mar  2 15:41:23 2008
@@ -1,251 +1,251 @@
-package org.apache.maven.plugins.enforcer.utils;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.ArtifactResolver;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Parent;
-import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-import org.codehaus.plexus.util.ReaderFactory;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-
-/**
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * 
- */
-public class EnforcerRuleUtils
-{
-    ArtifactFactory factory;
-
-    ArtifactResolver resolver;
-
-    ArtifactRepository local;
-
-    List remoteRepositories;
-
-    Log log;
-
-    MavenProject project;
-
-    public EnforcerRuleUtils( ArtifactFactory theFactory, ArtifactResolver theResolver, ArtifactRepository theLocal,
-                              List theRemoteRepositories, MavenProject project, Log theLog )
-    {
-        super();
-        this.factory = theFactory;
-        this.resolver = theResolver;
-        this.local = theLocal;
-        this.remoteRepositories = theRemoteRepositories;
-        this.log = theLog;
-        this.project = project;
-    }
-
-    public EnforcerRuleUtils( EnforcerRuleHelper helper )
-    {
-        // get the various expressions out of the
-        // helper.
-
-        try
-        {
-            factory = (ArtifactFactory) helper.getComponent( ArtifactFactory.class );
-            resolver = (ArtifactResolver) helper.getComponent( ArtifactResolver.class );
-            local = (ArtifactRepository) helper.evaluate( "${localRepository}" );
-            project = (MavenProject) helper.evaluate( "${project}" );
-            remoteRepositories = project.getRemoteArtifactRepositories();
-        }
-        catch ( ComponentLookupException e )
-        {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
-        catch ( ExpressionEvaluationException e )
-        {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Gets the pom model for this file.
-     * 
-     * @param pom
-     * @return
-     * @throws IOException
-     * @throws XmlPullParserException
-     */
-    private Model readModel ( File pom )
-        throws IOException, XmlPullParserException
-    {
-        Reader reader = ReaderFactory.newXmlReader( pom );
-        MavenXpp3Reader xpp3 = new MavenXpp3Reader();
-        Model model = null;
-        try
-        {
-            model = xpp3.read( reader );
-        }
-        finally
-        {
-            reader.close();
-            reader = null;
-        }
-        return model;
-    }
-
-    /**
-     * This method gets the model for the defined artifact.
-     * Looks first in the filesystem, then tries to get it
-     * from the repo.
-     * 
-     * @param factory
-     * @param groupId
-     * @param artifactId
-     * @param version
-     * @return
-     * @throws ArtifactResolutionException
-     * @throws ArtifactNotFoundException
-     * @throws XmlPullParserException
-     * @throws IOException
-     */
-    private Model getPomModel ( String groupId, String artifactId, String version, File pom )
-        throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException
-    {
-        Model model = null;
-
-        // do we want to look in the reactor like the
-        // project builder? Would require @aggregator goal
-        // which causes problems in maven core right now
-        // because we also need dependency resolution in
-        // other
-        // rules. (MNG-2277)
-
-        // look in the location specified by pom first.
-        boolean found = false;
-        try
-        {
-            model = readModel( pom );
-
-            // i found a model, lets make sure it's the one
-            // I want
-            found = checkIfModelMatches( groupId, artifactId, version, model );
-        }
-        catch ( IOException e )
-        {
-            // nothing here, but lets look in the repo
-            // before giving up.
-        }
-        catch ( XmlPullParserException e )
-        {
-            // nothing here, but lets look in the repo
-            // before giving up.
-        }
-
-        // i didn't find it in the local file system, go
-        // look in the repo
-        if ( !found )
-        {
-            Artifact pomArtifact = factory.createArtifact( groupId, artifactId, version, null, "pom" );
-            resolver.resolve( pomArtifact, remoteRepositories, local );
-            model = readModel( pomArtifact.getFile() );
-        }
-
-        return model;
-    }
-
-    /**
-     * This method loops through all the parents, getting
-     * each pom model and then its parent.
-     * 
-     * @param groupId
-     * @param artifactId
-     * @param version
-     * @return
-     * @throws ArtifactResolutionException
-     * @throws ArtifactNotFoundException
-     * @throws IOException
-     * @throws XmlPullParserException
-     */
-    public List getModelsRecursively ( String groupId, String artifactId, String version, File pom )
-        throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException
-    {
-        List models = null;
-        Model model = getPomModel( groupId, artifactId, version, pom );
-
-        Parent parent = model.getParent();
-
-        // recurse into the parent
-        if ( parent != null )
-        {
-            // get the relative path
-            String relativePath = parent.getRelativePath();
-            if ( StringUtils.isEmpty( relativePath ) )
-            {
-                relativePath = "../pom.xml";
-            }
-            // calculate the recursive path
-            File parentPom = new File( pom.getParent(), relativePath );
-
-            models = getModelsRecursively( parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), parentPom );
-        }
-        else
-        {
-            // only create it here since I'm not at the top
-            models = new ArrayList();
-        }
-        models.add( model );
-
-        return models;
-    }
-
-    /**
-     * Make sure the model is the one I'm expecting.
-     * 
-     * @param groupId
-     * @param artifactId
-     * @param version
-     * @param model Model being checked.
-     * @return
-     */
-    protected boolean checkIfModelMatches ( String groupId, String artifactId, String version, Model model )
-    {
-        // try these first.
-        String modelGroup = model.getGroupId();
-        String modelVersion = model.getVersion();
-
-        try
-        {
-            if ( StringUtils.isEmpty( modelGroup ) )
-            {
-                modelGroup = model.getParent().getGroupId();
-            }
-
-            if ( StringUtils.isEmpty( modelVersion ) )
-            {
-                modelVersion = model.getParent().getVersion();
-            }
-        }
-        catch ( NullPointerException e )
-        {
-            // this is probably bad. I don't have a valid
-            // group or version and I can't find a
-            // parent????
-            // lets see if it's what we're looking for
-            // anyway.
-        }
-        return ( StringUtils.equals( groupId, modelGroup ) && StringUtils.equals( version, modelVersion ) && StringUtils
-            .equals( artifactId, model.getArtifactId() ) );
-    }
-}
+package org.apache.maven.plugins.enforcer.utils;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Parent;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+/**
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ * 
+ */
+public class EnforcerRuleUtils
+{
+    ArtifactFactory factory;
+
+    ArtifactResolver resolver;
+
+    ArtifactRepository local;
+
+    List remoteRepositories;
+
+    Log log;
+
+    MavenProject project;
+
+    public EnforcerRuleUtils( ArtifactFactory theFactory, ArtifactResolver theResolver, ArtifactRepository theLocal,
+                              List theRemoteRepositories, MavenProject project, Log theLog )
+    {
+        super();
+        this.factory = theFactory;
+        this.resolver = theResolver;
+        this.local = theLocal;
+        this.remoteRepositories = theRemoteRepositories;
+        this.log = theLog;
+        this.project = project;
+    }
+
+    public EnforcerRuleUtils( EnforcerRuleHelper helper )
+    {
+        // get the various expressions out of the
+        // helper.
+
+        try
+        {
+            factory = (ArtifactFactory) helper.getComponent( ArtifactFactory.class );
+            resolver = (ArtifactResolver) helper.getComponent( ArtifactResolver.class );
+            local = (ArtifactRepository) helper.evaluate( "${localRepository}" );
+            project = (MavenProject) helper.evaluate( "${project}" );
+            remoteRepositories = project.getRemoteArtifactRepositories();
+        }
+        catch ( ComponentLookupException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch ( ExpressionEvaluationException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * Gets the pom model for this file.
+     * 
+     * @param pom
+     * @return
+     * @throws IOException
+     * @throws XmlPullParserException
+     */
+    private Model readModel ( File pom )
+        throws IOException, XmlPullParserException
+    {
+        Reader reader = ReaderFactory.newXmlReader( pom );
+        MavenXpp3Reader xpp3 = new MavenXpp3Reader();
+        Model model = null;
+        try
+        {
+            model = xpp3.read( reader );
+        }
+        finally
+        {
+            reader.close();
+            reader = null;
+        }
+        return model;
+    }
+
+    /**
+     * This method gets the model for the defined artifact.
+     * Looks first in the filesystem, then tries to get it
+     * from the repo.
+     * 
+     * @param factory
+     * @param groupId
+     * @param artifactId
+     * @param version
+     * @return
+     * @throws ArtifactResolutionException
+     * @throws ArtifactNotFoundException
+     * @throws XmlPullParserException
+     * @throws IOException
+     */
+    private Model getPomModel ( String groupId, String artifactId, String version, File pom )
+        throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException
+    {
+        Model model = null;
+
+        // do we want to look in the reactor like the
+        // project builder? Would require @aggregator goal
+        // which causes problems in maven core right now
+        // because we also need dependency resolution in
+        // other
+        // rules. (MNG-2277)
+
+        // look in the location specified by pom first.
+        boolean found = false;
+        try
+        {
+            model = readModel( pom );
+
+            // i found a model, lets make sure it's the one
+            // I want
+            found = checkIfModelMatches( groupId, artifactId, version, model );
+        }
+        catch ( IOException e )
+        {
+            // nothing here, but lets look in the repo
+            // before giving up.
+        }
+        catch ( XmlPullParserException e )
+        {
+            // nothing here, but lets look in the repo
+            // before giving up.
+        }
+
+        // i didn't find it in the local file system, go
+        // look in the repo
+        if ( !found )
+        {
+            Artifact pomArtifact = factory.createArtifact( groupId, artifactId, version, null, "pom" );
+            resolver.resolve( pomArtifact, remoteRepositories, local );
+            model = readModel( pomArtifact.getFile() );
+        }
+
+        return model;
+    }
+
+    /**
+     * This method loops through all the parents, getting
+     * each pom model and then its parent.
+     * 
+     * @param groupId
+     * @param artifactId
+     * @param version
+     * @return
+     * @throws ArtifactResolutionException
+     * @throws ArtifactNotFoundException
+     * @throws IOException
+     * @throws XmlPullParserException
+     */
+    public List getModelsRecursively ( String groupId, String artifactId, String version, File pom )
+        throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException
+    {
+        List models = null;
+        Model model = getPomModel( groupId, artifactId, version, pom );
+
+        Parent parent = model.getParent();
+
+        // recurse into the parent
+        if ( parent != null )
+        {
+            // get the relative path
+            String relativePath = parent.getRelativePath();
+            if ( StringUtils.isEmpty( relativePath ) )
+            {
+                relativePath = "../pom.xml";
+            }
+            // calculate the recursive path
+            File parentPom = new File( pom.getParent(), relativePath );
+
+            models = getModelsRecursively( parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), parentPom );
+        }
+        else
+        {
+            // only create it here since I'm not at the top
+            models = new ArrayList();
+        }
+        models.add( model );
+
+        return models;
+    }
+
+    /**
+     * Make sure the model is the one I'm expecting.
+     * 
+     * @param groupId
+     * @param artifactId
+     * @param version
+     * @param model Model being checked.
+     * @return
+     */
+    protected boolean checkIfModelMatches ( String groupId, String artifactId, String version, Model model )
+    {
+        // try these first.
+        String modelGroup = model.getGroupId();
+        String modelVersion = model.getVersion();
+
+        try
+        {
+            if ( StringUtils.isEmpty( modelGroup ) )
+            {
+                modelGroup = model.getParent().getGroupId();
+            }
+
+            if ( StringUtils.isEmpty( modelVersion ) )
+            {
+                modelVersion = model.getParent().getVersion();
+            }
+        }
+        catch ( NullPointerException e )
+        {
+            // this is probably bad. I don't have a valid
+            // group or version and I can't find a
+            // parent????
+            // lets see if it's what we're looking for
+            // anyway.
+        }
+        return ( StringUtils.equals( groupId, modelGroup ) && StringUtils.equals( version, modelVersion ) && StringUtils
+            .equals( artifactId, model.getArtifactId() ) );
+    }
+}

Propchange: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native