diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DeprecatedPluginValidator.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DeprecatedPluginValidator.java index a41c533cae..3139f5b84b 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DeprecatedPluginValidator.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DeprecatedPluginValidator.java @@ -24,6 +24,7 @@ import javax.inject.Singleton; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.Parameter; +import org.apache.maven.shared.utils.logging.MessageBuilder; import org.apache.maven.shared.utils.logging.MessageUtils; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; @@ -32,7 +33,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Print warnings if deprecated params of plugin are used in configuration. + * Print warnings if deprecated mojo or parameters of plugin are used in configuration. * * @author Slawomir Jaranowski */ @@ -52,6 +53,11 @@ class DeprecatedPluginValidator implements MavenPluginConfigurationValidator return; } + if ( mojoDescriptor.getDeprecated() != null ) + { + logDeprecatedMojo( mojoDescriptor ); + } + if ( mojoDescriptor.getParameters() == null ) { return; @@ -64,19 +70,19 @@ class DeprecatedPluginValidator implements MavenPluginConfigurationValidator } private static void checkParameter( Parameter parameter, - PlexusConfiguration pomConfiguration, - ExpressionEvaluator expressionEvaluator ) + PlexusConfiguration pomConfiguration, + ExpressionEvaluator expressionEvaluator ) { PlexusConfiguration config = pomConfiguration.getChild( parameter.getName(), false ); if ( isValueSet( config, expressionEvaluator ) ) { - logDeprecateWarn( parameter ); + logDeprecatedParameter( parameter ); } } private static boolean isValueSet( PlexusConfiguration config, - ExpressionEvaluator expressionEvaluator ) + ExpressionEvaluator expressionEvaluator ) { if ( config == null ) { @@ -112,22 +118,38 @@ class DeprecatedPluginValidator implements MavenPluginConfigurationValidator return false; } - private static void logDeprecateWarn( Parameter parameter ) + private void logDeprecatedMojo( MojoDescriptor mojoDescriptor ) { - StringBuilder sb = new StringBuilder(); - sb.append( "Parameter '" ); - sb.append( parameter.getName() ); - sb.append( '\'' ); + String message = MessageUtils.buffer() + .warning( "Goal '" ) + .warning( mojoDescriptor.getGoal() ) + .warning( "' is deprecated: " ) + .warning( mojoDescriptor.getDeprecated() ) + .toString(); + + LOGGER.warn( message ); + } + + private static void logDeprecatedParameter( Parameter parameter ) + { + MessageBuilder messageBuilder = MessageUtils.buffer() + .warning( "Parameter '" ) + .warning( parameter.getName() ) + .warning( '\'' ); + if ( parameter.getExpression() != null ) { String userProperty = parameter.getExpression().replace( "${", "'" ).replace( '}', '\'' ); - sb.append( " (user property " ); - sb.append( userProperty ); - sb.append( ")" ); + messageBuilder + .warning( " (user property " ) + .warning( userProperty ) + .warning( ")" ); } - sb.append( " is deprecated: " ); - sb.append( parameter.getDeprecated() ); - LOGGER.warn( MessageUtils.buffer().warning( sb.toString() ).toString() ); + messageBuilder + .warning( " is deprecated: " ) + .warning( parameter.getDeprecated() ); + + LOGGER.warn( messageBuilder.toString() ); } }