mirror of https://github.com/apache/maven.git
[MNG-4312] Magic expressions injected by PluginParameterExpressionEvalutor conflict with expressions used by plugins to access system properties
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@806286 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8e277259aa
commit
5c848ce17a
|
@ -28,7 +28,7 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
|||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.path.PathTranslator;
|
||||
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
|
||||
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
|
||||
import org.codehaus.plexus.component.configurator.expression.TypeAwareExpressionEvaluator;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
|
||||
|
||||
|
@ -36,7 +36,7 @@ import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
|
|||
* @author Jason van Zyl
|
||||
*/
|
||||
public class PluginParameterExpressionEvaluator
|
||||
implements ExpressionEvaluator
|
||||
implements TypeAwareExpressionEvaluator
|
||||
{
|
||||
private MavenSession session;
|
||||
|
||||
|
@ -94,6 +94,12 @@ public class PluginParameterExpressionEvaluator
|
|||
|
||||
public Object evaluate( String expr )
|
||||
throws ExpressionEvaluationException
|
||||
{
|
||||
return evaluate( expr, null );
|
||||
}
|
||||
|
||||
public Object evaluate( String expr, Class<?> type )
|
||||
throws ExpressionEvaluationException
|
||||
{
|
||||
Object value = null;
|
||||
|
||||
|
@ -295,6 +301,19 @@ public class PluginParameterExpressionEvaluator
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* MNG-4312: We neither have reserved all of the above magic expressions nor is their set fixed/well-known (it
|
||||
* gets occasionally extended by newer Maven versions). This imposes the risk for existing plugins to
|
||||
* unintentionally use such a magic expression for an ordinary system property. So here we check whether we
|
||||
* ended up with a magic value that is not compatible with the type of the configured mojo parameter (a string
|
||||
* 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 ) )
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
|
||||
if ( value == null )
|
||||
{
|
||||
// The CLI should win for defining properties
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -42,7 +42,7 @@
|
|||
<commonsCliVersion>1.2</commonsCliVersion>
|
||||
<easyMockVersion>1.2_Java1.3</easyMockVersion>
|
||||
<junitVersion>3.8.2</junitVersion>
|
||||
<plexusVersion>1.1.0</plexusVersion>
|
||||
<plexusVersion>1.2.0</plexusVersion>
|
||||
<plexusInterpolationVersion>1.11</plexusInterpolationVersion>
|
||||
<plexusPluginManagerVersion>1.0-alpha-1</plexusPluginManagerVersion>
|
||||
<plexusUtilsVersion>1.5.15</plexusUtilsVersion>
|
||||
|
|
Loading…
Reference in New Issue