michael-o commented on code in PR #741:
URL: https://github.com/apache/maven/pull/741#discussion_r882048013


##########
maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultMojoExecutionConfigurator.java:
##########
@@ -40,6 +51,7 @@
 public class DefaultMojoExecutionConfigurator
     implements MojoExecutionConfigurator
 {
+    private Logger logger = LoggerFactory.getLogger( getClass() );

Review Comment:
   Make it final, good habit.



##########
maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultMojoExecutionConfigurator.java:
##########
@@ -108,4 +122,75 @@ 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() );

Review Comment:
   Why do you compare with all other goals too?



##########
maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultMojoExecutionConfigurator.java:
##########
@@ -76,6 +88,8 @@ else if ( allowPluginLevelConfig )
             mojoConfiguration = Xpp3Dom.mergeXpp3Dom( 
mojoExecution.getConfiguration(), mojoConfiguration );
 
             mojoExecution.setConfiguration( mojoConfiguration );
+
+            checkUnKnownMojoConfigurationParameters( mojoExecution );

Review Comment:
   `Unknown`



##########
maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultMojoExecutionConfigurator.java:
##########
@@ -108,4 +122,75 @@ 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: '" )
+                    .warning( mojoExecution.getArtifactId() ).warning( ":" )
+                    .warning( mojoExecution.getVersion() ).warning( ":" )
+                    .warning( mojoExecution.getGoal() );

Review Comment:
   Is this consistent with other formats we use?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to