On Fri, 09 Nov 2018 08:58:49 +0100, <khmarba...@apache.org> wrote:

This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a commit to branch MENFORCER-306
in repository https://gitbox.apache.org/repos/asf/maven-enforcer.git

commit e81e13178ae3ea153a0d0c5936ca951b71a73bc3
Author: Karl Heinz Marbaise <khmarba...@apache.org>
AuthorDate: Sun Oct 7 17:33:56 2018 +0200

    Code improvement.
---
.../maven/plugins/enforcer/RequirePluginVersions.java | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
index 383f60e..a005365 100644
--- a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java +++ b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
@@ -644,8 +644,7 @@ public class RequirePluginVersions
         for ( PluginWrapper plugin : pluginWrappers )
         {
             // find the matching plugin entry
-            if ( source.getArtifactId().equals( plugin.getArtifactId() )
-                && source.getGroupId().equals( plugin.getGroupId() ) )
+            if ( isMatchingPlugin( source, plugin ) )
             {
                 found = true;
                 // found the entry. now see if the version is specified
@@ -659,7 +658,7 @@ public class RequirePluginVersions
                     return false;
                 }
- if ( StringUtils.isNotEmpty( version ) && !StringUtils.isWhitespace( version ) )
+                if ( isVersion( version ) )
                 {
helper.getLog().debug( "checking for notEmpty and notIsWhiespace(): " + version );
                     if ( banRelease && version.equals( "RELEASE" ) )
@@ -697,6 +696,17 @@ public class RequirePluginVersions
         return status;
     }

Please rename to isValidVersion

+    private boolean isVersion( String version )
+    {
+ return StringUtils.isNotEmpty( version ) && !StringUtils.isWhitespace( version );
+    }
+
+ private boolean isMatchingPlugin( Plugin source, PluginWrapper plugin )
+    {
+        return source.getArtifactId().equals( plugin.getArtifactId() )
+            && source.getGroupId().equals( plugin.getGroupId() );
+    }
+
     /**
      * Checks if is snapshot.
      *
@@ -1043,7 +1053,6 @@ public class RequirePluginVersions
         return pluginDescriptor;
     }
-
     /**
* Gets all plugin entries in build.plugins, build.pluginManagement.plugins, profile.build.plugins, reporting and
      * profile.reporting in this project and all parents
@@ -1074,7 +1083,7 @@ public class RequirePluginVersions
         }
        List<PluginWrapper> plugins = new ArrayList<PluginWrapper>();
-
+
         // now find all the plugin entries, either in
// build.plugins or build.pluginManagement.plugins, profiles.plugins and reporting
         for ( Model model : models )

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org

Reply via email to