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/04/11 07:21:31 UTC

[GitHub] [maven] michael-o commented on a diff in pull request #705: [MNG-5222] Maven 3 no longer logs warnings about deprecated plugin parameters

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


##########
maven-core/src/main/java/org/apache/maven/plugin/internal/ValidatingConfigurationListener.java:
##########
@@ -41,12 +50,20 @@
 
     private final ConfigurationListener delegate;
 
+    private final MojoDescriptor mojoDescriptor;
+    private final ExpressionEvaluator expressionEvaluator;
+
+    private final Logger logger = LoggerFactory.getLogger( getClass() );

Review Comment:
   Why not use a static logger, any reason to have a per-instance?



##########
maven-core/src/main/java/org/apache/maven/plugin/internal/ValidatingConfigurationListener.java:
##########
@@ -80,18 +95,83 @@ public void notifyFieldChangeUsingReflection( String fieldName, Object value, Ob
     {
         delegate.notifyFieldChangeUsingReflection( fieldName, value, target );
 
-        if ( mojo == target )
+        if ( mojo == target && value != null )
         {
             notify( fieldName, value );
         }
     }
 
     private void notify( String fieldName, Object value )
     {
-        if ( value != null )
+        missingParameters.remove( fieldName );
+
+        if ( logger.isWarnEnabled() )
+        {
+            warnDeprecated( fieldName, value );
+        }
+    }
+
+    private void warnDeprecated( String fieldName, Object value )
+    {
+        Parameter parameter = mojoDescriptor.getParameterMap().get( fieldName );
+        String deprecated = parameter.getDeprecated();
+        if ( deprecated != null && !deprecated.isEmpty() )
+        {
+            Object defaultValue = evaluateValue( parameter.getDefaultValue() );
+            if ( !toString( value ).equals( toString( defaultValue ) ) )
+            {
+                StringBuilder sb = new StringBuilder( "  Parameter '" );
+                sb.append( fieldName ).append( '\'' );
+                if ( parameter.getExpression() != null )
+                {
+                    String userProperty = parameter.getExpression().replace( "${", "'" ).replace( '}', '\'' );
+                    sb.append( " (User Property " ).append( userProperty ).append( ")" );
+                }
+                sb.append( " is deprecated. " ).append( deprecated );

Review Comment:
   This still doesn't make sense. The API says:
   
       @param deprecated <code>true</code> to deprecate the Mojo, <code>false</code> otherwise.
   
   So the output will read: ...is deprecated. true"
   
   Why not `"true"equals(deprecated)`?



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