[MPLUGIN-196] added property support to javadoc tags in addition to expression, deprecating expression
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1340574 13f79535-47bb-0310-9956-ffa450edef68master
parent
0a1066ff87
commit
02b29353d6
|
|
@ -35,7 +35,7 @@ public class CoreIt0013Mojo
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @parameter expression="${project.build.directory}"
|
* @parameter property="project.build.directory"
|
||||||
* @required
|
* @required
|
||||||
*/
|
*/
|
||||||
private String outputDirectory;
|
private String outputDirectory;
|
||||||
|
|
|
||||||
|
|
@ -297,9 +297,20 @@ public interface JavaMojoAnnotation
|
||||||
* Refer to <code>@parameter expression="..."</code>.
|
* Refer to <code>@parameter expression="..."</code>.
|
||||||
* <br/>
|
* <br/>
|
||||||
* <b>Note</b>: Should be defined in a Mojo Field.
|
* <b>Note</b>: Should be defined in a Mojo Field.
|
||||||
|
* @deprecated use PARAMETER_PROPERTY instead
|
||||||
*/
|
*/
|
||||||
String PARAMETER_EXPRESSION = "expression";
|
String PARAMETER_EXPRESSION = "expression";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This defines the property used to calculate the value to be injected into this parameter of the
|
||||||
|
* Mojo at build time, which can come from <code>-D</code> execution, setting properties or pom properties.
|
||||||
|
* <br/>
|
||||||
|
* Refer to <code>@parameter property="..."</code>.
|
||||||
|
* <br/>
|
||||||
|
* <b>Note</b>: Should be defined in a Mojo Field.
|
||||||
|
*/
|
||||||
|
String PARAMETER_PROPERTY = "property";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This defines the default implementation in the case the parameter type is an interface.
|
* This defines the default implementation in the case the parameter type is an interface.
|
||||||
* <br/>
|
* <br/>
|
||||||
|
|
|
||||||
|
|
@ -549,6 +549,35 @@ public class JavaMojoDescriptorExtractor
|
||||||
}
|
}
|
||||||
|
|
||||||
String expression = parameter.getNamedParameter( JavaMojoAnnotation.PARAMETER_EXPRESSION );
|
String expression = parameter.getNamedParameter( JavaMojoAnnotation.PARAMETER_EXPRESSION );
|
||||||
|
String property = parameter.getNamedParameter( JavaMojoAnnotation.PARAMETER_PROPERTY );
|
||||||
|
|
||||||
|
if ( StringUtils.isNotEmpty( expression ) && StringUtils.isNotEmpty( property ) )
|
||||||
|
{
|
||||||
|
getLogger().error( javaClass.getFullyQualifiedName() + "#" + field.getName() + ":" );
|
||||||
|
getLogger().error( " Cannot use both:" );
|
||||||
|
getLogger().error( " @parameter expression=\"${property}\"" );
|
||||||
|
getLogger().error( " and" );
|
||||||
|
getLogger().error( " @parameter property=\"property\"" );
|
||||||
|
getLogger().error( " Second syntax is preferred." );
|
||||||
|
throw new InvalidParameterException( javaClass.getFullyQualifiedName() + "#" + field.getName()
|
||||||
|
+ ": cannot" + " use both @parameter expression and property", null );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( StringUtils.isNotEmpty( expression ) )
|
||||||
|
{
|
||||||
|
getLogger().warn( javaClass.getFullyQualifiedName() + "#" + field.getName() + ":" );
|
||||||
|
getLogger().warn( " The syntax" );
|
||||||
|
getLogger().warn( " @parameter expression=\"${property}\"" );
|
||||||
|
getLogger().warn( " is deprecated, please use" );
|
||||||
|
getLogger().warn( " @parameter property=\"property\"" );
|
||||||
|
getLogger().warn( " instead." );
|
||||||
|
|
||||||
|
}
|
||||||
|
else if ( StringUtils.isNotEmpty( property ) )
|
||||||
|
{
|
||||||
|
expression = "${" + property + "}";
|
||||||
|
}
|
||||||
|
|
||||||
pd.setExpression( expression );
|
pd.setExpression( expression );
|
||||||
|
|
||||||
if ( StringUtils.isNotEmpty( expression ) && expression.startsWith( "${component." ) )
|
if ( StringUtils.isNotEmpty( expression ) && expression.startsWith( "${component." ) )
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ public class MyMojo
|
||||||
extends AbstractMojo
|
extends AbstractMojo
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @parameter alias="myAlias" implementation="" expression="aProperty" default-value="${anExpression}"
|
* @parameter alias="myAlias" implementation="" property="aProperty" default-value="${anExpression}"
|
||||||
* @readonly
|
* @readonly
|
||||||
* @required
|
* @required
|
||||||
* @since <since-text>
|
* @since <since-text>
|
||||||
|
|
@ -84,8 +84,8 @@ public class MyMojo
|
||||||
}
|
}
|
||||||
+---------+
|
+---------+
|
||||||
|
|
||||||
<<Notice>>: before 3.0, <<<${ }>>> were required for <<<expression>>> value (<<<expression="${aProperty}">>>),
|
<<Notice>>: before 3.0, <<<property>>> was replaced by <<<expression>>>, with <<<${ }>>> required (<<<expression="${aProperty}">>>),
|
||||||
but starting with 3.0, you can omit it (<<<expression="aProperty">>>)
|
but starting with 3.0, you can omit it (<<<expression="aProperty">>>), or preferably use <<<property="aProperty">>>.
|
||||||
|
|
||||||
* See also
|
* See also
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,12 @@ import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
|
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
|
||||||
import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
|
import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
|
||||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||||
import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
|
|
||||||
import org.apache.maven.tools.plugin.generator.Generator;
|
import org.apache.maven.tools.plugin.generator.Generator;
|
||||||
import org.apache.maven.tools.plugin.generator.PluginDescriptorGenerator;
|
import org.apache.maven.tools.plugin.generator.PluginDescriptorGenerator;
|
||||||
import org.apache.maven.tools.plugin.util.PluginUtils;
|
import org.apache.maven.tools.plugin.util.PluginUtils;
|
||||||
import org.codehaus.plexus.component.repository.ComponentDependency;
|
import org.codehaus.plexus.component.repository.ComponentDependency;
|
||||||
|
import org.codehaus.plexus.logging.Logger;
|
||||||
|
import org.codehaus.plexus.logging.console.ConsoleLogger;
|
||||||
import org.codehaus.plexus.util.FileUtils;
|
import org.codehaus.plexus.util.FileUtils;
|
||||||
import org.custommonkey.xmlunit.Diff;
|
import org.custommonkey.xmlunit.Diff;
|
||||||
import org.custommonkey.xmlunit.XMLUnit;
|
import org.custommonkey.xmlunit.XMLUnit;
|
||||||
|
|
@ -102,7 +103,8 @@ public class JavaMojoDescriptorExtractorTest
|
||||||
protected PluginDescriptor generate( String directory )
|
protected PluginDescriptor generate( String directory )
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
MojoDescriptorExtractor extractor = new JavaMojoDescriptorExtractor();
|
JavaMojoDescriptorExtractor extractor = new JavaMojoDescriptorExtractor();
|
||||||
|
extractor.enableLogging( new ConsoleLogger( Logger.LEVEL_INFO, "test" ) );
|
||||||
PluginToolsRequest request = createRequest( directory );
|
PluginToolsRequest request = createRequest( directory );
|
||||||
|
|
||||||
List<MojoDescriptor> mojoDescriptors = extractor.execute( request );
|
List<MojoDescriptor> mojoDescriptors = extractor.execute( request );
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,11 @@ public class Full
|
||||||
*/
|
*/
|
||||||
private File file;
|
private File file;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @parameter property="aSystemProperty"
|
||||||
|
*/
|
||||||
|
private String property;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A component.
|
* A component.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -97,9 +97,17 @@
|
||||||
<editable>true</editable>
|
<editable>true</editable>
|
||||||
<description>A parameter.</description>
|
<description>A parameter.</description>
|
||||||
</parameter>
|
</parameter>
|
||||||
|
<parameter>
|
||||||
|
<name>property</name>
|
||||||
|
<type>java.lang.String</type>
|
||||||
|
<required>false</required>
|
||||||
|
<editable>true</editable>
|
||||||
|
<description></description>
|
||||||
|
</parameter>
|
||||||
</parameters>
|
</parameters>
|
||||||
<configuration>
|
<configuration>
|
||||||
<file implementation="java.io.File" default-value="${anExpression}">${aSystemProperty}</file>
|
<file implementation="java.io.File" default-value="${anExpression}">${aSystemProperty}</file>
|
||||||
|
<property implementation="java.lang.String">${aSystemProperty}</property>
|
||||||
</configuration>
|
</configuration>
|
||||||
<requirements>
|
<requirements>
|
||||||
<requirement>
|
<requirement>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue