o fixed checkstyle + updated javadoc
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@684238 13f79535-47bb-0310-9956-ffa450edef68master
parent
126320356b
commit
e84fa8eeaa
|
|
@ -172,7 +172,8 @@ public interface JavaMojoAnnotation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flags this Mojo as requiring the dependencies in the specified scope (or an implied scope) to be resolved
|
* Flags this Mojo as requiring the dependencies in the specified scope (or an implied scope) to be resolved
|
||||||
* before it can execute. Currently supports <code>compile</code>, <code>runtime</code>, and <code>test</code> scopes.
|
* before it can execute. Currently supports <code>compile</code>, <code>runtime</code>, and
|
||||||
|
* <code>test</code> scopes.
|
||||||
* <br/>
|
* <br/>
|
||||||
* Refer to <code>@requiresDependencyResolution <requiredScope></code>.
|
* Refer to <code>@requiresDependencyResolution <requiredScope></code>.
|
||||||
* <br/>
|
* <br/>
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,8 @@ import java.util.TreeMap;
|
||||||
* Extracts Mojo descriptors from <a href="http://java.sun.com/">Java</a> sources.
|
* Extracts Mojo descriptors from <a href="http://java.sun.com/">Java</a> sources.
|
||||||
* <br/>
|
* <br/>
|
||||||
* For more information about the usage tag, have a look to:
|
* For more information about the usage tag, have a look to:
|
||||||
* <a href="http://maven.apache.org/developers/mojo-api-specification.html">http://maven.apache.org/developers/mojo-api-specification.html</a>
|
* <a href="http://maven.apache.org/developers/mojo-api-specification.html">
|
||||||
|
* http://maven.apache.org/developers/mojo-api-specification.html</a>
|
||||||
*
|
*
|
||||||
* @todo need to add validation directives so that systems embedding maven2 can
|
* @todo need to add validation directives so that systems embedding maven2 can
|
||||||
* get validation directives to help users in IDEs.
|
* get validation directives to help users in IDEs.
|
||||||
|
|
@ -152,7 +153,7 @@ public class JavaMojoDescriptorExtractor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parameter not null
|
* @param parameter not null
|
||||||
* @param i
|
* @param i positive number
|
||||||
* @throws InvalidParameterException if any
|
* @throws InvalidParameterException if any
|
||||||
*/
|
*/
|
||||||
protected void validateParameter( Parameter parameter, int i )
|
protected void validateParameter( Parameter parameter, int i )
|
||||||
|
|
@ -196,22 +197,17 @@ public class JavaMojoDescriptorExtractor
|
||||||
throws InvalidPluginDescriptorException
|
throws InvalidPluginDescriptorException
|
||||||
{
|
{
|
||||||
MojoDescriptor mojoDescriptor = new MojoDescriptor();
|
MojoDescriptor mojoDescriptor = new MojoDescriptor();
|
||||||
|
|
||||||
mojoDescriptor.setLanguage( "java" );
|
mojoDescriptor.setLanguage( "java" );
|
||||||
|
|
||||||
mojoDescriptor.setImplementation( javaClass.getFullyQualifiedName() );
|
mojoDescriptor.setImplementation( javaClass.getFullyQualifiedName() );
|
||||||
|
|
||||||
mojoDescriptor.setDescription( javaClass.getComment() );
|
mojoDescriptor.setDescription( javaClass.getComment() );
|
||||||
|
|
||||||
|
// instantiationStrategy
|
||||||
DocletTag tag = findInClassHierarchy( javaClass, JavaMojoAnnotation.INSTANTIATION_STRATEGY );
|
DocletTag tag = findInClassHierarchy( javaClass, JavaMojoAnnotation.INSTANTIATION_STRATEGY );
|
||||||
|
|
||||||
if ( tag != null )
|
if ( tag != null )
|
||||||
{
|
{
|
||||||
mojoDescriptor.setInstantiationStrategy( tag.getValue() );
|
mojoDescriptor.setInstantiationStrategy( tag.getValue() );
|
||||||
}
|
}
|
||||||
|
|
||||||
tag = findInClassHierarchy( javaClass, JavaMojoAnnotation.MULTI_EXECUTION_STRATEGY );
|
tag = findInClassHierarchy( javaClass, JavaMojoAnnotation.MULTI_EXECUTION_STRATEGY );
|
||||||
|
|
||||||
if ( tag != null )
|
if ( tag != null )
|
||||||
{
|
{
|
||||||
mojoDescriptor.setExecutionStrategy( MojoDescriptor.MULTI_PASS_EXEC_STRATEGY );
|
mojoDescriptor.setExecutionStrategy( MojoDescriptor.MULTI_PASS_EXEC_STRATEGY );
|
||||||
|
|
@ -221,67 +217,43 @@ public class JavaMojoDescriptorExtractor
|
||||||
mojoDescriptor.setExecutionStrategy( MojoDescriptor.SINGLE_PASS_EXEC_STRATEGY );
|
mojoDescriptor.setExecutionStrategy( MojoDescriptor.SINGLE_PASS_EXEC_STRATEGY );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Configurator hint
|
// Configurator hint
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
DocletTag configurator = findInClassHierarchy( javaClass, JavaMojoAnnotation.CONFIGURATOR );
|
DocletTag configurator = findInClassHierarchy( javaClass, JavaMojoAnnotation.CONFIGURATOR );
|
||||||
|
|
||||||
if ( configurator != null )
|
if ( configurator != null )
|
||||||
{
|
{
|
||||||
mojoDescriptor.setComponentConfigurator( configurator.getValue() );
|
mojoDescriptor.setComponentConfigurator( configurator.getValue() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Goal name
|
// Goal name
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
DocletTag goal = findInClassHierarchy( javaClass, JavaMojoAnnotation.GOAL );
|
DocletTag goal = findInClassHierarchy( javaClass, JavaMojoAnnotation.GOAL );
|
||||||
|
|
||||||
if ( goal != null )
|
if ( goal != null )
|
||||||
{
|
{
|
||||||
mojoDescriptor.setGoal( goal.getValue() );
|
mojoDescriptor.setGoal( goal.getValue() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// What version it was introduced in
|
// What version it was introduced in
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
DocletTag since = findInClassHierarchy( javaClass, JavaMojoAnnotation.SINCE );
|
DocletTag since = findInClassHierarchy( javaClass, JavaMojoAnnotation.SINCE );
|
||||||
|
|
||||||
if ( since != null )
|
if ( since != null )
|
||||||
{
|
{
|
||||||
mojoDescriptor.setSince( since.getValue() );
|
mojoDescriptor.setSince( since.getValue() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Deprecation hint
|
// Deprecation hint
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
DocletTag deprecated = javaClass.getTagByName( JavaMojoAnnotation.DEPRECATED );
|
DocletTag deprecated = javaClass.getTagByName( JavaMojoAnnotation.DEPRECATED );
|
||||||
|
|
||||||
if ( deprecated != null )
|
if ( deprecated != null )
|
||||||
{
|
{
|
||||||
mojoDescriptor.setDeprecated( deprecated.getValue() );
|
mojoDescriptor.setDeprecated( deprecated.getValue() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Phase name
|
// Phase name
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
DocletTag phase = findInClassHierarchy( javaClass, JavaMojoAnnotation.PHASE );
|
DocletTag phase = findInClassHierarchy( javaClass, JavaMojoAnnotation.PHASE );
|
||||||
|
|
||||||
if ( phase != null )
|
if ( phase != null )
|
||||||
{
|
{
|
||||||
mojoDescriptor.setPhase( phase.getValue() );
|
mojoDescriptor.setPhase( phase.getValue() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Additional phase to execute first
|
// Additional phase to execute first
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
DocletTag execute = findInClassHierarchy( javaClass, JavaMojoAnnotation.EXECUTE );
|
DocletTag execute = findInClassHierarchy( javaClass, JavaMojoAnnotation.EXECUTE );
|
||||||
|
|
||||||
if ( execute != null )
|
if ( execute != null )
|
||||||
{
|
{
|
||||||
String executePhase = execute.getNamedParameter( JavaMojoAnnotation.EXECUTE_PHASE );
|
String executePhase = execute.getNamedParameter( JavaMojoAnnotation.EXECUTE_PHASE );
|
||||||
|
|
@ -300,7 +272,6 @@ public class JavaMojoDescriptorExtractor
|
||||||
mojoDescriptor.setExecuteGoal( executeGoal );
|
mojoDescriptor.setExecuteGoal( executeGoal );
|
||||||
|
|
||||||
String lifecycle = execute.getNamedParameter( JavaMojoAnnotation.EXECUTE_LIFECYCLE );
|
String lifecycle = execute.getNamedParameter( JavaMojoAnnotation.EXECUTE_LIFECYCLE );
|
||||||
|
|
||||||
if ( lifecycle != null )
|
if ( lifecycle != null )
|
||||||
{
|
{
|
||||||
mojoDescriptor.setExecuteLifecycle( lifecycle );
|
mojoDescriptor.setExecuteLifecycle( lifecycle );
|
||||||
|
|
@ -312,12 +283,9 @@ public class JavaMojoDescriptorExtractor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Dependency resolution flag
|
// Dependency resolution flag
|
||||||
// ----------------------------------------------------------------------
|
DocletTag requiresDependencyResolution =
|
||||||
|
findInClassHierarchy( javaClass, JavaMojoAnnotation.REQUIRES_DEPENDENCY_RESOLUTION );
|
||||||
DocletTag requiresDependencyResolution = findInClassHierarchy( javaClass, JavaMojoAnnotation.REQUIRES_DEPENDENCY_RESOLUTION );
|
|
||||||
|
|
||||||
if ( requiresDependencyResolution != null )
|
if ( requiresDependencyResolution != null )
|
||||||
{
|
{
|
||||||
String value = requiresDependencyResolution.getValue();
|
String value = requiresDependencyResolution.getValue();
|
||||||
|
|
@ -330,44 +298,33 @@ public class JavaMojoDescriptorExtractor
|
||||||
mojoDescriptor.setDependencyResolutionRequired( value );
|
mojoDescriptor.setDependencyResolutionRequired( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Project flag
|
// Project flag
|
||||||
// ----------------------------------------------------------------------
|
boolean value =
|
||||||
|
getBooleanTagValue( javaClass, JavaMojoAnnotation.REQUIRES_PROJECT, mojoDescriptor.isProjectRequired() );
|
||||||
boolean value = getBooleanTagValue( javaClass, JavaMojoAnnotation.REQUIRES_PROJECT, mojoDescriptor.isProjectRequired() );
|
|
||||||
mojoDescriptor.setProjectRequired( value );
|
mojoDescriptor.setProjectRequired( value );
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Aggregator flag
|
// Aggregator flag
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
DocletTag aggregator = findInClassHierarchy( javaClass, JavaMojoAnnotation.AGGREGATOR );
|
DocletTag aggregator = findInClassHierarchy( javaClass, JavaMojoAnnotation.AGGREGATOR );
|
||||||
|
|
||||||
if ( aggregator != null )
|
if ( aggregator != null )
|
||||||
{
|
{
|
||||||
mojoDescriptor.setAggregator( true );
|
mojoDescriptor.setAggregator( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// requiresDirectInvocation flag
|
// requiresDirectInvocation flag
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
value =
|
value =
|
||||||
getBooleanTagValue( javaClass, JavaMojoAnnotation.REQUIRES_DIRECT_INVOCATION, mojoDescriptor.isDirectInvocationOnly() );
|
getBooleanTagValue( javaClass, JavaMojoAnnotation.REQUIRES_DIRECT_INVOCATION,
|
||||||
|
mojoDescriptor.isDirectInvocationOnly() );
|
||||||
mojoDescriptor.setDirectInvocationOnly( value );
|
mojoDescriptor.setDirectInvocationOnly( value );
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Online flag
|
// Online flag
|
||||||
// ----------------------------------------------------------------------
|
value =
|
||||||
|
getBooleanTagValue( javaClass, JavaMojoAnnotation.REQUIRES_ONLINE, mojoDescriptor.isOnlineRequired() );
|
||||||
value = getBooleanTagValue( javaClass, JavaMojoAnnotation.REQUIRES_ONLINE, mojoDescriptor.isOnlineRequired() );
|
|
||||||
mojoDescriptor.setOnlineRequired( value );
|
mojoDescriptor.setOnlineRequired( value );
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// inheritByDefault flag
|
// inheritByDefault flag
|
||||||
// ----------------------------------------------------------------------
|
value =
|
||||||
|
getBooleanTagValue( javaClass, JavaMojoAnnotation.INHERIT_BY_DEFAULT,
|
||||||
value = getBooleanTagValue( javaClass, JavaMojoAnnotation.INHERIT_BY_DEFAULT, mojoDescriptor.isInheritedByDefault() );
|
mojoDescriptor.isInheritedByDefault() );
|
||||||
mojoDescriptor.setInheritedByDefault( value );
|
mojoDescriptor.setInheritedByDefault( value );
|
||||||
|
|
||||||
extractParameters( mojoDescriptor, javaClass );
|
extractParameters( mojoDescriptor, javaClass );
|
||||||
|
|
@ -375,6 +332,13 @@ public class JavaMojoDescriptorExtractor
|
||||||
return mojoDescriptor;
|
return mojoDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param javaClass not null
|
||||||
|
* @param tagName not null
|
||||||
|
* @param defaultValue the wanted default value
|
||||||
|
* @return the boolean value of the given tagName
|
||||||
|
* @see #findInClassHierarchy(JavaClass, String)
|
||||||
|
*/
|
||||||
private static boolean getBooleanTagValue( JavaClass javaClass, String tagName, boolean defaultValue )
|
private static boolean getBooleanTagValue( JavaClass javaClass, String tagName, boolean defaultValue )
|
||||||
{
|
{
|
||||||
DocletTag requiresProject = findInClassHierarchy( javaClass, tagName );
|
DocletTag requiresProject = findInClassHierarchy( javaClass, tagName );
|
||||||
|
|
@ -391,6 +355,11 @@ public class JavaMojoDescriptorExtractor
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param javaClass not null
|
||||||
|
* @param tagName not null
|
||||||
|
* @return docletTag instance
|
||||||
|
*/
|
||||||
private static DocletTag findInClassHierarchy( JavaClass javaClass, String tagName )
|
private static DocletTag findInClassHierarchy( JavaClass javaClass, String tagName )
|
||||||
{
|
{
|
||||||
DocletTag tag = javaClass.getTagByName( tagName );
|
DocletTag tag = javaClass.getTagByName( tagName );
|
||||||
|
|
@ -408,6 +377,11 @@ public class JavaMojoDescriptorExtractor
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mojoDescriptor not null
|
||||||
|
* @param javaClass not null
|
||||||
|
* @throws InvalidPluginDescriptorException if any
|
||||||
|
*/
|
||||||
private void extractParameters( MojoDescriptor mojoDescriptor, JavaClass javaClass )
|
private void extractParameters( MojoDescriptor mojoDescriptor, JavaClass javaClass )
|
||||||
throws InvalidPluginDescriptorException
|
throws InvalidPluginDescriptorException
|
||||||
{
|
{
|
||||||
|
|
@ -540,6 +514,10 @@ public class JavaMojoDescriptorExtractor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param javaClass not null
|
||||||
|
* @return map with Mojo parameters names as keys
|
||||||
|
*/
|
||||||
private Map extractFieldParameterTags( JavaClass javaClass )
|
private Map extractFieldParameterTags( JavaClass javaClass )
|
||||||
{
|
{
|
||||||
Map rawParams;
|
Map rawParams;
|
||||||
|
|
@ -565,7 +543,8 @@ public class JavaMojoDescriptorExtractor
|
||||||
{
|
{
|
||||||
JavaField field = classFields[i];
|
JavaField field = classFields[i];
|
||||||
|
|
||||||
if ( field.getTagByName( JavaMojoAnnotation.PARAMETER ) != null || field.getTagByName( JavaMojoAnnotation.COMPONENT ) != null )
|
if ( field.getTagByName( JavaMojoAnnotation.PARAMETER ) != null
|
||||||
|
|| field.getTagByName( JavaMojoAnnotation.COMPONENT ) != null )
|
||||||
{
|
{
|
||||||
rawParams.put( field.getName(), field );
|
rawParams.put( field.getName(), field );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue