You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/06/01 19:02:46 UTC

[GitHub] [maven] slawekjaranowski commented on a diff in pull request #741: [MNG-7468] Check unsupported plugins parameters in configuration

slawekjaranowski commented on code in PR #741:
URL: https://github.com/apache/maven/pull/741#discussion_r887204090


##########
maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultMojoExecutionConfigurator.java:
##########
@@ -108,4 +122,77 @@ private PluginExecution findPluginExecution( String executionId, Collection<Plug
         return null;
     }
 
+    private void checkUnknownMojoConfigurationParameters( MojoExecution mojoExecution )
+    {
+        if ( mojoExecution.getConfiguration() == null || mojoExecution.getConfiguration().getChildCount() == 0 )
+        {
+            return;
+        }
+
+        MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
+
+        // in first step get parameter names of current goal
+        Set<String> parametersNamesGoal = mojoDescriptor.getParameters().stream()
+            .flatMap( this::getParameterNames )
+            .collect( Collectors.toSet() );
+
+        Set<String> unknownParameters = getUnknownParameters( mojoExecution, parametersNamesGoal );
+
+        if ( unknownParameters.isEmpty() )
+        {
+            return;
+        }
+
+        // second step get parameter names of all plugin goals
+        Set<String> parametersNamesAll = mojoDescriptor.getPluginDescriptor().getMojos().stream()
+            .flatMap( m -> m.getParameters().stream() )
+            .flatMap( this::getParameterNames )
+            .collect( Collectors.toSet() );
+
+        unknownParameters = getUnknownParameters( mojoExecution, parametersNamesAll );
+
+        unknownParameters.forEach(
+            name ->
+            {
+                MessageBuilder messageBuilder = MessageUtils.buffer()
+                    .warning( "Parameter '" )
+                    .warning( name )
+                    .warning( "' is unknown for plugin '" )

Review Comment:
   It is for plugin - we check parameters for all goals



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

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org