[MPLUGIN-194] support expression="a property" in addition to expression="${a property}"
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1337816 13f79535-47bb-0310-9956-ffa450edef68master
parent
fb6cee3d5c
commit
169cb9dcc2
|
|
@ -48,7 +48,7 @@ public class FirstMojo
|
|||
@Parameter( defaultValue = "${basedir}", readonly = true )
|
||||
private File basedir;
|
||||
|
||||
@Parameter( expression = "${first.touchFile}", defaultValue = "${project.build.directory}/touch.txt",
|
||||
@Parameter( expression = "first.touchFile", defaultValue = "${project.build.directory}/touch.txt",
|
||||
required = true )
|
||||
private File touchFile;
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class FirstMojo
|
|||
private File basedir;
|
||||
|
||||
/**
|
||||
* @parameter expression="${first.touchFile}" default-value="${project.build.directory}/touch.txt"
|
||||
* @parameter expression="first.touchFile" default-value="${project.build.directory}/touch.txt"
|
||||
* @required
|
||||
*/
|
||||
private File touchFile;
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class MyMojo
|
|||
* @deprecated <deprecated-text>
|
||||
*/
|
||||
@Parameter( alias = "myAlias",
|
||||
expression = "${aSystemProperty}",
|
||||
expression = "aSystemProperty",
|
||||
defaultValue = "${anExpression}",
|
||||
readonly = <false|true>
|
||||
required = <false|true> )
|
||||
|
|
@ -97,6 +97,7 @@ public class MyMojo
|
|||
}
|
||||
+---------+
|
||||
|
||||
|
||||
* See also
|
||||
|
||||
* {{{../maven-plugin-annotations/index.html}Maven Plugin Tools Java 5 Annotations}}
|
||||
|
|
|
|||
|
|
@ -420,7 +420,7 @@ public class PluginDescriptorGenerator
|
|||
{
|
||||
for ( Parameter parameter : parameters )
|
||||
{
|
||||
String expression = parameter.getExpression();
|
||||
String expression = getExpression( parameter );
|
||||
|
||||
if ( StringUtils.isNotEmpty( expression ) && expression.startsWith( "${component." ) )
|
||||
{
|
||||
|
|
@ -571,6 +571,23 @@ public class PluginDescriptorGenerator
|
|||
w.endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the expression value, eventually surrounding it with <code>${ }</code>.
|
||||
*
|
||||
* @param parameter the parameter
|
||||
* @return the expression value
|
||||
*/
|
||||
private String getExpression( Parameter parameter )
|
||||
{
|
||||
String expression = parameter.getExpression();
|
||||
if ( StringUtils.isNotBlank( expression ) && !expression.contains( "${" ) )
|
||||
{
|
||||
expression = "${" + expression.trim() + "}";
|
||||
parameter.setExpression( expression );
|
||||
}
|
||||
return expression;
|
||||
}
|
||||
|
||||
protected String rewriteHelpClassToMojoPackage( PluginToolsRequest request )
|
||||
throws GeneratorException
|
||||
{
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class MyMojo
|
|||
extends AbstractMojo
|
||||
{
|
||||
/**
|
||||
* @parameter alias="myAlias" implementation="" expression="${aSystemProperty}" default-value="${anExpression}"
|
||||
* @parameter alias="myAlias" implementation="" expression="aSystemProperty" default-value="${anExpression}"
|
||||
* @readonly
|
||||
* @required
|
||||
* @since <since-text>
|
||||
|
|
@ -86,6 +86,9 @@ public class MyMojo
|
|||
}
|
||||
+---------+
|
||||
|
||||
<<Notice>>: before 3.0, <<<${ }>>> were required for <<<expression>>> value (<<<expression="${aSystemProperty}">>>),
|
||||
but starting with 3.0, you can omit it (<<<expression="aSystemProperty">>>)
|
||||
|
||||
* See also
|
||||
|
||||
* {{{/developers/mojo-api-specification.html#The_Descriptor_and_Annotations}Mojo API Specification}}
|
||||
|
|
|
|||
Loading…
Reference in New Issue