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/12/27 17:49:00 UTC

[maven] branch MNG-5001 created (now 8537935)

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

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


      at 8537935  [MNG-5001] updated error message to better match Maven 2

This branch includes the following new commits:

     new 521649c  [MNG-5001] Run ITs
     new ecaad5d  [MNG-5001] Block the option to set Mojo parameters marked as @readonly
     new a76f14b  [MNG-5001] short circuit to focus on read-only parameter with config
     new 8537935  [MNG-5001] updated error message to better match Maven 2

The 4 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.



[maven] 01/04: [MNG-5001] Run ITs

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
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 521649c1fbb5e67fff02487330c459521442e6db
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat Mar 28 22:58:27 2020 +0100

    [MNG-5001] Run ITs
---
 Jenkinsfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index ba9c3c8..a3545aa 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -70,7 +70,7 @@ node(jenkinsEnv.nodeSelection(osNode)) {
             }
         }
 
-        tests = resolveScm source: [$class: 'GitSCMSource', credentialsId: '', id: '_', remote: 'https://gitbox.apache.org/repos/asf/maven-integration-testing.git', traits: [[$class: 'jenkins.plugins.git.traits.BranchDiscoveryTrait'], [$class: 'GitToolSCMSourceTrait', gitTool: 'Default']]], targets: [BRANCH_NAME, 'master']
+        tests = resolveScm source: [$class: 'GitSCMSource', credentialsId: '', id: '_', remote: 'https://gitbox.apache.org/repos/asf/maven-integration-testing.git', traits: [[$class: 'jenkins.plugins.git.traits.BranchDiscoveryTrait'], [$class: 'GitToolSCMSourceTrait', gitTool: 'Default']]], targets: [BRANCH_NAME, 'MNG-5001']
     }
 }
 


[maven] 04/04: [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
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 85379355cc13b00b6d7d27296990c0e8b44d45da
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 89d8d0d..89cc2e2 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
@@ -787,7 +787,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() + "'" );
             }
         }
 


[maven] 03/04: [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
in repository https://gitbox.apache.org/repos/asf/maven.git

commit a76f14bf284ea32bec553b7be8ecce152d40a751
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 788aadd..89d8d0d 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
@@ -770,16 +770,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/04: [MNG-5001] Block the option to set Mojo parameters marked as @readonly

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
in repository https://gitbox.apache.org/repos/asf/maven.git

commit ecaad5ddd874832e71870d0b20f02cac5a9f5101
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Fri Apr 5 16:46:16 2019 +0200

    [MNG-5001] Block the option to set Mojo parameters marked as @readonly
---
 .../maven/plugin/PluginParameterException.java     |  2 +-
 .../plugin/internal/DefaultMavenPluginManager.java | 35 +++++++++++++++++++++-
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterException.java b/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterException.java
index eaf02ec..e69f555 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterException.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterException.java
@@ -43,7 +43,7 @@ public class PluginParameterException
     public PluginParameterException( MojoDescriptor mojo, List<Parameter> parameters )
     {
         super( mojo.getPluginDescriptor(), "The parameters " + format( parameters ) + " for goal "
-            + mojo.getRoleHint() + " are missing or invalid" );
+            + mojo.getRoleHint() + " are missing, read-only or invalid" );
 
         this.mojo = mojo;
 
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 7c77ee8..788aadd 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
@@ -627,6 +627,8 @@ public class DefaultMavenPluginManager
             logger.debug(
                 "Configuring mojo '" + mojoDescriptor.getId() + "' with " + configuratorId + " configurator -->" );
 
+            validateReadOnlyParameters( mojoDescriptor, configuration );
+
             configurator.configureComponent( mojo, configuration, expressionEvaluator, pluginRealm, validator );
 
             logger.debug( "-- end configuration --" );
@@ -719,7 +721,6 @@ public class DefaultMavenPluginManager
             {
                 continue;
             }
-
             Object value = null;
 
             PlexusConfiguration config = configuration.getChild( parameter.getName(), false );
@@ -742,6 +743,7 @@ public class DefaultMavenPluginManager
                         + configuration.getName() + "'";
                     throw new ComponentConfigurationException( configuration, msg, e );
                 }
+
             }
 
             if ( value == null && ( config == null || config.getChildCount() <= 0 ) )
@@ -756,6 +758,37 @@ public class DefaultMavenPluginManager
         }
     }
 
+    private void validateReadOnlyParameters( MojoDescriptor mojoDescriptor, PlexusConfiguration configuration )
+            throws PluginParameterException
+    {
+        if ( mojoDescriptor.getParameters() == null )
+        {
+            return;
+        }
+
+        List<Parameter> invalidParameters = new ArrayList<>();
+
+        for ( Parameter parameter : mojoDescriptor.getParameters() )
+        {
+            PlexusConfiguration config = configuration.getChild( parameter.getName(), false );
+            if ( config != null && !parameter.isEditable() )
+            {
+                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 );
+                }
+            }
+        }
+
+        if ( !invalidParameters.isEmpty() )
+        {
+            throw new PluginParameterException( mojoDescriptor, invalidParameters );
+        }
+    }
+
     public void releaseMojo( Object mojo, MojoExecution mojoExecution )
     {
         if ( mojo != null )