eolivelli commented on a change in pull request #240: [MNG-5001] Block the 
option to set Mojo parameters marked as @readonly
URL: https://github.com/apache/maven/pull/240#discussion_r399760914
 
 

 ##########
 File path: 
maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java
 ##########
 @@ -753,6 +755,37 @@ private void validateParameters( MojoDescriptor 
mojoDescriptor, PlexusConfigurat
         }
     }
 
+    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 );
 
 Review comment:
   Please report mojo/plugin/execution id f possible

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to