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/20 20:17:27 UTC
svn commit: r806286 - in /maven/components/trunk:
maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
pom.xml
Author: bentmann
Date: Thu Aug 20 18:17:26 2009
New Revision: 806286
URL: http://svn.apache.org/viewvc?rev=806286&view=rev
Log:
[MNG-4312] Magic expressions injected by PluginParameterExpressionEvalutor conflict with expressions used by plugins to access system properties
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
maven/components/trunk/pom.xml
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=806286&r1=806285&r2=806286&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 Thu Aug 20 18:17:26 2009
@@ -28,7 +28,7 @@
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 @@
* @author Jason van Zyl
*/
public class PluginParameterExpressionEvaluator
- implements ExpressionEvaluator
+ implements TypeAwareExpressionEvaluator
{
private MavenSession session;
@@ -95,6 +95,12 @@
public Object evaluate( String expr )
throws ExpressionEvaluationException
{
+ return evaluate( expr, null );
+ }
+
+ public Object evaluate( String expr, Class<?> type )
+ throws ExpressionEvaluationException
+ {
Object value = null;
if ( expr == null )
@@ -295,6 +301,19 @@
}
}
+ /*
+ * 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
Modified: maven/components/trunk/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/pom.xml?rev=806286&r1=806285&r2=806286&view=diff
==============================================================================
--- maven/components/trunk/pom.xml (original)
+++ maven/components/trunk/pom.xml Thu Aug 20 18:17:26 2009
@@ -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>