You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2022/01/06 20:21:37 UTC

[maven] branch MNG-7263 updated: [MNG-7263] improve AbstractLifecycleProvider

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

hboutemy pushed a commit to branch MNG-7263
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/MNG-7263 by this push:
     new 654a41e  [MNG-7263] improve AbstractLifecycleProvider
654a41e is described below

commit 654a41ea10b1e3aa27d18b5e13a89ea30fab5479
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Thu Jan 6 21:21:34 2022 +0100

    [MNG-7263] improve AbstractLifecycleProvider
---
 .../lifecycle/providers/AbstractLifecycleProvider.java      | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/providers/AbstractLifecycleProvider.java b/maven-core/src/main/java/org/apache/maven/lifecycle/providers/AbstractLifecycleProvider.java
index eb80a58..c54d77c 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/providers/AbstractLifecycleProvider.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/providers/AbstractLifecycleProvider.java
@@ -41,11 +41,16 @@ public abstract class AbstractLifecycleProvider
         HashMap<String, LifecyclePhase> defaultBindings = null;
         if ( pluginBindings != null )
         {
-            int len = pluginBindings.length;
-            defaultBindings = new HashMap<>();
-            for ( int i = 0; i < len; i++ )
+            final int len = pluginBindings.length;
+
+            if ( len < 1 || len % 2 != 0 )
+            {
+                throw new IllegalArgumentException( "Plugin bindings must have more than 0, even count of elements" );
+            }            defaultBindings = new HashMap<>();
+
+            for ( int i = 0; i < len; i += 2 )
             {
-                defaultBindings.put( pluginBindings[i++], new LifecyclePhase( pluginBindings[i] ) );
+                defaultBindings.put( pluginBindings[i], new LifecyclePhase( pluginBindings[i + 1] ) );
             }
         }