Author: nicolas
Date: Wed Apr 23 03:51:34 2008
New Revision: 650822

URL: http://svn.apache.org/viewvc?rev=650822&view=rev
Log:
MENFORCER-45 : plugins declared in profiles are not detected for version check

Modified:
    
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java

Modified: 
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
URL: 
http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java?rev=650822&r1=650821&r2=650822&view=diff
==============================================================================
--- 
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
 (original)
+++ 
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
 Wed Apr 23 03:51:34 2008
@@ -377,6 +377,7 @@
      * @param plugin to lookup
      * @param project to search
      * @return matching plugin, null if not found.
+     * @return matching plugin, null if not found.
      */
     protected Plugin findCurrentPlugin( Plugin plugin, MavenProject project )
     {
@@ -472,7 +473,8 @@
      * specified.
      */
     protected boolean hasValidVersionSpecified( EnforcerRuleHelper helper, 
Plugin source, List plugins )
-    {
+    {          
+               boolean found = false;
         boolean status = false;
         Iterator iter = plugins.iterator();
         while ( iter.hasNext() )
@@ -482,6 +484,7 @@
             if ( source.getArtifactId().equals( plugin.getArtifactId() ) &&
                 source.getGroupId().equals( plugin.getGroupId() ) )
             {
+                               found = true;
                 // found the entry. now see if the version
                 // is specified
                 String version = plugin.getVersion();
@@ -492,11 +495,11 @@
                 catch ( ExpressionEvaluationException e )
                 {
                     return false;
-                }
+                               }
 
                 if ( StringUtils.isNotEmpty( version ) && 
!StringUtils.isWhitespace( version ) )
                 {
-
+                               
                     if ( banRelease && version.equals( "RELEASE" ) )
                     {
                         return false;
@@ -525,6 +528,10 @@
                 }
             }
         }
+               if ( !found )
+               {
+                       log.warn( "plugin " + source.getGroupId() + ":" + 
source.getArtifactId() + " not found" );
+               }
         return status;
     }
 
@@ -791,7 +798,8 @@
     }
 
     /**
-     * Gets all plugin entries in build.plugins or 
build.pluginManagement.plugins in this project and all parents
+     * Gets all plugin entries in build.plugins or 
build.pluginManagement.plugins or profile.build.plugins 
+        * in this project and all parents
      * 
      * @param project
      * @return
@@ -823,6 +831,22 @@
             {
                 // guess there are no plugins here.
             }
+                       
+                       // Add plugins in profiles
+                       Iterator it = model.getProfiles().iterator();
+                       while ( it.hasNext() )
+                       {
+                               Profile profile = (Profile) it.next();
+                               try
+                               {
+                                       plugins.addAll( 
profile.getBuild().getPlugins() );                              
+                               }
+                               catch ( NullPointerException e )
+                               {
+                                       // guess there are no plugins here.
+                               }
+                               
+                       }
 
             try
             {


Reply via email to