mirror of https://github.com/apache/maven.git
[MNG-4238] [regression] plugin parameters of primitive types can't be populated from expression
o First part of the fix, complete solution requires new plexus container (PLX-431) as well git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@808971 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
023afe0dec
commit
0b8b83f670
|
@ -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
|
* could still be converted by the configurator so we leave those alone). If so, back off to evaluating the
|
||||||
* expression from properties only.
|
* 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;
|
value = null;
|
||||||
}
|
}
|
||||||
|
@ -359,6 +359,24 @@ public class PluginParameterExpressionEvaluator
|
||||||
return value;
|
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 )
|
private String stripTokens( String expr )
|
||||||
{
|
{
|
||||||
if ( expr.startsWith( "${" ) && ( expr.indexOf( "}" ) == expr.length() - 1 ) )
|
if ( expr.startsWith( "${" ) && ( expr.indexOf( "}" ) == expr.length() - 1 ) )
|
||||||
|
|
Loading…
Reference in New Issue