All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.codehaus.mojo.apt.HelpMojo Maven / Gradle / Ivy

There is a newer version: 1.0-alpha-5
Show newest version
package org.codehaus.mojo.apt;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;

/**
 * Display help information on apt-maven-plugin.
Call
  mvn apt:help -Ddetail=true -Dgoal=<goal-name>
to display parameter details. * * @version generated on Thu Sep 16 16:45:02 BST 2010 * @author org.apache.maven.tools.plugin.generator.PluginHelpGenerator (version 2.6) * @goal help * @requiresProject false */ public class HelpMojo extends AbstractMojo { /** * If true, display all settable properties for each goal. * * @parameter expression="${detail}" default-value="false" */ private boolean detail; /** * The name of the goal for which to show help. If unspecified, all goals will be displayed. * * @parameter expression="${goal}" */ private java.lang.String goal; /** * The maximum length of a display line, should be positive. * * @parameter expression="${lineLength}" default-value="80" */ private int lineLength; /** * The number of spaces per indentation level, should be positive. * * @parameter expression="${indentSize}" default-value="2" */ private int indentSize; /** {@inheritDoc} */ public void execute() throws MojoExecutionException { if ( lineLength <= 0 ) { getLog().warn( "The parameter 'lineLength' should be positive, using '80' as default." ); lineLength = 80; } if ( indentSize <= 0 ) { getLog().warn( "The parameter 'indentSize' should be positive, using '2' as default." ); indentSize = 2; } StringBuffer sb = new StringBuffer(); append( sb, "org.codehaus.mojo:apt-maven-plugin:1.0-alpha-4", 0 ); append( sb, "", 0 ); append( sb, "Apt Maven Plugin", 0 ); append( sb, "Maven Plugin for Annotation Processing Tool (apt).", 1 ); append( sb, "", 0 ); if ( goal == null || goal.length() <= 0 ) { append( sb, "This plugin has 4 goals:", 0 ); append( sb, "", 0 ); } if ( goal == null || goal.length() <= 0 || "eclipse".equals( goal ) ) { append( sb, "apt:eclipse", 0 ); append( sb, "Generates Eclipse files for apt integration.", 1 ); append( sb, "", 0 ); if ( detail ) { append( sb, "Available parameters:", 1 ); append( sb, "", 0 ); append( sb, "additionalSourceRoots", 2 ); append( sb, "The source directories containing any additional sources to be processed.", 3 ); append( sb, "", 0 ); append( sb, "encoding (Default: ISO-8859-1)", 2 ); append( sb, "The source file encoding name, such as EUC-JP and UTF-8. If encoding is not specified, the encoding ISO-8859-1 is used rather than the platform default for reproducibility reasons. This is equivalent to the -encoding argument for apt.", 3 ); append( sb, "", 0 ); append( sb, "excludes", 2 ); append( sb, "A set of exclusion filters for apt.", 3 ); append( sb, "", 0 ); append( sb, "executable (Default: apt)", 2 ); append( sb, "The apt executable to use when forked.", 3 ); append( sb, "", 0 ); append( sb, "factory", 2 ); append( sb, "Name of AnnotationProcessorFactory to use; bypasses default discovery process. This is equivalent to the -factory argument for apt.", 3 ); append( sb, "", 0 ); append( sb, "force (Default: false)", 2 ); append( sb, "Force apt processing without staleness checking. When false, use outputFiles or outputFileEndings to control computing staleness.", 3 ); append( sb, "", 0 ); append( sb, "fork (Default: false)", 2 ); append( sb, "Whether to run apt in a separate process.", 3 ); append( sb, "", 0 ); append( sb, "includes", 2 ); append( sb, "A set of inclusion filters for apt. Default value is **/*.java.", 3 ); append( sb, "", 0 ); append( sb, "maxmem", 2 ); append( sb, "The maximum size of the memory allocation pool when forked, for example 128m.", 3 ); append( sb, "", 0 ); append( sb, "meminitial", 2 ); append( sb, "The initial size of the memory allocation pool when forked, for example 64m.", 3 ); append( sb, "", 0 ); append( sb, "options", 2 ); append( sb, "Options to pass to annotation processors. These are equivalent to multiple -A arguments for apt.", 3 ); append( sb, "", 0 ); append( sb, "outputDirectory (Default: ${project.build.directory}/generated-resources/apt)", 2 ); append( sb, "The directory to place processor and generated class files. This is equivalent to the -d argument for apt.", 3 ); append( sb, "", 0 ); append( sb, "outputFileEndings", 2 ); append( sb, "The filename endings of processor-generated files to examine when computing staleness. For example, .txt would specify that the processor creates a corresponding .txt file for every .java source file. Default value is .java. Note that this parameter has no effect if outputFiles is specified.", 3 ); append( sb, "", 0 ); append( sb, "outputFiles", 2 ); append( sb, "The filenames of processor-generated files to examine when computing staleness. For example, generated.xml would specify that the processor creates the aforementioned single file from all .java source files. When this parameter is not specified, outputFileEndings is used instead.", 3 ); append( sb, "", 0 ); append( sb, "resourceFiltering (Default: false)", 2 ); append( sb, "Whether resource filtering is enabled for processor-generated resources.", 3 ); append( sb, "", 0 ); append( sb, "resourceTargetPath", 2 ); append( sb, "The path for processor-generated resources.", 3 ); append( sb, "", 0 ); append( sb, "showWarnings (Default: false)", 2 ); append( sb, "Whether to show apt warnings. This is opposite to the -nowarn argument for apt.", 3 ); append( sb, "", 0 ); append( sb, "skip (Default: false)", 2 ); append( sb, "Whether to bypass running apt.", 3 ); append( sb, "", 0 ); append( sb, "sourceOutputDirectory (Default: ${project.build.directory}/generated-sources/apt)", 2 ); append( sb, "The directory root under which processor-generated source files will be placed; files are placed in subdirectories based on package namespace. This is equivalent to the -s argument for apt.", 3 ); append( sb, "", 0 ); append( sb, "staleMillis (Default: 0)", 2 ); append( sb, "Sets the granularity in milliseconds of the last modification date for testing whether a source needs processing.", 3 ); append( sb, "", 0 ); append( sb, "verbose (Default: false)", 2 ); append( sb, "Whether to output information about each class loaded and each source file processed. This is equivalent to the -verbose argument for apt.", 3 ); append( sb, "", 0 ); } } if ( goal == null || goal.length() <= 0 || "help".equals( goal ) ) { append( sb, "apt:help", 0 ); append( sb, "Display help information on apt-maven-plugin.\nCall\n\u00a0\u00a0mvn\u00a0apt:help\u00a0-Ddetail=true\u00a0-Dgoal=\nto display parameter details.", 1 ); append( sb, "", 0 ); if ( detail ) { append( sb, "Available parameters:", 1 ); append( sb, "", 0 ); append( sb, "detail (Default: false)", 2 ); append( sb, "If true, display all settable properties for each goal.", 3 ); append( sb, "", 0 ); append( sb, "goal", 2 ); append( sb, "The name of the goal for which to show help. If unspecified, all goals will be displayed.", 3 ); append( sb, "", 0 ); append( sb, "indentSize (Default: 2)", 2 ); append( sb, "The number of spaces per indentation level, should be positive.", 3 ); append( sb, "", 0 ); append( sb, "lineLength (Default: 80)", 2 ); append( sb, "The maximum length of a display line, should be positive.", 3 ); append( sb, "", 0 ); } } if ( goal == null || goal.length() <= 0 || "process".equals( goal ) ) { append( sb, "apt:process", 0 ); append( sb, "Executes apt on project sources.", 1 ); append( sb, "", 0 ); if ( detail ) { append( sb, "Available parameters:", 1 ); append( sb, "", 0 ); append( sb, "additionalSourceRoots", 2 ); append( sb, "The source directories containing any additional sources to be processed.", 3 ); append( sb, "", 0 ); append( sb, "encoding (Default: ISO-8859-1)", 2 ); append( sb, "The source file encoding name, such as EUC-JP and UTF-8. If encoding is not specified, the encoding ISO-8859-1 is used rather than the platform default for reproducibility reasons. This is equivalent to the -encoding argument for apt.", 3 ); append( sb, "", 0 ); append( sb, "excludes", 2 ); append( sb, "A set of exclusion filters for apt.", 3 ); append( sb, "", 0 ); append( sb, "executable (Default: apt)", 2 ); append( sb, "The apt executable to use when forked.", 3 ); append( sb, "", 0 ); append( sb, "factory", 2 ); append( sb, "Name of AnnotationProcessorFactory to use; bypasses default discovery process. This is equivalent to the -factory argument for apt.", 3 ); append( sb, "", 0 ); append( sb, "force (Default: false)", 2 ); append( sb, "Force apt processing without staleness checking. When false, use outputFiles or outputFileEndings to control computing staleness.", 3 ); append( sb, "", 0 ); append( sb, "fork (Default: false)", 2 ); append( sb, "Whether to run apt in a separate process.", 3 ); append( sb, "", 0 ); append( sb, "includes", 2 ); append( sb, "A set of inclusion filters for apt. Default value is **/*.java.", 3 ); append( sb, "", 0 ); append( sb, "maxmem", 2 ); append( sb, "The maximum size of the memory allocation pool when forked, for example 128m.", 3 ); append( sb, "", 0 ); append( sb, "meminitial", 2 ); append( sb, "The initial size of the memory allocation pool when forked, for example 64m.", 3 ); append( sb, "", 0 ); append( sb, "options", 2 ); append( sb, "Options to pass to annotation processors. These are equivalent to multiple -A arguments for apt.", 3 ); append( sb, "", 0 ); append( sb, "outputDirectory (Default: ${project.build.directory}/generated-resources/apt)", 2 ); append( sb, "The directory to place processor and generated class files. This is equivalent to the -d argument for apt.", 3 ); append( sb, "", 0 ); append( sb, "outputFileEndings", 2 ); append( sb, "The filename endings of processor-generated files to examine when computing staleness. For example, .txt would specify that the processor creates a corresponding .txt file for every .java source file. Default value is .java. Note that this parameter has no effect if outputFiles is specified.", 3 ); append( sb, "", 0 ); append( sb, "outputFiles", 2 ); append( sb, "The filenames of processor-generated files to examine when computing staleness. For example, generated.xml would specify that the processor creates the aforementioned single file from all .java source files. When this parameter is not specified, outputFileEndings is used instead.", 3 ); append( sb, "", 0 ); append( sb, "resourceFiltering (Default: false)", 2 ); append( sb, "Whether resource filtering is enabled for processor-generated resources.", 3 ); append( sb, "", 0 ); append( sb, "resourceTargetPath", 2 ); append( sb, "The path for processor-generated resources.", 3 ); append( sb, "", 0 ); append( sb, "showWarnings (Default: false)", 2 ); append( sb, "Whether to show apt warnings. This is opposite to the -nowarn argument for apt.", 3 ); append( sb, "", 0 ); append( sb, "skip (Default: false)", 2 ); append( sb, "Whether to bypass running apt.", 3 ); append( sb, "", 0 ); append( sb, "sourceOutputDirectory (Default: ${project.build.directory}/generated-sources/apt)", 2 ); append( sb, "The directory root under which processor-generated source files will be placed; files are placed in subdirectories based on package namespace. This is equivalent to the -s argument for apt.", 3 ); append( sb, "", 0 ); append( sb, "staleMillis (Default: 0)", 2 ); append( sb, "Sets the granularity in milliseconds of the last modification date for testing whether a source needs processing.", 3 ); append( sb, "", 0 ); append( sb, "verbose (Default: false)", 2 ); append( sb, "Whether to output information about each class loaded and each source file processed. This is equivalent to the -verbose argument for apt.", 3 ); append( sb, "", 0 ); } } if ( goal == null || goal.length() <= 0 || "test-process".equals( goal ) ) { append( sb, "apt:test-process", 0 ); append( sb, "Executes apt on project test sources.", 1 ); append( sb, "", 0 ); if ( detail ) { append( sb, "Available parameters:", 1 ); append( sb, "", 0 ); append( sb, "additionalSourceRoots", 2 ); append( sb, "The source directories containing any additional sources to be processed.", 3 ); append( sb, "", 0 ); append( sb, "encoding (Default: ISO-8859-1)", 2 ); append( sb, "The source file encoding name, such as EUC-JP and UTF-8. If encoding is not specified, the encoding ISO-8859-1 is used rather than the platform default for reproducibility reasons. This is equivalent to the -encoding argument for apt.", 3 ); append( sb, "", 0 ); append( sb, "excludes", 2 ); append( sb, "A list of exclusion filters for apt.", 3 ); append( sb, "", 0 ); append( sb, "executable (Default: apt)", 2 ); append( sb, "The apt executable to use when forked.", 3 ); append( sb, "", 0 ); append( sb, "factory", 2 ); append( sb, "Name of AnnotationProcessorFactory to use; bypasses default discovery process. This is equivalent to the -factory argument for apt.", 3 ); append( sb, "", 0 ); append( sb, "force (Default: false)", 2 ); append( sb, "Force apt processing without staleness checking. When false, use outputFiles or outputFileEndings to control computing staleness.", 3 ); append( sb, "", 0 ); append( sb, "fork (Default: false)", 2 ); append( sb, "Whether to run apt in a separate process.", 3 ); append( sb, "", 0 ); append( sb, "includes", 2 ); append( sb, "A list of inclusion filters for apt. Default value is **/*.java.", 3 ); append( sb, "", 0 ); append( sb, "maxmem", 2 ); append( sb, "The maximum size of the memory allocation pool when forked, for example 128m.", 3 ); append( sb, "", 0 ); append( sb, "meminitial", 2 ); append( sb, "The initial size of the memory allocation pool when forked, for example 64m.", 3 ); append( sb, "", 0 ); append( sb, "options", 2 ); append( sb, "Options to pass to annotation processors. These are equivalent to multiple -A arguments for apt.", 3 ); append( sb, "", 0 ); append( sb, "outputFileEndings", 2 ); append( sb, "The filename endings of processor-generated files to examine when computing staleness. For example, .txt would specify that the processor creates a corresponding .txt file for every .java source file. Default value is .java. Note that this parameter has no effect if outputFiles is specified.", 3 ); append( sb, "", 0 ); append( sb, "outputFiles", 2 ); append( sb, "The filenames of processor-generated files to examine when computing staleness. For example, generated.xml would specify that the processor creates the aforementioned single file from all .java source files. When this parameter is not specified, outputFileEndings is used instead.", 3 ); append( sb, "", 0 ); append( sb, "resourceFiltering (Default: false)", 2 ); append( sb, "Whether resource filtering is enabled for processor-generated resources.", 3 ); append( sb, "", 0 ); append( sb, "resourceTargetPath", 2 ); append( sb, "The path for processor-generated resources.", 3 ); append( sb, "", 0 ); append( sb, "showWarnings (Default: false)", 2 ); append( sb, "Whether to show apt warnings. This is opposite to the -nowarn argument for apt.", 3 ); append( sb, "", 0 ); append( sb, "skip (Default: false)", 2 ); append( sb, "Whether to bypass running apt.", 3 ); append( sb, "", 0 ); append( sb, "staleMillis (Default: 0)", 2 ); append( sb, "Sets the granularity in milliseconds of the last modification date for testing whether a source needs processing.", 3 ); append( sb, "", 0 ); append( sb, "testOutputDirectory (Default: ${project.build.directory}/generated-test-resources/apt)", 2 ); append( sb, "The directory to place processor and generated class files. This is equivalent to the -d argument for apt.", 3 ); append( sb, "", 0 ); append( sb, "testSourceOutputDirectory (Default: ${project.build.directory}/generated-test-sources/apt)", 2 ); append( sb, "The directory root under which processor-generated test source files will be placed; files are placed in subdirectories based on package namespace. This is equivalent to the -s argument for apt.", 3 ); append( sb, "", 0 ); append( sb, "verbose (Default: false)", 2 ); append( sb, "Whether to output information about each class loaded and each source file processed. This is equivalent to the -verbose argument for apt.", 3 ); append( sb, "", 0 ); } } if ( getLog().isInfoEnabled() ) { getLog().info( sb.toString() ); } } /** *

Repeat a String n times to form a new string.

* * @param str String to repeat * @param repeat number of times to repeat str * @return String with repeated String * @throws NegativeArraySizeException if repeat < 0 * @throws NullPointerException if str is null */ private static String repeat( String str, int repeat ) { StringBuffer buffer = new StringBuffer( repeat * str.length() ); for ( int i = 0; i < repeat; i++ ) { buffer.append( str ); } return buffer.toString(); } /** * Append a description to the buffer by respecting the indentSize and lineLength parameters. * Note: The last character is always a new line. * * @param sb The buffer to append the description, not null. * @param description The description, not null. * @param indent The base indentation level of each line, must not be negative. */ private void append( StringBuffer sb, String description, int indent ) { for ( Iterator it = toLines( description, indent, indentSize, lineLength ).iterator(); it.hasNext(); ) { sb.append( it.next().toString() ).append( '\n' ); } } /** * Splits the specified text into lines of convenient display length. * * @param text The text to split into lines, must not be null. * @param indent The base indentation level of each line, must not be negative. * @param indentSize The size of each indentation, must not be negative. * @param lineLength The length of the line, must not be negative. * @return The sequence of display lines, never null. * @throws NegativeArraySizeException if indent < 0 */ private static List toLines( String text, int indent, int indentSize, int lineLength ) { List lines = new ArrayList(); String ind = repeat( "\t", indent ); String[] plainLines = text.split( "(\r\n)|(\r)|(\n)" ); for ( int i = 0; i < plainLines.length; i++ ) { toLines( lines, ind + plainLines[i], indentSize, lineLength ); } return lines; } /** * Adds the specified line to the output sequence, performing line wrapping if necessary. * * @param lines The sequence of display lines, must not be null. * @param line The line to add, must not be null. * @param indentSize The size of each indentation, must not be negative. * @param lineLength The length of the line, must not be negative. */ private static void toLines( List lines, String line, int indentSize, int lineLength ) { int lineIndent = getIndentLevel( line ); StringBuffer buf = new StringBuffer( 256 ); String[] tokens = line.split( " +" ); for ( int i = 0; i < tokens.length; i++ ) { String token = tokens[i]; if ( i > 0 ) { if ( buf.length() + token.length() >= lineLength ) { lines.add( buf.toString() ); buf.setLength( 0 ); buf.append( repeat( " ", lineIndent * indentSize ) ); } else { buf.append( ' ' ); } } for ( int j = 0; j < token.length(); j++ ) { char c = token.charAt( j ); if ( c == '\t' ) { buf.append( repeat( " ", indentSize - buf.length() % indentSize ) ); } else if ( c == '\u00A0' ) { buf.append( ' ' ); } else { buf.append( c ); } } } lines.add( buf.toString() ); } /** * Gets the indentation level of the specified line. * * @param line The line whose indentation level should be retrieved, must not be null. * @return The indentation level of the line. */ private static int getIndentLevel( String line ) { int level = 0; for ( int i = 0; i < line.length() && line.charAt( i ) == '\t'; i++ ) { level++; } for ( int i = level + 1; i <= level + 4 && i < line.length(); i++ ) { if ( line.charAt( i ) == '\t' ) { level++; break; } } return level; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy