mirror of https://github.com/apache/maven.git
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:
parent
075812942b
commit
ed14ff454d
|
@ -33,6 +33,9 @@ import java.util.List;
|
|||
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.
|
||||
*/
|
||||
|
|
|
@ -182,6 +182,11 @@ public class PluginDescriptorGenerator
|
|||
|
||||
element( w, "name", parameter.getName() );
|
||||
|
||||
if( parameter.getAlias() != null )
|
||||
{
|
||||
element( w, "alias", parameter.getAlias() );
|
||||
}
|
||||
|
||||
element( w, "type", parameter.getType() );
|
||||
|
||||
if ( parameter.getDeprecated() != null )
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.maven.tools.plugin.generator;
|
|||
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 @@ import java.util.Set;
|
|||
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 @@ public class PluginXdocGenerator
|
|||
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 @@ public class PluginXdocGenerator
|
|||
|
||||
w.startElement( "th" );
|
||||
|
||||
w.writeText( "Type" );
|
||||
|
||||
w.endElement();
|
||||
|
||||
w.startElement( "th" );
|
||||
|
||||
w.writeText( "Expression" );
|
||||
|
||||
w.endElement();
|
||||
|
@ -163,6 +172,18 @@ public class PluginXdocGenerator
|
|||
|
||||
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 @@ public class PluginXdocGenerator
|
|||
|
||||
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 @@ public class PluginXdocGenerator
|
|||
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
|||
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 @@ public class JellyHarnessGenerator
|
|||
{
|
||||
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();
|
||||
|
|
|
@ -61,6 +61,12 @@ public class JavaMojoDescriptorExtractor
|
|||
|
||||
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";
|
||||
|
||||
public static final String PHASE = "phase";
|
||||
|
@ -298,6 +304,10 @@ public class JavaMojoDescriptorExtractor
|
|||
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 @@ public class JavaMojoDescriptorExtractor
|
|||
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 @@ public class JavaMojoDescriptorExtractor
|
|||
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 );
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue