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 2020/04/22 07:04:29 UTC

[maven] branch MNG-5001-t updated (c0d72a0 -> 6235a20)

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

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


    from c0d72a0  [MNG-5001] Block the option to set Mojo parameters marked as @readonly
     new 89fed43  [MNG-5001] short circuit to focus on read-only parameter with config
     new 6235a20  [MNG-5001] updated error message to better match Maven 2

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../plugin/internal/DefaultMavenPluginManager.java | 25 +++++++++++++++-------
 1 file changed, 17 insertions(+), 8 deletions(-)


[maven] 01/02: [MNG-5001] short circuit to focus on read-only parameter with config

Posted by hb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 89fed43b06bfdd7e2369576267c26a88eef4d86e
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Wed Apr 22 08:42:51 2020 +0200

    [MNG-5001] short circuit to focus on read-only parameter with config
---
 .../plugin/internal/DefaultMavenPluginManager.java | 24 ++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java
index b427622..9d25d35 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java
@@ -767,16 +767,24 @@ public class DefaultMavenPluginManager
 
         for ( Parameter parameter : mojoDescriptor.getParameters() )
         {
+            if ( parameter.isEditable() )
+            {
+                // mojo parameter not read-only: ignore
+                continue;
+            }
             PlexusConfiguration config = configuration.getChild( parameter.getName(), false );
-            if ( config != null && !parameter.isEditable() )
+            if ( config == null )
             {
-                String value = config.getValue( null );
-                String defaultValue = config.getAttribute( "default-value", null );
-                if ( value != null && defaultValue != null && !Objects.equals( defaultValue, value ) )
-                {
-                    invalidParameters.add( parameter );
-                    logger.error( "Setting read-only parameter '" + parameter.getName() + "' to " + value );
-                }
+              // parameter not configured: ignore
+              continue;
+            }
+
+            String value = config.getValue( null );
+            String defaultValue = config.getAttribute( "default-value", null );
+            if ( value != null && defaultValue != null && !Objects.equals( defaultValue, value ) )
+            {
+                invalidParameters.add( parameter );
+                logger.error( "Setting read-only parameter '" + parameter.getName() + "' to " + value );
             }
         }
 


[maven] 02/02: [MNG-5001] updated error message to better match Maven 2

Posted by hb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 6235a20cda6ee70451b330142c76519f8d30c8a5
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Wed Apr 22 09:04:24 2020 +0200

    [MNG-5001] updated error message to better match Maven 2
---
 .../org/apache/maven/plugin/internal/DefaultMavenPluginManager.java    | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java
index 9d25d35..ce5c81e 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java
@@ -784,7 +784,8 @@ public class DefaultMavenPluginManager
             if ( value != null && defaultValue != null && !Objects.equals( defaultValue, value ) )
             {
                 invalidParameters.add( parameter );
-                logger.error( "Setting read-only parameter '" + parameter.getName() + "' to " + value );
+                logger.error( "Invalid plugin configuration: Cannot override read-only parameter '"
+                    + parameter.getName() + "' in goal '" + mojoDescriptor.getGoal() + "'" );
             }
         }