- Allow recursive evaluation

- Allow evaluation for default value


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163446 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Emmanuel Venisse 2005-03-02 12:29:03 +00:00
parent 90ab124653
commit 6211437619
2 changed files with 22 additions and 1 deletions

View File

@ -373,7 +373,7 @@ public static Map createParameters( MojoDescriptor goal, MavenSession session )
{ {
if ( parameter.getDefaultValue() != null ) if ( parameter.getDefaultValue() != null )
{ {
value = parameter.getDefaultValue(); value = PluginParameterExpressionEvaluator.evaluate( parameter.getDefaultValue(), session );
} }
} }

View File

@ -34,6 +34,11 @@ public static Object evaluate( String expression, MavenSession context )
{ {
Object value = null; Object value = null;
if ( expression == null )
{
// todo : verify if it's fixed with trygvis modification in Plexus
return null;
}
if ( expression.startsWith( "#component" ) ) if ( expression.startsWith( "#component" ) )
{ {
String role = expression.substring( 11 ); String role = expression.substring( 11 );
@ -114,6 +119,22 @@ else if ( expression.startsWith( "#" ) )
value = System.getProperty( expression.substring( 1 ) ); value = System.getProperty( expression.substring( 1 ) );
} }
if ( value instanceof String )
{
String val = (String) value;
int sharpSeparator = val.indexOf( "#" );
if ( sharpSeparator > 0 )
{
val = val.substring( 0, sharpSeparator ) + evaluate( val.substring( sharpSeparator ), context );
value = val;
}
else if ( sharpSeparator > 0 )
{
value = evaluate( val.substring( sharpSeparator ), context );
}
}
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// If we strike and we are not dealing with an expression then we will // If we strike and we are not dealing with an expression then we will
// will let the value pass through unaltered so that users can hardcode // will let the value pass through unaltered so that users can hardcode