o fixed checkstyle + updated javadoc
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@684236 13f79535-47bb-0310-9956-ffa450edef68master
parent
fa601065d6
commit
4c3d449369
|
|
@ -72,6 +72,11 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
return mojoDescriptors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scriptFilesKeyedByBasedir not null
|
||||
* @param outputDirectory not null
|
||||
* @throws ExtractionException if any
|
||||
*/
|
||||
protected void copyScriptsToOutputDirectory( Map scriptFilesKeyedByBasedir, String outputDirectory )
|
||||
throws ExtractionException
|
||||
{
|
||||
|
|
@ -121,6 +126,12 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param basedir not null
|
||||
* @param directories not null
|
||||
* @param scriptFileExtension not null
|
||||
* @return map with subdirs paths as key
|
||||
*/
|
||||
protected Map gatherFilesByBasedir( File basedir, List directories, String scriptFileExtension )
|
||||
{
|
||||
Map sourcesByBasedir = new TreeMap();
|
||||
|
|
@ -164,6 +175,15 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
return sourcesByBasedir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be implemented in the sub classes.
|
||||
*
|
||||
* @param metadataFilesKeyedByBasedir could be null
|
||||
* @param pluginDescriptor could be null
|
||||
* @return always null
|
||||
* @throws ExtractionException if any
|
||||
* @throws InvalidPluginDescriptorException if any
|
||||
*/
|
||||
protected List extractMojoDescriptorsFromMetadata( Map metadataFilesKeyedByBasedir,
|
||||
PluginDescriptor pluginDescriptor )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
|
|
@ -171,17 +191,34 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be implemented in the sub classes.
|
||||
*
|
||||
* @return always null
|
||||
*/
|
||||
protected String getMetadataFileExtension()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be implemented in the sub classes.
|
||||
*
|
||||
* @param scriptFilesKeyedByBasedir could be null
|
||||
* @param pluginDescriptor could be null
|
||||
* @return always null
|
||||
* @throws ExtractionException if any
|
||||
* @throws InvalidPluginDescriptorException if any
|
||||
*/
|
||||
protected List extractMojoDescriptors( Map scriptFilesKeyedByBasedir, PluginDescriptor pluginDescriptor )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the file extension like <code>.bsh</code> for BeanShell.
|
||||
*/
|
||||
protected abstract String getScriptFileExtension();
|
||||
|
||||
}
|
||||
|
|
@ -73,19 +73,19 @@ public class PluginDescriptorGenerator
|
|||
|
||||
w.startElement( "plugin" );
|
||||
|
||||
element( w, "description", pluginDescriptor.getDescription() );
|
||||
PluginUtils.element( w, "description", pluginDescriptor.getDescription() );
|
||||
|
||||
element( w, "groupId", pluginDescriptor.getGroupId() );
|
||||
PluginUtils.element( w, "groupId", pluginDescriptor.getGroupId() );
|
||||
|
||||
element( w, "artifactId", pluginDescriptor.getArtifactId() );
|
||||
PluginUtils.element( w, "artifactId", pluginDescriptor.getArtifactId() );
|
||||
|
||||
element( w, "version", pluginDescriptor.getVersion() );
|
||||
PluginUtils.element( w, "version", pluginDescriptor.getVersion() );
|
||||
|
||||
element( w, "goalPrefix", pluginDescriptor.getGoalPrefix() );
|
||||
PluginUtils.element( w, "goalPrefix", pluginDescriptor.getGoalPrefix() );
|
||||
|
||||
element( w, "isolatedRealm", "" + pluginDescriptor.isIsolatedRealm() );
|
||||
PluginUtils.element( w, "isolatedRealm", "" + pluginDescriptor.isIsolatedRealm() );
|
||||
|
||||
element( w, "inheritedByDefault", "" + pluginDescriptor.isInheritedByDefault() );
|
||||
PluginUtils.element( w, "inheritedByDefault", "" + pluginDescriptor.isInheritedByDefault() );
|
||||
|
||||
w.startElement( "mojos" );
|
||||
|
||||
|
|
@ -112,6 +112,10 @@ public class PluginDescriptorGenerator
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mojoDescriptor not null
|
||||
* @param w not null
|
||||
*/
|
||||
protected void processMojoDescriptor( MojoDescriptor mojoDescriptor, XMLWriter w )
|
||||
{
|
||||
w.startElement( "mojo" );
|
||||
|
|
@ -121,9 +125,7 @@ public class PluginDescriptorGenerator
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
w.startElement( "goal" );
|
||||
|
||||
w.writeText( mojoDescriptor.getGoal() );
|
||||
|
||||
w.endElement();
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
@ -135,9 +137,7 @@ public class PluginDescriptorGenerator
|
|||
if ( description != null )
|
||||
{
|
||||
w.startElement( "description" );
|
||||
|
||||
w.writeText( mojoDescriptor.getDescription() );
|
||||
|
||||
w.endElement();
|
||||
}
|
||||
|
||||
|
|
@ -147,44 +147,44 @@ public class PluginDescriptorGenerator
|
|||
|
||||
if ( mojoDescriptor.isDependencyResolutionRequired() != null )
|
||||
{
|
||||
element( w, "requiresDependencyResolution", mojoDescriptor.isDependencyResolutionRequired() );
|
||||
PluginUtils.element( w, "requiresDependencyResolution", mojoDescriptor.isDependencyResolutionRequired() );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
element( w, "requiresDirectInvocation", "" + mojoDescriptor.isDirectInvocationOnly() );
|
||||
PluginUtils.element( w, "requiresDirectInvocation", "" + mojoDescriptor.isDirectInvocationOnly() );
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
element( w, "requiresProject", "" + mojoDescriptor.isProjectRequired() );
|
||||
PluginUtils.element( w, "requiresProject", "" + mojoDescriptor.isProjectRequired() );
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
element( w, "requiresReports", "" + mojoDescriptor.isRequiresReports() );
|
||||
PluginUtils.element( w, "requiresReports", "" + mojoDescriptor.isRequiresReports() );
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
element( w, "aggregator", "" + mojoDescriptor.isAggregator() );
|
||||
PluginUtils.element( w, "aggregator", "" + mojoDescriptor.isAggregator() );
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
element( w, "requiresOnline", "" + mojoDescriptor.isOnlineRequired() );
|
||||
PluginUtils.element( w, "requiresOnline", "" + mojoDescriptor.isOnlineRequired() );
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
element( w, "inheritedByDefault", "" + mojoDescriptor.isInheritedByDefault() );
|
||||
PluginUtils.element( w, "inheritedByDefault", "" + mojoDescriptor.isInheritedByDefault() );
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
|
|
@ -192,7 +192,7 @@ public class PluginDescriptorGenerator
|
|||
|
||||
if ( mojoDescriptor.getPhase() != null )
|
||||
{
|
||||
element( w, "phase", mojoDescriptor.getPhase() );
|
||||
PluginUtils.element( w, "phase", mojoDescriptor.getPhase() );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
@ -201,17 +201,17 @@ public class PluginDescriptorGenerator
|
|||
|
||||
if ( mojoDescriptor.getExecutePhase() != null )
|
||||
{
|
||||
element( w, "executePhase", mojoDescriptor.getExecutePhase() );
|
||||
PluginUtils.element( w, "executePhase", mojoDescriptor.getExecutePhase() );
|
||||
}
|
||||
|
||||
if ( mojoDescriptor.getExecuteGoal() != null )
|
||||
{
|
||||
element( w, "executeGoal", mojoDescriptor.getExecuteGoal() );
|
||||
PluginUtils.element( w, "executeGoal", mojoDescriptor.getExecuteGoal() );
|
||||
}
|
||||
|
||||
if ( mojoDescriptor.getExecuteLifecycle() != null )
|
||||
{
|
||||
element( w, "executeLifecycle", mojoDescriptor.getExecuteLifecycle() );
|
||||
PluginUtils.element( w, "executeLifecycle", mojoDescriptor.getExecuteLifecycle() );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
@ -219,9 +219,7 @@ public class PluginDescriptorGenerator
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
w.startElement( "implementation" );
|
||||
|
||||
w.writeText( mojoDescriptor.getImplementation() );
|
||||
|
||||
w.endElement();
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
@ -229,9 +227,7 @@ public class PluginDescriptorGenerator
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
w.startElement( "language" );
|
||||
|
||||
w.writeText( mojoDescriptor.getLanguage() );
|
||||
|
||||
w.endElement();
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
@ -241,9 +237,7 @@ public class PluginDescriptorGenerator
|
|||
if ( mojoDescriptor.getComponentConfigurator() != null )
|
||||
{
|
||||
w.startElement( "configurator" );
|
||||
|
||||
w.writeText( mojoDescriptor.getComponentConfigurator() );
|
||||
|
||||
w.endElement();
|
||||
}
|
||||
|
||||
|
|
@ -254,9 +248,7 @@ public class PluginDescriptorGenerator
|
|||
if ( mojoDescriptor.getComponentComposer() != null )
|
||||
{
|
||||
w.startElement( "composer" );
|
||||
|
||||
w.writeText( mojoDescriptor.getComponentComposer() );
|
||||
|
||||
w.endElement();
|
||||
}
|
||||
|
||||
|
|
@ -265,9 +257,7 @@ public class PluginDescriptorGenerator
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
w.startElement( "instantiationStrategy" );
|
||||
|
||||
w.writeText( mojoDescriptor.getInstantiationStrategy() );
|
||||
|
||||
w.endElement();
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
@ -275,9 +265,7 @@ public class PluginDescriptorGenerator
|
|||
// the calculated (decorated, resolved) execution stack
|
||||
// ----------------------------------------------------------------------
|
||||
w.startElement( "executionStrategy" );
|
||||
|
||||
w.writeText( mojoDescriptor.getExecutionStrategy() );
|
||||
|
||||
w.endElement();
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
@ -329,9 +317,8 @@ public class PluginDescriptorGenerator
|
|||
|
||||
String roleHint = null;
|
||||
|
||||
int posRoleHintSeparator;
|
||||
|
||||
if ( ( posRoleHintSeparator = role.indexOf( "#" ) ) > 0 )
|
||||
int posRoleHintSeparator = role.indexOf( "#" );
|
||||
if ( posRoleHintSeparator > 0 )
|
||||
{
|
||||
roleHint = role.substring( posRoleHintSeparator + 1 );
|
||||
|
||||
|
|
@ -351,33 +338,33 @@ public class PluginDescriptorGenerator
|
|||
|
||||
w.startElement( "parameter" );
|
||||
|
||||
element( w, "name", parameter.getName() );
|
||||
PluginUtils.element( w, "name", parameter.getName() );
|
||||
|
||||
if ( parameter.getAlias() != null )
|
||||
{
|
||||
element( w, "alias", parameter.getAlias() );
|
||||
PluginUtils.element( w, "alias", parameter.getAlias() );
|
||||
}
|
||||
|
||||
element( w, "type", parameter.getType() );
|
||||
PluginUtils.element( w, "type", parameter.getType() );
|
||||
|
||||
if ( parameter.getDeprecated() != null )
|
||||
{
|
||||
element( w, "deprecated", parameter.getDeprecated() );
|
||||
PluginUtils.element( w, "deprecated", parameter.getDeprecated() );
|
||||
}
|
||||
|
||||
if ( parameter.getImplementation() != null )
|
||||
{
|
||||
element( w, "implementation", parameter.getImplementation() );
|
||||
PluginUtils.element( w, "implementation", parameter.getImplementation() );
|
||||
}
|
||||
|
||||
element( w, "required", Boolean.toString( parameter.isRequired() ) );
|
||||
PluginUtils.element( w, "required", Boolean.toString( parameter.isRequired() ) );
|
||||
|
||||
element( w, "editable", Boolean.toString( parameter.isEditable() ) );
|
||||
PluginUtils.element( w, "editable", Boolean.toString( parameter.isEditable() ) );
|
||||
|
||||
element( w, "description", parameter.getDescription() );
|
||||
PluginUtils.element( w, "description", parameter.getDescription() );
|
||||
|
||||
if ( StringUtils.isNotEmpty( parameter.getDefaultValue() ) ||
|
||||
StringUtils.isNotEmpty( parameter.getExpression() ) )
|
||||
if ( StringUtils.isNotEmpty( parameter.getDefaultValue() )
|
||||
|| StringUtils.isNotEmpty( parameter.getExpression() ) )
|
||||
{
|
||||
configuration.add( parameter );
|
||||
}
|
||||
|
|
@ -391,7 +378,7 @@ public class PluginDescriptorGenerator
|
|||
w.endElement();
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Coinfiguration
|
||||
// Configuration
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
if ( !configuration.isEmpty() )
|
||||
|
|
@ -441,14 +428,14 @@ public class PluginDescriptorGenerator
|
|||
|
||||
w.startElement( "requirement" );
|
||||
|
||||
element( w, "role", requirement.getRole() );
|
||||
PluginUtils.element( w, "role", requirement.getRole() );
|
||||
|
||||
if ( requirement.getRoleHint() != null )
|
||||
{
|
||||
element( w, "role-hint", requirement.getRoleHint() );
|
||||
PluginUtils.element( w, "role-hint", requirement.getRoleHint() );
|
||||
}
|
||||
|
||||
element( w, "field-name", key );
|
||||
PluginUtils.element( w, "field-name", key );
|
||||
|
||||
w.endElement();
|
||||
}
|
||||
|
|
@ -456,15 +443,6 @@ public class PluginDescriptorGenerator
|
|||
w.endElement();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
w.endElement();
|
||||
}
|
||||
|
||||
private void element( XMLWriter w, String name, String value )
|
||||
{
|
||||
PluginUtils.element( w, name, value );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,10 +53,13 @@ public class PluginHelpGenerator
|
|||
extends AbstractLogEnabled
|
||||
implements Generator
|
||||
{
|
||||
/** Line separator */
|
||||
private static final String LS = System.getProperty( "line.separator" );
|
||||
|
||||
/** Default generated class name */
|
||||
private static final String HELP_MOJO_CLASS_NAME = "HelpMojo";
|
||||
|
||||
/** Default goal */
|
||||
private static final String HELP_GOAL = "help";
|
||||
|
||||
/**
|
||||
|
|
@ -156,42 +159,37 @@ public class PluginHelpGenerator
|
|||
|
||||
try
|
||||
{
|
||||
{
|
||||
Parameter param = new Parameter();
|
||||
param.setName( "detail" );
|
||||
param.setType( "boolean" );
|
||||
param.setDescription( "If <code>true</code>, display all settable properties for each goal." );
|
||||
param.setDefaultValue( "false" );
|
||||
param.setExpression( "${detail}" );
|
||||
descriptor.addParameter( param );
|
||||
}
|
||||
{
|
||||
Parameter param = new Parameter();
|
||||
param.setName( "goal" );
|
||||
param.setType( "java.lang.String" );
|
||||
param.setDescription( "The name of the goal for which to show help."
|
||||
+ " If unspecified, all goals will be displayed." );
|
||||
param.setExpression( "${goal}" );
|
||||
descriptor.addParameter( param );
|
||||
}
|
||||
{
|
||||
Parameter param = new Parameter();
|
||||
param.setName( "lineLength" );
|
||||
param.setType( "int" );
|
||||
param.setDescription( "The maximum length of a display line, should be positive." );
|
||||
param.setDefaultValue( "80" );
|
||||
param.setExpression( "${lineLength}" );
|
||||
descriptor.addParameter( param );
|
||||
}
|
||||
{
|
||||
Parameter param = new Parameter();
|
||||
param.setName( "indentSize" );
|
||||
param.setType( "int" );
|
||||
param.setDescription( "The number of spaces per indentation level, should be positive." );
|
||||
param.setDefaultValue( "2" );
|
||||
param.setExpression( "${indentSize}" );
|
||||
descriptor.addParameter( param );
|
||||
}
|
||||
Parameter param = new Parameter();
|
||||
param.setName( "detail" );
|
||||
param.setType( "boolean" );
|
||||
param.setDescription( "If <code>true</code>, display all settable properties for each goal." );
|
||||
param.setDefaultValue( "false" );
|
||||
param.setExpression( "${detail}" );
|
||||
descriptor.addParameter( param );
|
||||
|
||||
param = new Parameter();
|
||||
param.setName( "goal" );
|
||||
param.setType( "java.lang.String" );
|
||||
param.setDescription( "The name of the goal for which to show help."
|
||||
+ " If unspecified, all goals will be displayed." );
|
||||
param.setExpression( "${goal}" );
|
||||
descriptor.addParameter( param );
|
||||
|
||||
param = new Parameter();
|
||||
param.setName( "lineLength" );
|
||||
param.setType( "int" );
|
||||
param.setDescription( "The maximum length of a display line, should be positive." );
|
||||
param.setDefaultValue( "80" );
|
||||
param.setExpression( "${lineLength}" );
|
||||
descriptor.addParameter( param );
|
||||
|
||||
param = new Parameter();
|
||||
param.setName( "indentSize" );
|
||||
param.setType( "int" );
|
||||
param.setDescription( "The number of spaces per indentation level, should be positive." );
|
||||
param.setDefaultValue( "2" );
|
||||
param.setExpression( "${indentSize}" );
|
||||
descriptor.addParameter( param );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
|
|
@ -204,7 +202,7 @@ public class PluginHelpGenerator
|
|||
/**
|
||||
* Find the best package name, based on the number of hits of actual Mojo classes.
|
||||
*
|
||||
* @param pluginDescriptor
|
||||
* @param pluginDescriptor not null
|
||||
* @return the best name of the package for the generated mojo
|
||||
*/
|
||||
private static String discoverPackageName( PluginDescriptor pluginDescriptor )
|
||||
|
|
@ -253,9 +251,9 @@ public class PluginHelpGenerator
|
|||
/**
|
||||
* Generates the <code>HelpMojo</code> class.
|
||||
*
|
||||
* @param writer
|
||||
* @param pluginDescriptor
|
||||
* @param helpDescriptor
|
||||
* @param writer not null
|
||||
* @param pluginDescriptor not null
|
||||
* @param helpDescriptor not null
|
||||
* @throws IOException if any
|
||||
*/
|
||||
private static void writeClass( Writer writer, PluginDescriptor pluginDescriptor, MojoDescriptor helpDescriptor )
|
||||
|
|
@ -296,6 +294,10 @@ public class PluginHelpGenerator
|
|||
writer.write( "}" + LS );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param writer not null
|
||||
* @throws IOException if any
|
||||
*/
|
||||
private static void writeImports( Writer writer )
|
||||
throws IOException
|
||||
{
|
||||
|
|
@ -307,6 +309,12 @@ public class PluginHelpGenerator
|
|||
writer.write( "import org.apache.maven.plugin.MojoExecutionException;" + LS );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param writer not null
|
||||
* @param pluginDescriptor not null
|
||||
* @param helpDescriptor not null
|
||||
* @throws IOException if any
|
||||
*/
|
||||
private static void writeMojoJavadoc( Writer writer, PluginDescriptor pluginDescriptor,
|
||||
MojoDescriptor helpDescriptor )
|
||||
throws IOException
|
||||
|
|
@ -342,6 +350,11 @@ public class PluginHelpGenerator
|
|||
writer.write( " */" + LS );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param writer not null
|
||||
* @param helpDescriptor not null
|
||||
* @throws IOException if any
|
||||
*/
|
||||
private static void writeVariables( Writer writer, MojoDescriptor helpDescriptor )
|
||||
throws IOException
|
||||
{
|
||||
|
|
@ -371,6 +384,12 @@ public class PluginHelpGenerator
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param writer not null
|
||||
* @param pluginDescriptor not null
|
||||
* @param helpDescriptor not null
|
||||
* @throws IOException if any
|
||||
*/
|
||||
private static void writeExecute( Writer writer, PluginDescriptor pluginDescriptor, MojoDescriptor helpDescriptor )
|
||||
throws IOException
|
||||
{
|
||||
|
|
@ -396,12 +415,14 @@ public class PluginHelpGenerator
|
|||
|
||||
writer.write( " if ( lineLength <= 0 )" + LS );
|
||||
writer.write( " {" + LS );
|
||||
writer.write( " getLog().warn( \"The parameter 'lineLength' should be positive, using '80' as default.\" );" + LS );
|
||||
writer.write( " getLog().warn( \"The parameter 'lineLength' should be positive, using '80' as "
|
||||
+ "default.\" );" + LS );
|
||||
writer.write( " lineLength = 80;" + LS );
|
||||
writer.write( " }" + LS );
|
||||
writer.write( " if ( indentSize <= 0 )" + LS );
|
||||
writer.write( " {" + LS );
|
||||
writer.write( " getLog().warn( \"The parameter 'indentSize' should be positive, using '2' as default.\" );" + LS );
|
||||
writer.write( " getLog().warn( \"The parameter 'indentSize' should be positive, using '2' as "
|
||||
+ "default.\" );" + LS );
|
||||
writer.write( " indentSize = 2;" + LS );
|
||||
writer.write( " }" + LS );
|
||||
writer.write( LS );
|
||||
|
|
@ -416,7 +437,8 @@ public class PluginHelpGenerator
|
|||
writer.write( " append( sb, \""
|
||||
+ StringUtils.escape( pluginDescriptor.getName() + " " + pluginDescriptor.getVersion() )
|
||||
+ "\", 0 );" + LS );
|
||||
writer.write( " append( sb, \"" + toDescription( pluginDescriptor.getDescription() ) + "\", 1 );" + LS );
|
||||
writer.write( " append( sb, \"" + toDescription( pluginDescriptor.getDescription() ) + "\", 1 );"
|
||||
+ LS );
|
||||
writer.write( " append( sb, \"\", 0 );" + LS );
|
||||
writer.write( LS );
|
||||
|
||||
|
|
@ -443,6 +465,11 @@ public class PluginHelpGenerator
|
|||
writer.write( " }" + LS );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param writer not null
|
||||
* @param descriptor not null
|
||||
* @throws IOException if any
|
||||
*/
|
||||
private static void writeGoal( Writer writer, MojoDescriptor descriptor )
|
||||
throws IOException
|
||||
{
|
||||
|
|
@ -495,6 +522,11 @@ public class PluginHelpGenerator
|
|||
writer.write( LS );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param writer not null
|
||||
* @param parameter not null
|
||||
* @throws IOException if any
|
||||
*/
|
||||
private static void writeParameter( Writer writer, Parameter parameter )
|
||||
throws IOException
|
||||
{
|
||||
|
|
@ -520,6 +552,10 @@ public class PluginHelpGenerator
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param writer not null
|
||||
* @throws IOException if any
|
||||
*/
|
||||
private static void writeUtilities( Writer writer )
|
||||
throws IOException
|
||||
{
|
||||
|
|
@ -546,7 +582,8 @@ public class PluginHelpGenerator
|
|||
|
||||
writer.write( LS );
|
||||
writer.write( " /** " + LS );
|
||||
writer.write( " * Append a description to the buffer by respecting the indentSize and lineLength parameters." + LS );
|
||||
writer.write( " * Append a description to the buffer by respecting the indentSize and lineLength "
|
||||
+ "parameters." + LS );
|
||||
writer.write( " * <b>Note</b>: The last character is always a new line." + LS );
|
||||
writer.write( " * " + LS );
|
||||
writer.write( " * @param sb The buffer to append the description, not <code>null</code>." + LS );
|
||||
|
|
@ -555,7 +592,8 @@ public class PluginHelpGenerator
|
|||
writer.write( " */" + LS );
|
||||
writer.write( " private void append( StringBuffer sb, String description, int indent )" + LS );
|
||||
writer.write( " {" + LS );
|
||||
writer.write( " for ( Iterator it = toLines( description, indent, indentSize, lineLength ).iterator(); it.hasNext(); )" + LS );
|
||||
writer.write( " for ( Iterator it = toLines( description, indent, indentSize, lineLength )"
|
||||
+ ".iterator(); it.hasNext(); )" + LS );
|
||||
writer.write( " {" + LS );
|
||||
writer.write( " sb.append( it.next().toString() ).append( '\\n' );" + LS );
|
||||
writer.write( " }" + LS );
|
||||
|
|
@ -572,7 +610,8 @@ public class PluginHelpGenerator
|
|||
writer.write( " * @return The sequence of display lines, never <code>null</code>." + LS );
|
||||
writer.write( " * @throws NegativeArraySizeException if <code>indent < 0</code>" + LS );
|
||||
writer.write( " */" + LS );
|
||||
writer.write( " private static List toLines( String text, int indent, int indentSize, int lineLength )" + LS );
|
||||
writer.write( " private static List toLines( String text, int indent, int indentSize, int lineLength )"
|
||||
+ LS );
|
||||
writer.write( " {" + LS );
|
||||
writer.write( " List lines = new ArrayList();" + LS );
|
||||
writer.write( LS );
|
||||
|
|
@ -588,14 +627,16 @@ public class PluginHelpGenerator
|
|||
|
||||
writer.write( LS );
|
||||
writer.write( " /** " + LS );
|
||||
writer.write( " * Adds the specified line to the output sequence, performing line wrapping if necessary." + LS );
|
||||
writer.write( " * Adds the specified line to the output sequence, performing line wrapping if necessary."
|
||||
+ LS );
|
||||
writer.write( " * " + LS );
|
||||
writer.write( " * @param lines The sequence of display lines, must not be <code>null</code>." + LS );
|
||||
writer.write( " * @param line The line to add, must not be <code>null</code>." + LS );
|
||||
writer.write( " * @param indentSize The size of each indentation, must not be negative." + LS );
|
||||
writer.write( " * @param lineLength The length of the line, must not be negative." + LS );
|
||||
writer.write( " */" + LS );
|
||||
writer.write( " private static void toLines( List lines, String line, int indentSize, int lineLength )" + LS );
|
||||
writer.write( " private static void toLines( List lines, String line, int indentSize, int lineLength )"
|
||||
+ LS );
|
||||
writer.write( " {" + LS );
|
||||
writer.write( " int lineIndent = getIndentLevel( line );" + LS );
|
||||
writer.write( " StringBuffer buf = new StringBuffer( 256 );" + LS );
|
||||
|
|
@ -621,7 +662,8 @@ public class PluginHelpGenerator
|
|||
writer.write( " char c = token.charAt( j );" + LS );
|
||||
writer.write( " if ( c == '\\t' )" + LS );
|
||||
writer.write( " {" + LS );
|
||||
writer.write( " buf.append( repeat( \" \", indentSize - buf.length() % indentSize ) );" + LS );
|
||||
writer.write( " buf.append( repeat( \" \", indentSize - buf.length() % indentSize ) );"
|
||||
+ LS );
|
||||
writer.write( " }" + LS );
|
||||
writer.write( " else if ( c == '\\u00A0' )" + LS );
|
||||
writer.write( " {" + LS );
|
||||
|
|
@ -640,7 +682,8 @@ public class PluginHelpGenerator
|
|||
writer.write( " /** " + LS );
|
||||
writer.write( " * Gets the indentation level of the specified line." + LS );
|
||||
writer.write( " * " + LS );
|
||||
writer.write( " * @param line The line whose indentation level should be retrieved, must not be <code>null</code>." + LS );
|
||||
writer.write( " * @param line The line whose indentation level should be retrieved, must not be "
|
||||
+ "<code>null</code>." + LS );
|
||||
writer.write( " * @return The indentation level of the line." + LS );
|
||||
writer.write( " */" + LS );
|
||||
writer.write( " private static int getIndentLevel( String line )" + LS );
|
||||
|
|
|
|||
|
|
@ -49,8 +49,10 @@ import org.codehaus.plexus.util.xml.XMLWriter;
|
|||
public class PluginXdocGenerator
|
||||
implements Generator
|
||||
{
|
||||
/** locale */
|
||||
private final Locale locale;
|
||||
|
||||
/** project */
|
||||
private final MavenProject project;
|
||||
|
||||
/**
|
||||
|
|
@ -75,6 +77,7 @@ public class PluginXdocGenerator
|
|||
}
|
||||
|
||||
/**
|
||||
* @param project not null.
|
||||
* @param locale not null wanted locale.
|
||||
*/
|
||||
public PluginXdocGenerator( MavenProject project, Locale locale )
|
||||
|
|
@ -99,11 +102,17 @@ public class PluginXdocGenerator
|
|||
for ( Iterator it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
|
||||
{
|
||||
MojoDescriptor descriptor = (MojoDescriptor) it.next();
|
||||
|
||||
processMojoDescriptor( descriptor, destinationDirectory );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mojoDescriptor not null
|
||||
* @param destinationDirectory not null
|
||||
* @throws IOException if any
|
||||
*/
|
||||
protected void processMojoDescriptor( MojoDescriptor mojoDescriptor, File destinationDirectory )
|
||||
throws IOException
|
||||
{
|
||||
|
|
@ -125,11 +134,20 @@ public class PluginXdocGenerator
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mojo not null
|
||||
* @param ext not null
|
||||
* @return the output file name
|
||||
*/
|
||||
private String getMojoFilename( MojoDescriptor mojo, String ext )
|
||||
{
|
||||
return mojo.getGoal() + "-mojo." + ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mojoDescriptor not null
|
||||
* @param w not null
|
||||
*/
|
||||
private void writeBody( MojoDescriptor mojoDescriptor, XMLWriter w )
|
||||
{
|
||||
w.startElement( "document" );
|
||||
|
|
@ -141,9 +159,7 @@ public class PluginXdocGenerator
|
|||
w.startElement( "properties" );
|
||||
|
||||
w.startElement( "title" );
|
||||
|
||||
w.writeText( mojoDescriptor.getFullGoalName() );
|
||||
|
||||
w.endElement(); // title
|
||||
|
||||
w.endElement(); // properties
|
||||
|
|
@ -204,6 +220,10 @@ public class PluginXdocGenerator
|
|||
w.endElement(); // document
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mojoDescriptor not null
|
||||
* @param w not null
|
||||
*/
|
||||
private void writeReportNotice( MojoDescriptor mojoDescriptor, XMLWriter w )
|
||||
{
|
||||
if ( PluginUtils.isMavenReport( mojoDescriptor.getImplementation(), project ) )
|
||||
|
|
@ -215,6 +235,10 @@ public class PluginXdocGenerator
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mojoDescriptor not null
|
||||
* @param w not null
|
||||
*/
|
||||
private void writeGoalAttributes( MojoDescriptor mojoDescriptor, XMLWriter w )
|
||||
{
|
||||
w.startElement( "p" );
|
||||
|
|
@ -308,9 +332,13 @@ public class PluginXdocGenerator
|
|||
w.endElement(); //li
|
||||
}
|
||||
|
||||
w.endElement();//ul
|
||||
w.endElement(); //ul
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mojoDescriptor not null
|
||||
* @param w not null
|
||||
*/
|
||||
private void writeGoalParameterTable( MojoDescriptor mojoDescriptor, XMLWriter w )
|
||||
{
|
||||
List parameterList = mojoDescriptor.getParameters();
|
||||
|
|
@ -337,6 +365,10 @@ public class PluginXdocGenerator
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parameterList not null
|
||||
* @return the parameters list without components.
|
||||
*/
|
||||
private List filterParameters( List parameterList )
|
||||
{
|
||||
List filtered = new ArrayList();
|
||||
|
|
@ -362,6 +394,11 @@ public class PluginXdocGenerator
|
|||
return filtered;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mojoDescriptor not null
|
||||
* @param parameterList not null
|
||||
* @param w not null
|
||||
*/
|
||||
private void writeParameterDetails( MojoDescriptor mojoDescriptor, List parameterList, XMLWriter w )
|
||||
{
|
||||
w.startElement( "subsection" );
|
||||
|
|
@ -406,24 +443,27 @@ public class PluginXdocGenerator
|
|||
{
|
||||
if ( StringUtils.isNotEmpty( mojoDescriptor.getSince() ) )
|
||||
{
|
||||
writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.since" ), mojoDescriptor.getSince(), w );
|
||||
writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.since" ),
|
||||
mojoDescriptor.getSince(), w );
|
||||
}
|
||||
}
|
||||
|
||||
if ( parameter.isRequired() )
|
||||
{
|
||||
writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.required" ), getString( "pluginxdoc.yes" ), w );
|
||||
writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.required" ),
|
||||
getString( "pluginxdoc.yes" ), w );
|
||||
}
|
||||
else
|
||||
{
|
||||
writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.required" ), getString( "pluginxdoc.no" ), w );
|
||||
writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.required" ),
|
||||
getString( "pluginxdoc.no" ), w );
|
||||
}
|
||||
|
||||
writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.expression" ), parameter.getExpression(), w );
|
||||
|
||||
writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.default" ), parameter.getDefaultValue(), w );
|
||||
|
||||
w.endElement();//ul
|
||||
w.endElement(); //ul
|
||||
|
||||
if ( parameters.hasNext() )
|
||||
{
|
||||
|
|
@ -434,6 +474,11 @@ public class PluginXdocGenerator
|
|||
w.endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param param not null
|
||||
* @param value could be null
|
||||
* @param w not null
|
||||
*/
|
||||
private void writeDetail( String param, String value, XMLWriter w )
|
||||
{
|
||||
if ( StringUtils.isNotEmpty( value ) )
|
||||
|
|
@ -444,21 +489,34 @@ public class PluginXdocGenerator
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mojoDescriptor not null
|
||||
* @param parameterList not null
|
||||
* @param w not null
|
||||
*/
|
||||
private void writeParameterSummary( MojoDescriptor mojoDescriptor, List parameterList, XMLWriter w )
|
||||
{
|
||||
List requiredParams = getParametersByRequired( true, parameterList );
|
||||
if ( requiredParams.size() > 0 )
|
||||
{
|
||||
writeParameterList( mojoDescriptor, getString( "pluginxdoc.mojodescriptor.requiredParameters" ), requiredParams, w );
|
||||
writeParameterList( mojoDescriptor, getString( "pluginxdoc.mojodescriptor.requiredParameters" ),
|
||||
requiredParams, w );
|
||||
}
|
||||
|
||||
List optionalParams = getParametersByRequired( false, parameterList );
|
||||
if ( optionalParams.size() > 0 )
|
||||
{
|
||||
writeParameterList( mojoDescriptor, getString( "pluginxdoc.mojodescriptor.optionalParameters" ), optionalParams, w );
|
||||
writeParameterList( mojoDescriptor, getString( "pluginxdoc.mojodescriptor.optionalParameters" ),
|
||||
optionalParams, w );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mojoDescriptor not null
|
||||
* @param title not null
|
||||
* @param parameterList not null
|
||||
* @param w not null
|
||||
*/
|
||||
private void writeParameterList( MojoDescriptor mojoDescriptor, String title, List parameterList, XMLWriter w )
|
||||
{
|
||||
w.startElement( "subsection" );
|
||||
|
|
@ -471,17 +529,17 @@ public class PluginXdocGenerator
|
|||
w.startElement( "tr" );
|
||||
w.startElement( "th" );
|
||||
w.writeText( getString( "pluginxdoc.mojodescriptor.parameter.name" ) );
|
||||
w.endElement();//th
|
||||
w.endElement(); //th
|
||||
w.startElement( "th" );
|
||||
w.writeText( getString( "pluginxdoc.mojodescriptor.parameter.type" ) );
|
||||
w.endElement();//th
|
||||
w.endElement(); //th
|
||||
w.startElement( "th" );
|
||||
w.writeText( getString( "pluginxdoc.mojodescriptor.parameter.since" ) );
|
||||
w.endElement();//th
|
||||
w.endElement(); //th
|
||||
w.startElement( "th" );
|
||||
w.writeText( getString( "pluginxdoc.mojodescriptor.parameter.description" ) );
|
||||
w.endElement();//th
|
||||
w.endElement();//tr
|
||||
w.endElement(); //th
|
||||
w.endElement(); //tr
|
||||
|
||||
for ( Iterator parameters = parameterList.iterator(); parameters.hasNext(); )
|
||||
{
|
||||
|
|
@ -490,11 +548,11 @@ public class PluginXdocGenerator
|
|||
w.startElement( "tr" );
|
||||
w.startElement( "td" );
|
||||
w.writeMarkup( format( "pluginxdoc.mojodescriptor.parameter.name_link", parameter.getName() ) );
|
||||
w.endElement();//td
|
||||
w.endElement(); //td
|
||||
w.startElement( "td" );
|
||||
int index = parameter.getType().lastIndexOf( "." );
|
||||
w.writeMarkup( "<code>" + parameter.getType().substring( index + 1 ) + "</code>" );
|
||||
w.endElement();//td
|
||||
w.endElement(); //td
|
||||
w.startElement( "td" );
|
||||
if ( StringUtils.isNotEmpty( parameter.getSince() ) )
|
||||
{
|
||||
|
|
@ -511,7 +569,7 @@ public class PluginXdocGenerator
|
|||
w.writeMarkup( "<code>-</code>" );
|
||||
}
|
||||
}
|
||||
w.endElement();//td
|
||||
w.endElement(); //td
|
||||
w.startElement( "td" );
|
||||
String description;
|
||||
if ( StringUtils.isNotEmpty( parameter.getDeprecated() ) )
|
||||
|
|
@ -532,16 +590,22 @@ public class PluginXdocGenerator
|
|||
|
||||
if ( StringUtils.isNotEmpty( parameter.getDefaultValue() ) )
|
||||
{
|
||||
w.writeMarkup( format( "pluginxdoc.mojodescriptor.parameter.defaultValue", parameter.getDefaultValue() ) );
|
||||
w.writeMarkup( format( "pluginxdoc.mojodescriptor.parameter.defaultValue",
|
||||
parameter.getDefaultValue() ) );
|
||||
}
|
||||
w.endElement();//td
|
||||
w.endElement(); //td
|
||||
w.endElement(); //tr
|
||||
}
|
||||
|
||||
w.endElement();//table
|
||||
w.endElement();//section
|
||||
w.endElement(); //table
|
||||
w.endElement(); //section
|
||||
}
|
||||
|
||||
/**
|
||||
* @param required <code>true</code> for required parameters, <code>false</code> otherwise.
|
||||
* @param parameterList not null
|
||||
* @return list of parameters depending the value of <code>required</code>
|
||||
*/
|
||||
private List getParametersByRequired( boolean required, List parameterList )
|
||||
{
|
||||
List list = new ArrayList();
|
||||
|
|
|
|||
|
|
@ -50,6 +50,11 @@ public class DefaultMojoScanner
|
|||
*/
|
||||
private Set/* <String> */activeExtractors;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*
|
||||
* @param extractors not null
|
||||
*/
|
||||
public DefaultMojoScanner( Map extractors )
|
||||
{
|
||||
this.mojoDescriptorExtractors = extractors;
|
||||
|
|
@ -57,8 +62,12 @@ public class DefaultMojoScanner
|
|||
this.enableLogging( new ConsoleLogger( Logger.LEVEL_INFO, "standalone-scanner-logger" ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
public DefaultMojoScanner()
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
@ -66,13 +75,13 @@ public class DefaultMojoScanner
|
|||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
Logger logger = getLogger();
|
||||
Set activeExtractors = getActiveExtractors();
|
||||
Set activeExtractorsInternal = getActiveExtractors();
|
||||
|
||||
logger.info( "Using " + activeExtractors.size() + " extractors." );
|
||||
logger.info( "Using " + activeExtractorsInternal.size() + " extractors." );
|
||||
|
||||
int numMojoDescriptors = 0;
|
||||
|
||||
for ( Iterator it = activeExtractors.iterator(); it.hasNext(); )
|
||||
for ( Iterator it = activeExtractorsInternal.iterator(); it.hasNext(); )
|
||||
{
|
||||
String language = (String) it.next();
|
||||
MojoDescriptorExtractor extractor = (MojoDescriptorExtractor) mojoDescriptorExtractors.get( language );
|
||||
|
|
@ -86,8 +95,8 @@ public class DefaultMojoScanner
|
|||
|
||||
List extractorDescriptors = extractor.execute( project, pluginDescriptor );
|
||||
|
||||
logger.info( "Extractor for language: " + language + " found " + extractorDescriptors.size() +
|
||||
" mojo descriptors." );
|
||||
logger.info( "Extractor for language: " + language + " found " + extractorDescriptors.size()
|
||||
+ " mojo descriptors." );
|
||||
numMojoDescriptors += extractorDescriptors.size();
|
||||
|
||||
for ( Iterator descriptorIt = extractorDescriptors.iterator(); descriptorIt.hasNext(); )
|
||||
|
|
@ -104,21 +113,25 @@ public class DefaultMojoScanner
|
|||
|
||||
if ( numMojoDescriptors == 0 )
|
||||
{
|
||||
//MPLUGIN-102. Restore the old functionality and allow a deprecation period
|
||||
//throw new InvalidPluginDescriptorException( "No mojo descriptors were found in this project." );
|
||||
for (int i= 0; i < 10; i++)
|
||||
// MPLUGIN-102. Restore the old functionality and allow a deprecation period
|
||||
// throw new InvalidPluginDescriptorException( "No mojo descriptors were found in this project." );
|
||||
for ( int i = 0; i < 10; i++ )
|
||||
{
|
||||
logger.warn("");
|
||||
logger.warn( "" );
|
||||
}
|
||||
logger.warn("*******************************************************");
|
||||
logger.warn("Deprecation Alert:");
|
||||
logger.warn("No mojo descriptors were found in this project which has a packaging type of maven-plugin.");
|
||||
logger.warn("In future versions of the plugin tools, this will fail the build.");
|
||||
logger.warn("If this project is an archetype, change the packaging type from maven-plugin to maven-archetype.");
|
||||
logger.warn("********************************************************");
|
||||
for (int i= 0; i < 10; i++)
|
||||
|
||||
logger.warn( "*******************************************************" );
|
||||
logger.warn( "Deprecation Alert:" );
|
||||
logger.warn( "No mojo descriptors were found in this project which has a packaging type of "
|
||||
+ "maven-plugin." );
|
||||
logger.warn( "In future versions of the plugin tools, this will fail the build." );
|
||||
logger.warn( "If this project is an archetype, change the packaging type from maven-plugin to "
|
||||
+ "maven-archetype." );
|
||||
logger.warn( "********************************************************" );
|
||||
|
||||
for ( int i = 0; i < 10; i++ )
|
||||
{
|
||||
logger.warn("");
|
||||
logger.warn( "" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -140,9 +153,7 @@ public class DefaultMojoScanner
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.tools.plugin.scanner.MojoScanner#setActiveExtractors(java.util.Set)
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
public void setActiveExtractors( Set/* <String> */extractors )
|
||||
{
|
||||
if ( extractors == null )
|
||||
|
|
|
|||
|
|
@ -36,11 +36,10 @@ public interface MojoScanner
|
|||
String ROLE = MojoScanner.class.getName();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param project
|
||||
* @param pluginDescriptor
|
||||
* @throws ExtractionException
|
||||
* @throws InvalidPluginDescriptorException
|
||||
* @param project not null
|
||||
* @param pluginDescriptor not null
|
||||
* @throws ExtractionException if any
|
||||
* @throws InvalidPluginDescriptorException if any
|
||||
*/
|
||||
void populatePluginDescriptor( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||
throws ExtractionException, InvalidPluginDescriptorException;
|
||||
|
|
@ -52,8 +51,8 @@ public interface MojoScanner
|
|||
* Only the specified extractors will be used, all others will be skipped.
|
||||
*
|
||||
* @param extractors The names of the sctive extractors. If this parameter is <code>null</code>,
|
||||
* all the scanner's extractors are considered active. Set entries that are
|
||||
* <code>null</code> or empty ("") will be ignored.
|
||||
* all the scanner's extractors are considered active. Set entries that are <code>null</code> or
|
||||
* empty ("") will be ignored.
|
||||
*/
|
||||
void setActiveExtractors( Set/* <String> */extractors );
|
||||
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ public final class PluginUtils
|
|||
}
|
||||
|
||||
/**
|
||||
* @param basedir
|
||||
* @param include
|
||||
* @param basedir not null
|
||||
* @param include not null
|
||||
* @return list of included files with default SCM excluded files
|
||||
*/
|
||||
public static String[] findSources( String basedir, String include )
|
||||
|
|
@ -81,9 +81,9 @@ public final class PluginUtils
|
|||
}
|
||||
|
||||
/**
|
||||
* @param basedir
|
||||
* @param include
|
||||
* @param exclude
|
||||
* @param basedir not null
|
||||
* @param include not null
|
||||
* @param exclude could be null
|
||||
* @return list of included files
|
||||
*/
|
||||
public static String[] findSources( String basedir, String include, String exclude )
|
||||
|
|
@ -160,8 +160,8 @@ public final class PluginUtils
|
|||
|
||||
/**
|
||||
* @param w not null writer
|
||||
* @param name
|
||||
* @param value
|
||||
* @param name not null
|
||||
* @param value could be null
|
||||
*/
|
||||
public static void element( XMLWriter w, String name, String value )
|
||||
{
|
||||
|
|
@ -185,6 +185,7 @@ public final class PluginUtils
|
|||
* @throws IllegalArgumentException if any
|
||||
*/
|
||||
public static boolean isMavenReport( String impl, MavenProject project )
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
if ( impl == null )
|
||||
{
|
||||
|
|
@ -273,7 +274,7 @@ public final class PluginUtils
|
|||
{
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream( commentCleaned.length() + 256 );
|
||||
tidy.parse( new ByteArrayInputStream( commentCleaned.getBytes( "UTF-8" ) ), out );
|
||||
commentCleaned = out.toString("UTF-8");
|
||||
commentCleaned = out.toString( "UTF-8" );
|
||||
}
|
||||
catch ( UnsupportedEncodingException e )
|
||||
{
|
||||
|
|
@ -286,9 +287,9 @@ public final class PluginUtils
|
|||
}
|
||||
|
||||
// strip the header/body stuff
|
||||
String LS = System.getProperty( "line.separator" );
|
||||
int startPos = commentCleaned.indexOf( "<body>" + LS ) + 6 + LS.length();
|
||||
int endPos = commentCleaned.indexOf( LS + "</body>" );
|
||||
String ls = System.getProperty( "line.separator" );
|
||||
int startPos = commentCleaned.indexOf( "<body>" + ls ) + 6 + ls.length();
|
||||
int endPos = commentCleaned.indexOf( ls + "</body>" );
|
||||
commentCleaned = commentCleaned.substring( startPos, endPos );
|
||||
|
||||
return commentCleaned;
|
||||
|
|
@ -325,29 +326,29 @@ public final class PluginUtils
|
|||
else if ( "link".equals( tag ) || "linkplain".equals( tag ) || "value".equals( tag ) )
|
||||
{
|
||||
String pattern = "(([^#\\.\\s]+\\.)*([^#\\.\\s]+))?" + "(#([^\\(\\s]*)(\\([^\\)]*\\))?\\s*(\\S.*)?)?";
|
||||
final int LABEL = 7;
|
||||
final int CLASS = 3;
|
||||
final int MEMBER = 5;
|
||||
final int ARGS = 6;
|
||||
final int label = 7;
|
||||
final int clazz = 3;
|
||||
final int member = 5;
|
||||
final int args = 6;
|
||||
Matcher link = Pattern.compile( pattern ).matcher( text );
|
||||
if ( link.matches() )
|
||||
{
|
||||
text = link.group( LABEL );
|
||||
text = link.group( label );
|
||||
if ( StringUtils.isEmpty( text ) )
|
||||
{
|
||||
text = link.group( CLASS );
|
||||
text = link.group( clazz );
|
||||
if ( StringUtils.isEmpty( text ) )
|
||||
{
|
||||
text = "";
|
||||
}
|
||||
if ( StringUtils.isNotEmpty( link.group( MEMBER ) ) )
|
||||
if ( StringUtils.isNotEmpty( link.group( member ) ) )
|
||||
{
|
||||
if ( StringUtils.isNotEmpty( text ) )
|
||||
{
|
||||
text += '.';
|
||||
}
|
||||
text += link.group( MEMBER );
|
||||
if ( StringUtils.isNotEmpty( link.group( ARGS ) ) )
|
||||
text += link.group( member );
|
||||
if ( StringUtils.isNotEmpty( link.group( args ) ) )
|
||||
{
|
||||
text += "()";
|
||||
}
|
||||
|
|
@ -381,7 +382,10 @@ public final class PluginUtils
|
|||
private static String quoteReplacement( String s )
|
||||
{
|
||||
if ( ( s.indexOf( '\\' ) == -1 ) && ( s.indexOf( '$' ) == -1 ) )
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for ( int i = 0; i < s.length(); i++ )
|
||||
{
|
||||
|
|
@ -401,6 +405,7 @@ public final class PluginUtils
|
|||
sb.append( c );
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
|
@ -415,7 +420,7 @@ public final class PluginUtils
|
|||
{
|
||||
Collections.sort( mojoDescriptors, new Comparator()
|
||||
{
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public int compare( Object arg0, Object arg1 )
|
||||
{
|
||||
MojoDescriptor mojo0 = (MojoDescriptor) arg0;
|
||||
|
|
@ -454,228 +459,7 @@ public final class PluginUtils
|
|||
final StringBuffer sb = new StringBuffer();
|
||||
|
||||
HTMLEditorKit.Parser parser = new ParserDelegator();
|
||||
HTMLEditorKit.ParserCallback htmlCallback = new HTMLEditorKit.ParserCallback()
|
||||
{
|
||||
/**
|
||||
* Holds the index of the current item in a numbered list.
|
||||
*/
|
||||
class Counter
|
||||
{
|
||||
public int value;
|
||||
}
|
||||
|
||||
/**
|
||||
* A flag whether the parser is currently in the body element.
|
||||
*/
|
||||
private boolean body;
|
||||
|
||||
/**
|
||||
* A flag whether the parser is currently processing preformatted text, actually a counter to track nesting.
|
||||
*/
|
||||
private int preformatted;
|
||||
|
||||
/**
|
||||
* The current indentation depth for the output.
|
||||
*/
|
||||
private int depth;
|
||||
|
||||
/**
|
||||
* A stack of {@link Counter} objects corresponding to the nesting of (un-)ordered lists. A
|
||||
* <code>null</code> element denotes an unordered list.
|
||||
*/
|
||||
private Stack numbering = new Stack();
|
||||
|
||||
/**
|
||||
* A flag whether an implicit line break is pending in the output buffer. This flag is used to postpone the
|
||||
* output of implicit line breaks until we are sure that are not to be merged with other implicit line
|
||||
* breaks.
|
||||
*/
|
||||
private boolean pendingNewline;
|
||||
|
||||
/**
|
||||
* A flag whether we have just parsed a simple tag.
|
||||
*/
|
||||
private boolean simpleTag;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void handleSimpleTag( HTML.Tag t, MutableAttributeSet a, int pos )
|
||||
{
|
||||
simpleTag = true;
|
||||
if ( body && HTML.Tag.BR.equals( t ) )
|
||||
{
|
||||
newline( false );
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void handleStartTag( HTML.Tag t, MutableAttributeSet a, int pos )
|
||||
{
|
||||
simpleTag = false;
|
||||
if ( body && ( t.breaksFlow() || t.isBlock() ) )
|
||||
{
|
||||
newline( true );
|
||||
}
|
||||
if ( HTML.Tag.OL.equals( t ) )
|
||||
{
|
||||
numbering.push( new Counter() );
|
||||
}
|
||||
else if ( HTML.Tag.UL.equals( t ) )
|
||||
{
|
||||
numbering.push( null );
|
||||
}
|
||||
else if ( HTML.Tag.LI.equals( t ) )
|
||||
{
|
||||
Counter counter = (Counter) numbering.peek();
|
||||
if ( counter == null )
|
||||
{
|
||||
text( "-\t" );
|
||||
}
|
||||
else
|
||||
{
|
||||
text( ++counter.value + ".\t" );
|
||||
}
|
||||
depth++;
|
||||
}
|
||||
else if ( HTML.Tag.DD.equals( t ) )
|
||||
{
|
||||
depth++;
|
||||
}
|
||||
else if ( t.isPreformatted() )
|
||||
{
|
||||
preformatted++;
|
||||
}
|
||||
else if ( HTML.Tag.BODY.equals( t ) )
|
||||
{
|
||||
body = true;
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void handleEndTag( HTML.Tag t, int pos )
|
||||
{
|
||||
if ( HTML.Tag.OL.equals( t ) || HTML.Tag.UL.equals( t ) )
|
||||
{
|
||||
numbering.pop();
|
||||
}
|
||||
else if ( HTML.Tag.LI.equals( t ) || HTML.Tag.DD.equals( t ) )
|
||||
{
|
||||
depth--;
|
||||
}
|
||||
else if ( t.isPreformatted() )
|
||||
{
|
||||
preformatted--;
|
||||
}
|
||||
else if ( HTML.Tag.BODY.equals( t ) )
|
||||
{
|
||||
body = false;
|
||||
}
|
||||
if ( body && ( t.breaksFlow() || t.isBlock() ) && !HTML.Tag.LI.equals( t ) )
|
||||
{
|
||||
if ( ( HTML.Tag.P.equals( t ) || HTML.Tag.PRE.equals( t ) || HTML.Tag.OL.equals( t )
|
||||
|| HTML.Tag.UL.equals( t ) || HTML.Tag.DL.equals( t ) )
|
||||
&& numbering.isEmpty() )
|
||||
{
|
||||
newline( pendingNewline = false );
|
||||
}
|
||||
else
|
||||
{
|
||||
newline( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void handleText( char[] data, int pos )
|
||||
{
|
||||
/*
|
||||
* NOTE: Parsers before JRE 1.6 will parse XML-conform simple tags like <br/> as "<br>" followed by
|
||||
* the text event ">..." so we need to watch out for the closing angle bracket.
|
||||
*/
|
||||
int offset = 0;
|
||||
if ( simpleTag && data[0] == '>' )
|
||||
{
|
||||
simpleTag = false;
|
||||
for ( ++offset; offset < data.length && data[offset] <= ' '; )
|
||||
{
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
if ( offset < data.length )
|
||||
{
|
||||
String text = new String( data, offset, data.length - offset );
|
||||
text( text );
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void flush()
|
||||
{
|
||||
flushPendingNewline();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a line break to the plain text output.
|
||||
*
|
||||
* @param implicit A flag whether this is an explicit or implicit line break. Explicit line breaks are
|
||||
* always written to the output whereas consecutive implicit line breaks are merged into a single
|
||||
* line break.
|
||||
*/
|
||||
private void newline( boolean implicit )
|
||||
{
|
||||
if ( implicit )
|
||||
{
|
||||
pendingNewline = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flushPendingNewline();
|
||||
sb.append( '\n' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes a pending newline (if any).
|
||||
*/
|
||||
private void flushPendingNewline()
|
||||
{
|
||||
if ( pendingNewline )
|
||||
{
|
||||
pendingNewline = false;
|
||||
if ( sb.length() > 0 )
|
||||
{
|
||||
sb.append( '\n' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the specified character data to the plain text output. If the last output was a line break, the
|
||||
* character data will automatically be prefixed with the current indent.
|
||||
*
|
||||
* @param data The character data, must not be <code>null</code>.
|
||||
*/
|
||||
private void text( String data )
|
||||
{
|
||||
flushPendingNewline();
|
||||
if ( sb.length() <= 0 || sb.charAt( sb.length() - 1 ) == '\n' )
|
||||
{
|
||||
for ( int i = 0; i < depth; i++ )
|
||||
{
|
||||
sb.append( '\t' );
|
||||
}
|
||||
}
|
||||
String text;
|
||||
if ( preformatted > 0 )
|
||||
{
|
||||
text = data.replace( ' ', '\u00A0' );
|
||||
}
|
||||
else
|
||||
{
|
||||
text = data.replace( '\n', ' ' );
|
||||
}
|
||||
sb.append( text );
|
||||
}
|
||||
};
|
||||
HTMLEditorKit.ParserCallback htmlCallback = new MojoParserCallback( sb );
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -688,4 +472,245 @@ public final class PluginUtils
|
|||
|
||||
return sb.toString().replace( '\"', '\'' ); // for CDATA
|
||||
}
|
||||
|
||||
/**
|
||||
* ParserCallback implementation.
|
||||
*/
|
||||
private static class MojoParserCallback
|
||||
extends HTMLEditorKit.ParserCallback
|
||||
{
|
||||
/**
|
||||
* Holds the index of the current item in a numbered list.
|
||||
*/
|
||||
class Counter
|
||||
{
|
||||
public int value;
|
||||
}
|
||||
|
||||
/**
|
||||
* A flag whether the parser is currently in the body element.
|
||||
*/
|
||||
private boolean body;
|
||||
|
||||
/**
|
||||
* A flag whether the parser is currently processing preformatted text, actually a counter to track nesting.
|
||||
*/
|
||||
private int preformatted;
|
||||
|
||||
/**
|
||||
* The current indentation depth for the output.
|
||||
*/
|
||||
private int depth;
|
||||
|
||||
/**
|
||||
* A stack of {@link Counter} objects corresponding to the nesting of (un-)ordered lists. A
|
||||
* <code>null</code> element denotes an unordered list.
|
||||
*/
|
||||
private Stack numbering = new Stack();
|
||||
|
||||
/**
|
||||
* A flag whether an implicit line break is pending in the output buffer. This flag is used to postpone the
|
||||
* output of implicit line breaks until we are sure that are not to be merged with other implicit line
|
||||
* breaks.
|
||||
*/
|
||||
private boolean pendingNewline;
|
||||
|
||||
/**
|
||||
* A flag whether we have just parsed a simple tag.
|
||||
*/
|
||||
private boolean simpleTag;
|
||||
|
||||
/**
|
||||
* The current buffer.
|
||||
*/
|
||||
private final StringBuffer sb;
|
||||
|
||||
/**
|
||||
* @param sb not null
|
||||
*/
|
||||
public MojoParserCallback( StringBuffer sb )
|
||||
{
|
||||
this.sb = sb;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void handleSimpleTag( HTML.Tag t, MutableAttributeSet a, int pos )
|
||||
{
|
||||
simpleTag = true;
|
||||
if ( body && HTML.Tag.BR.equals( t ) )
|
||||
{
|
||||
newline( false );
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void handleStartTag( HTML.Tag t, MutableAttributeSet a, int pos )
|
||||
{
|
||||
simpleTag = false;
|
||||
if ( body && ( t.breaksFlow() || t.isBlock() ) )
|
||||
{
|
||||
newline( true );
|
||||
}
|
||||
if ( HTML.Tag.OL.equals( t ) )
|
||||
{
|
||||
numbering.push( new Counter() );
|
||||
}
|
||||
else if ( HTML.Tag.UL.equals( t ) )
|
||||
{
|
||||
numbering.push( null );
|
||||
}
|
||||
else if ( HTML.Tag.LI.equals( t ) )
|
||||
{
|
||||
Counter counter = (Counter) numbering.peek();
|
||||
if ( counter == null )
|
||||
{
|
||||
text( "-\t" );
|
||||
}
|
||||
else
|
||||
{
|
||||
text( ++counter.value + ".\t" );
|
||||
}
|
||||
depth++;
|
||||
}
|
||||
else if ( HTML.Tag.DD.equals( t ) )
|
||||
{
|
||||
depth++;
|
||||
}
|
||||
else if ( t.isPreformatted() )
|
||||
{
|
||||
preformatted++;
|
||||
}
|
||||
else if ( HTML.Tag.BODY.equals( t ) )
|
||||
{
|
||||
body = true;
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void handleEndTag( HTML.Tag t, int pos )
|
||||
{
|
||||
if ( HTML.Tag.OL.equals( t ) || HTML.Tag.UL.equals( t ) )
|
||||
{
|
||||
numbering.pop();
|
||||
}
|
||||
else if ( HTML.Tag.LI.equals( t ) || HTML.Tag.DD.equals( t ) )
|
||||
{
|
||||
depth--;
|
||||
}
|
||||
else if ( t.isPreformatted() )
|
||||
{
|
||||
preformatted--;
|
||||
}
|
||||
else if ( HTML.Tag.BODY.equals( t ) )
|
||||
{
|
||||
body = false;
|
||||
}
|
||||
if ( body && ( t.breaksFlow() || t.isBlock() ) && !HTML.Tag.LI.equals( t ) )
|
||||
{
|
||||
if ( ( HTML.Tag.P.equals( t ) || HTML.Tag.PRE.equals( t ) || HTML.Tag.OL.equals( t )
|
||||
|| HTML.Tag.UL.equals( t ) || HTML.Tag.DL.equals( t ) )
|
||||
&& numbering.isEmpty() )
|
||||
{
|
||||
pendingNewline = false;
|
||||
newline( pendingNewline );
|
||||
}
|
||||
else
|
||||
{
|
||||
newline( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void handleText( char[] data, int pos )
|
||||
{
|
||||
/*
|
||||
* NOTE: Parsers before JRE 1.6 will parse XML-conform simple tags like <br/> as "<br>" followed by
|
||||
* the text event ">..." so we need to watch out for the closing angle bracket.
|
||||
*/
|
||||
int offset = 0;
|
||||
if ( simpleTag && data[0] == '>' )
|
||||
{
|
||||
simpleTag = false;
|
||||
for ( ++offset; offset < data.length && data[offset] <= ' '; )
|
||||
{
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
if ( offset < data.length )
|
||||
{
|
||||
String text = new String( data, offset, data.length - offset );
|
||||
text( text );
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void flush()
|
||||
{
|
||||
flushPendingNewline();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a line break to the plain text output.
|
||||
*
|
||||
* @param implicit A flag whether this is an explicit or implicit line break. Explicit line breaks are
|
||||
* always written to the output whereas consecutive implicit line breaks are merged into a single
|
||||
* line break.
|
||||
*/
|
||||
private void newline( boolean implicit )
|
||||
{
|
||||
if ( implicit )
|
||||
{
|
||||
pendingNewline = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flushPendingNewline();
|
||||
sb.append( '\n' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes a pending newline (if any).
|
||||
*/
|
||||
private void flushPendingNewline()
|
||||
{
|
||||
if ( pendingNewline )
|
||||
{
|
||||
pendingNewline = false;
|
||||
if ( sb.length() > 0 )
|
||||
{
|
||||
sb.append( '\n' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the specified character data to the plain text output. If the last output was a line break, the
|
||||
* character data will automatically be prefixed with the current indent.
|
||||
*
|
||||
* @param data The character data, must not be <code>null</code>.
|
||||
*/
|
||||
private void text( String data )
|
||||
{
|
||||
flushPendingNewline();
|
||||
if ( sb.length() <= 0 || sb.charAt( sb.length() - 1 ) == '\n' )
|
||||
{
|
||||
for ( int i = 0; i < depth; i++ )
|
||||
{
|
||||
sb.append( '\t' );
|
||||
}
|
||||
}
|
||||
String text;
|
||||
if ( preformatted > 0 )
|
||||
{
|
||||
text = data.replace( ' ', '\u00A0' );
|
||||
}
|
||||
else
|
||||
{
|
||||
text = data.replace( '\n', ' ' );
|
||||
}
|
||||
sb.append( text );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue