Modifying the mojo generators to handle alias, and other missing elements where appropriate. Changed the resources mojos to be as trim as I can, and added @required to the field-level annotations (this might be a good thing to do for all plexus components, dunno if it's there already)...finally, trimmed up the annotation handling in the JavaMojoDescriptorExtractor to push as many annotation fields as possible into the endangered area, and started pulling as much info from the field, other companion annotations on the field, etc. as I can...I think the annotations are there, now. They need to be cleaned up after converting all the core plugins to use field-level annotations, then we're set.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@164990 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-04-27 15:11:28 +00:00
parent 075812942b
commit ed14ff454d
7 changed files with 110 additions and 24 deletions

View File

@ -33,6 +33,9 @@
import java.util.Set;
/**
* [JC] Is this class defunct now? I can't find o.a.m.plugin.BeanPluginAdapter in the codebase...
* I'm not going to edit this class to account for aliases, deprecation, etc. until I know.
*
* @todo use the descriptions in the descriptor for the javadoc pushed into the
* source code.
*/

View File

@ -181,6 +181,11 @@ protected void processPluginDescriptor( MojoDescriptor mojoDescriptor, XMLWriter
w.startElement( "parameter" );
element( w, "name", parameter.getName() );
if( parameter.getAlias() != null )
{
element( w, "alias", parameter.getAlias() );
}
element( w, "type", parameter.getType() );

View File

@ -19,6 +19,7 @@
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
import org.codehaus.plexus.util.xml.XMLWriter;
@ -37,7 +38,8 @@
public class PluginXdocGenerator
implements Generator
{
public void execute( String destinationDirectory, Set mojoDescriptors, MavenProject project ) throws Exception
public void execute( String destinationDirectory, Set mojoDescriptors, MavenProject project )
throws Exception
{
for ( Iterator it = mojoDescriptors.iterator(); it.hasNext(); )
{
@ -137,7 +139,8 @@ protected void processPluginDescriptor( MojoDescriptor mojoDescriptor, String de
writer.close();
}
private void writeGoalParameterTable( MojoDescriptor mojoDescriptor, XMLWriter w ) throws Exception
private void writeGoalParameterTable( MojoDescriptor mojoDescriptor, XMLWriter w )
throws Exception
{
w.startElement( "p" );
@ -153,6 +156,12 @@ private void writeGoalParameterTable( MojoDescriptor mojoDescriptor, XMLWriter w
w.startElement( "th" );
w.writeText( "Type" );
w.endElement();
w.startElement( "th" );
w.writeText( "Expression" );
w.endElement();
@ -163,6 +172,18 @@ private void writeGoalParameterTable( MojoDescriptor mojoDescriptor, XMLWriter w
w.endElement();
w.startElement( "th" );
w.writeText( "Required?" );
w.endElement();
w.startElement( "th" );
w.writeText( "Deprecated?" );
w.endElement();
w.endElement();
List parameters = mojoDescriptor.getParameters();
@ -181,7 +202,24 @@ private void writeGoalParameterTable( MojoDescriptor mojoDescriptor, XMLWriter w
w.startElement( "td" );
w.writeText( parameter.getName() );
String paramName = parameter.getAlias();
if ( StringUtils.isEmpty( paramName ) )
{
paramName = parameter.getName();
}
w.writeText( paramName );
w.endElement();
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
w.startElement( "td" );
w.writeText( parameter.getType() );
w.endElement();
@ -201,12 +239,34 @@ private void writeGoalParameterTable( MojoDescriptor mojoDescriptor, XMLWriter w
w.startElement( "td" );
Parameter p = (Parameter) parameterMap.get( parameter.getName() );
w.writeText( p.getDescription() );
w.writeText( parameter.getDescription() );
w.endElement();
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
w.startElement( "td" );
w.writeText( Boolean.toString( parameter.isRequired() ) );
w.endElement();
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
String deprecationWarning = parameter.getDeprecated();
if ( StringUtils.isNotEmpty( deprecationWarning ) )
{
w.startElement( "td" );
w.writeText( deprecationWarning );
w.endElement();
}
w.endElement();
}

View File

@ -22,6 +22,7 @@
import org.apache.maven.project.MavenProject;
import org.apache.maven.tools.plugin.generator.Generator;
import org.apache.maven.tools.plugin.util.PluginUtils;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
import org.codehaus.plexus.util.xml.XMLWriter;
@ -194,7 +195,14 @@ protected void processPluginDescriptor( MojoDescriptor mojoDescriptor, XMLWriter
{
Parameter parameter = (Parameter) parameters.get( i );
w.addAttribute( parameter.getName(), "${" + parameter.getName() + "}" );
String paramName = parameter.getAlias();
if( StringUtils.isEmpty( paramName ) )
{
paramName = parameter.getName();
}
w.addAttribute( paramName, "${" + paramName + "}" );
}
w.endElement();

View File

@ -60,6 +60,12 @@ public class JavaMojoDescriptorExtractor
public static final String MAVEN_PLUGIN_MODE = "maven.plugin.mode";
public static final String PARAMETER = "parameter";
public static final String PARAMETER_EXPRESSION = "expression";
public static final String REQUIRED = "required";
public static final String DEPRECATED = "deprecated";
public static final String GOAL = "goal";
@ -298,6 +304,10 @@ private void extractParameters( MojoDescriptor mojoDescriptor, JavaClass javaCla
pd.setDefaultValue( parameter.getNamedParameter( "default" ) );
pd.setDescription( parameter.getNamedParameter( "description" ) );
pd.setRequired( parameter.getNamedParameter( "required" ).equals( "true" ) ? true : false );
pd.setDeprecated( parameter.getNamedParameter( "deprecated" ) );
}
else
{
@ -306,6 +316,14 @@ private void extractParameters( MojoDescriptor mojoDescriptor, JavaClass javaCla
pd.setType( field.getType().getValue() );
pd.setDescription( field.getComment() );
pd.setRequired( field.getTagByName(REQUIRED) != null );
DocletTag deprecationTag = field.getTagByName( DEPRECATED );
if( deprecationTag != null)
{
pd.setDeprecated( deprecationTag.getValue() );
}
}
String alias = parameter.getNamedParameter( "alias" );
@ -315,11 +333,7 @@ private void extractParameters( MojoDescriptor mojoDescriptor, JavaClass javaCla
pd.setAlias( alias );
}
pd.setRequired( parameter.getNamedParameter( "required" ).equals( "true" ) ? true : false );
pd.setExpression( parameter.getNamedParameter( "expression" ) );
pd.setDeprecated( parameter.getNamedParameter( "deprecated" ) );
pd.setExpression( parameter.getNamedParameter( PARAMETER_EXPRESSION ) );
parameters.add( pd );
}

View File

@ -46,18 +46,16 @@ public class ResourcesMojo
/**
* The output directory into which to copy the resources.
*
* @parameter name="outputDirectory"
* required="true"
* expression="${project.build.outputDirectory}"
* @parameter expression="${project.build.outputDirectory}"
* @required
*/
private String outputDirectory;
/**
* The list of resources we want to transfer.
*
* @parameter name="resources"
* required="true"
* expression="${project.build.resources}"
* @parameter expression="${project.build.resources}"
* @required
*/
private List resources;

View File

@ -33,18 +33,16 @@ public class TestResourcesMojo
/**
* The output directory into which to copy the resources.
*
* @parameter name="outputDirectory"
* required="true"
* expression="${project.build.testOutputDirectory}"
* @parameter expression="${project.build.testOutputDirectory}"
* @required
*/
private String outputDirectory;
/**
* The list of resources we want to transfer.
*
* @parameter name="resources"
* required="true"
* expression="${project.build.testResources}"
* @parameter expression="${project.build.testResources}"
* @required
*/
private List resources;