diff --git a/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java b/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java index 8739f9fd89..a933d4d7a2 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java @@ -309,7 +309,7 @@ public class PluginParameterExpressionEvaluator * could still be converted by the configurator so we leave those alone). If so, back off to evaluating the * expression from properties only. */ - if ( value != null && type != null && !( value instanceof String ) && !type.isInstance( value ) ) + if ( value != null && type != null && !( value instanceof String ) && !isTypeCompatible( type, value ) ) { value = null; } @@ -359,6 +359,24 @@ public class PluginParameterExpressionEvaluator return value; } + private static boolean isTypeCompatible( Class type, Object value ) + { + if ( type.isInstance( value ) ) + { + return true; + } + else if ( ( type.isPrimitive() || type.getName().startsWith( "java.lang." ) ) + && value.getClass().getName().startsWith( "java.lang." ) ) + { + // likely Boolean -> boolean, Short -> int etc. conversions, it's not the problem case we try to avoid + return true; + } + else + { + return false; + } + } + private String stripTokens( String expr ) { if ( expr.startsWith( "${" ) && ( expr.indexOf( "}" ) == expr.length() - 1 ) )