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 e8d54e83f7ee62b36d9644d0a2146b489983fd5a Author: Karl Heinz Marbaise <[email protected]> AuthorDate: Sun Oct 7 17:33:56 2018 +0200 Code improvement. --- .../plugins/enforcer/RequirePluginVersions.java | 21 ++++++++++++++++----- 1 file changed, 16 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 f48fcbd..9936462 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 ) ) { log.debug( "checking for notEmpty and notIsWhiespace(): " + version ); if ( banRelease && version.equals( "RELEASE" ) ) @@ -697,6 +696,17 @@ public class RequirePluginVersions return status; } + 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. * @@ -1057,7 +1067,6 @@ public class RequirePluginVersions protected List<PluginWrapper> getAllPluginEntries( MavenProject project ) throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException { - List<PluginWrapper> plugins = new ArrayList<PluginWrapper>(); // get all the pom models List<Model> models = new ArrayList<Model>(); @@ -1068,6 +1077,8 @@ public class RequirePluginVersions models.add( mavenProject.getOriginalModel() ); } + 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 ) @@ -1278,4 +1289,4 @@ public class RequirePluginVersions { return additionalPlugins; } -} \ No newline at end of file +}
