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
|
extends ComponentDescriptor
|
||||||
implements Cloneable
|
implements Cloneable
|
||||||
{
|
{
|
||||||
// TODO: share with type handler
|
|
||||||
public static String MAVEN_PLUGIN = "maven-plugin";
|
public static String MAVEN_PLUGIN = "maven-plugin";
|
||||||
|
|
||||||
public static final String SINGLE_PASS_EXEC_STRATEGY = "once-per-session";
|
public static final String SINGLE_PASS_EXEC_STRATEGY = "once-per-session";
|
||||||
|
@ -59,6 +58,8 @@ public class MojoDescriptor
|
||||||
|
|
||||||
private String executePhase;
|
private String executePhase;
|
||||||
|
|
||||||
|
private String executeLifecycle;
|
||||||
|
|
||||||
private String deprecated;
|
private String deprecated;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -375,4 +376,14 @@ public class MojoDescriptor
|
||||||
|
|
||||||
return result;
|
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.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo share constants
|
* @todo share constants
|
||||||
* @todo add example usage tag that can be shown in the doco
|
* @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 java.io.FileReader;
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
import org.apache.maven.plugin.descriptor.Parameter;
|
import org.apache.maven.plugin.descriptor.Parameter;
|
||||||
|
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
|
||||||
|
|
||||||
// only on start of line
|
// only on start of line
|
||||||
this.tag = "\\r?\\n\\s*\\*?\\s*@(\\w+)";
|
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.descriptionPattern = Pattern.compile( "(?s)\\r?\\n\\s*\\*" );
|
||||||
this.typePattern = Pattern.compile( "type\\s*=\\s*\"(.*?)\"" );
|
this.typePattern = Pattern.compile( "type\\s*=\\s*\"(.*?)\"" );
|
||||||
this.expressionPattern = Pattern.compile( "expression\\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 );
|
setAccessibility( true );
|
||||||
|
|
||||||
|
@ -135,7 +138,6 @@ extract( file, mojoDescriptor )
|
||||||
this.tags = getTags( text );
|
this.tags = getTags( text );
|
||||||
mojoDescriptor.setGoal( tags.get( "goal" ) );
|
mojoDescriptor.setGoal( tags.get( "goal" ) );
|
||||||
mojoDescriptor.setPhase( tags.get( "phase" ) );
|
mojoDescriptor.setPhase( tags.get( "phase" ) );
|
||||||
mojoDescriptor.setExecutePhase( tags.get( "executePhase" ) );
|
|
||||||
this.value = tags.get( "requiresDependencyResolution" );
|
this.value = tags.get( "requiresDependencyResolution" );
|
||||||
// TODO: share with java extractor
|
// TODO: share with java extractor
|
||||||
if ( value == null || value.length() == 0 )
|
if ( value == null || value.length() == 0 )
|
||||||
|
@ -146,6 +148,26 @@ extract( file, mojoDescriptor )
|
||||||
|
|
||||||
mojoDescriptor.setProjectRequired( tags.containsKey( "requiresProject" ) );
|
mojoDescriptor.setProjectRequired( tags.containsKey( "requiresProject" ) );
|
||||||
mojoDescriptor.setOnlineRequired( tags.containsKey( "requiresOnline" ) );
|
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 PHASE = "phase";
|
||||||
|
|
||||||
public static final String EXECUTE_PHASE = "executePhase";
|
public static final String EXECUTE = "execute";
|
||||||
|
|
||||||
public static final String GOAL_DESCRIPTION = "description";
|
public static final String GOAL_DESCRIPTION = "description";
|
||||||
|
|
||||||
|
@ -184,11 +184,29 @@ public class JavaMojoDescriptorExtractor
|
||||||
// Additional phase to execute first
|
// Additional phase to execute first
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
DocletTag executePhase = findInClassHierarchy( javaClass, EXECUTE_PHASE );
|
DocletTag oldExecutePhase = findInClassHierarchy( javaClass, "executePhase" );
|
||||||
|
if ( oldExecutePhase != null )
|
||||||
if ( executePhase != 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.
|
// We're resolving class-level, ancestor-class-field, local-class-field order here.
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
Map rawParams = new TreeMap();
|
Map rawParams = extractFieldParameterTags( javaClass );
|
||||||
|
|
||||||
extractFieldParameterTags( javaClass, rawParams );
|
|
||||||
|
|
||||||
for ( Iterator it = rawParams.entrySet().iterator(); it.hasNext(); )
|
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
|
// we have to add the parent fields first, so that they will be overwritten by the local fields if
|
||||||
// that actually happens...
|
// that actually happens...
|
||||||
JavaClass superClass = javaClass.getSuperJavaClass();
|
JavaClass superClass = javaClass.getSuperJavaClass();
|
||||||
|
|
||||||
if ( superClass != null )
|
if ( superClass != null )
|
||||||
{
|
{
|
||||||
extractFieldParameterTags( superClass, rawParams );
|
rawParams = extractFieldParameterTags( superClass );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rawParams = new TreeMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
JavaField[] classFields = javaClass.getFields();
|
JavaField[] classFields = javaClass.getFields();
|
||||||
|
@ -341,7 +363,7 @@ public class JavaMojoDescriptorExtractor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return rawParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JavaClass getJavaClass( JavaSource javaSource )
|
private JavaClass getJavaClass( JavaSource javaSource )
|
||||||
|
@ -354,8 +376,6 @@ public class JavaMojoDescriptorExtractor
|
||||||
{
|
{
|
||||||
JavaDocBuilder builder = new JavaDocBuilder();
|
JavaDocBuilder builder = new JavaDocBuilder();
|
||||||
|
|
||||||
File basedir = project.getBasedir();
|
|
||||||
|
|
||||||
for ( Iterator i = project.getCompileSourceRoots().iterator(); i.hasNext(); )
|
for ( Iterator i = project.getCompileSourceRoots().iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
builder.addSourceTree( new File( (String) i.next() ) );
|
builder.addSourceTree( new File( (String) i.next() ) );
|
||||||
|
|
Loading…
Reference in New Issue