mirror of https://github.com/apache/maven.git
PR: MNG-471
add @execute phase|lifecycle doclet tag for java and beanshell not sure how this would be configured for marmalade - will leave this for a once over of marmalade wrt the mojo api later git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@191385 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0d27b339f9
commit
dbcdd0b526
|
@ -36,7 +36,6 @@ public class MojoDescriptor
|
|||
extends ComponentDescriptor
|
||||
implements Cloneable
|
||||
{
|
||||
// TODO: share with type handler
|
||||
public static String MAVEN_PLUGIN = "maven-plugin";
|
||||
|
||||
public static final String SINGLE_PASS_EXEC_STRATEGY = "once-per-session";
|
||||
|
@ -59,6 +58,8 @@ public class MojoDescriptor
|
|||
|
||||
private String executePhase;
|
||||
|
||||
private String executeLifecycle;
|
||||
|
||||
private String deprecated;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -375,4 +376,14 @@ public class MojoDescriptor
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getExecuteLifecycle()
|
||||
{
|
||||
return executeLifecycle;
|
||||
}
|
||||
|
||||
public void setExecuteLifecycle( String executeLifecycle )
|
||||
{
|
||||
this.executeLifecycle = executeLifecycle;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @todo share constants
|
||||
* @todo add example usage tag that can be shown in the doco
|
||||
|
|
|
@ -3,6 +3,7 @@ import java.util.regex.Pattern;
|
|||
import java.io.FileReader;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.apache.maven.plugin.descriptor.Parameter;
|
||||
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
|
||||
|
||||
// only on start of line
|
||||
this.tag = "\\r?\\n\\s*\\*?\\s*@(\\w+)";
|
||||
|
@ -13,6 +14,8 @@ this.tagsPattern = Pattern.compile( "(?s)" + tag + "\\s*(.*?)" + tagOrEndComment
|
|||
this.descriptionPattern = Pattern.compile( "(?s)\\r?\\n\\s*\\*" );
|
||||
this.typePattern = Pattern.compile( "type\\s*=\\s*\"(.*?)\"" );
|
||||
this.expressionPattern = Pattern.compile( "expression\\s*=\\s*\"(.*?)\"" );
|
||||
this.phasePattern = Pattern.compile( "phase\\s*=\\s*\"(.*?)\"" );
|
||||
this.lifecyclePattern = Pattern.compile( "lifecycle\\s*=\\s*\"(.*?)\"" );
|
||||
|
||||
setAccessibility( true );
|
||||
|
||||
|
@ -135,7 +138,6 @@ extract( file, mojoDescriptor )
|
|||
this.tags = getTags( text );
|
||||
mojoDescriptor.setGoal( tags.get( "goal" ) );
|
||||
mojoDescriptor.setPhase( tags.get( "phase" ) );
|
||||
mojoDescriptor.setExecutePhase( tags.get( "executePhase" ) );
|
||||
this.value = tags.get( "requiresDependencyResolution" );
|
||||
// TODO: share with java extractor
|
||||
if ( value == null || value.length() == 0 )
|
||||
|
@ -146,6 +148,26 @@ extract( file, mojoDescriptor )
|
|||
|
||||
mojoDescriptor.setProjectRequired( tags.containsKey( "requiresProject" ) );
|
||||
mojoDescriptor.setOnlineRequired( tags.containsKey( "requiresOnline" ) );
|
||||
|
||||
this.value = tags.get( "execute" );
|
||||
if ( value != null )
|
||||
{
|
||||
m = phasePattern.matcher( value );
|
||||
if ( m.find() )
|
||||
{
|
||||
mojoDescriptor.setExecutePhase( m.group( 1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidPluginDescriptorException( "@execute must have a phase" );
|
||||
}
|
||||
|
||||
m = lifecyclePattern.matcher( value );
|
||||
if ( m.find() )
|
||||
{
|
||||
mojoDescriptor.setExecuteLifecycle( m.group( 1 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public class JavaMojoDescriptorExtractor
|
|||
|
||||
public static final String PHASE = "phase";
|
||||
|
||||
public static final String EXECUTE_PHASE = "executePhase";
|
||||
public static final String EXECUTE = "execute";
|
||||
|
||||
public static final String GOAL_DESCRIPTION = "description";
|
||||
|
||||
|
@ -184,11 +184,29 @@ public class JavaMojoDescriptorExtractor
|
|||
// Additional phase to execute first
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DocletTag executePhase = findInClassHierarchy( javaClass, EXECUTE_PHASE );
|
||||
|
||||
if ( executePhase != null )
|
||||
DocletTag oldExecutePhase = findInClassHierarchy( javaClass, "executePhase" );
|
||||
if ( oldExecutePhase != null )
|
||||
{
|
||||
mojoDescriptor.setExecutePhase( executePhase.getValue() );
|
||||
getLogger().warn( "DEPRECATED: @executePhase is deprecated, please use @execute" );
|
||||
mojoDescriptor.setExecutePhase( oldExecutePhase.getValue() );
|
||||
}
|
||||
|
||||
DocletTag execute = findInClassHierarchy( javaClass, EXECUTE );
|
||||
|
||||
if ( execute != null )
|
||||
{
|
||||
String executePhase = execute.getNamedParameter( "phase" );
|
||||
if ( executePhase == null )
|
||||
{
|
||||
throw new InvalidPluginDescriptorException( "@execute tag requires a 'phase' parameter" );
|
||||
}
|
||||
mojoDescriptor.setExecutePhase( executePhase );
|
||||
|
||||
String lifecycle = execute.getNamedParameter( "lifecycle" );
|
||||
if ( lifecycle != null )
|
||||
{
|
||||
mojoDescriptor.setExecuteLifecycle( lifecycle );
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -268,9 +286,7 @@ public class JavaMojoDescriptorExtractor
|
|||
// We're resolving class-level, ancestor-class-field, local-class-field order here.
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
Map rawParams = new TreeMap();
|
||||
|
||||
extractFieldParameterTags( javaClass, rawParams );
|
||||
Map rawParams = extractFieldParameterTags( javaClass );
|
||||
|
||||
for ( Iterator it = rawParams.entrySet().iterator(); it.hasNext(); )
|
||||
{
|
||||
|
@ -314,15 +330,21 @@ public class JavaMojoDescriptorExtractor
|
|||
}
|
||||
}
|
||||
|
||||
private void extractFieldParameterTags( JavaClass javaClass, Map rawParams )
|
||||
private Map extractFieldParameterTags( JavaClass javaClass )
|
||||
{
|
||||
Map rawParams;
|
||||
|
||||
// we have to add the parent fields first, so that they will be overwritten by the local fields if
|
||||
// that actually happens...
|
||||
JavaClass superClass = javaClass.getSuperJavaClass();
|
||||
|
||||
if ( superClass != null )
|
||||
{
|
||||
extractFieldParameterTags( superClass, rawParams );
|
||||
rawParams = extractFieldParameterTags( superClass );
|
||||
}
|
||||
else
|
||||
{
|
||||
rawParams = new TreeMap();
|
||||
}
|
||||
|
||||
JavaField[] classFields = javaClass.getFields();
|
||||
|
@ -341,7 +363,7 @@ public class JavaMojoDescriptorExtractor
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rawParams;
|
||||
}
|
||||
|
||||
private JavaClass getJavaClass( JavaSource javaSource )
|
||||
|
@ -354,8 +376,6 @@ public class JavaMojoDescriptorExtractor
|
|||
{
|
||||
JavaDocBuilder builder = new JavaDocBuilder();
|
||||
|
||||
File basedir = project.getBasedir();
|
||||
|
||||
for ( Iterator i = project.getCompileSourceRoots().iterator(); i.hasNext(); )
|
||||
{
|
||||
builder.addSourceTree( new File( (String) i.next() ) );
|
||||
|
|
Loading…
Reference in New Issue