You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/08/28 19:57:05 UTC
svn commit: r808971 -
/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
Author: bentmann
Date: Fri Aug 28 17:57:04 2009
New Revision: 808971
URL: http://svn.apache.org/viewvc?rev=808971&view=rev
Log:
[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
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java?rev=808971&r1=808970&r2=808971&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java Fri Aug 28 17:57:04 2009
@@ -309,7 +309,7 @@
* 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 @@
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 ) )