![JAR search and dependency download from the Maven repository](/logo.png)
org.codehaus.mojo.dita.HelpMojo Maven / Gradle / Ivy
package org.codehaus.mojo.dita;
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 dita-maven-plugin.
Call mvn dita:help -Ddetail=true -Dgoal=<goal-name>
to display parameter details.
*
* @version generated on Sun Mar 07 11:43:52 PST 2010
* @author org.apache.maven.tools.plugin.generator.PluginHelpGenerator (version 2.5)
* @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:dita-maven-plugin:1.0-beta-2", 0 );
append( sb, "", 0 );
append( sb, "DITA Open Toolkit Maven Plugin", 0 );
append( sb, "The DITA Open Toolkit is an implementation of the OASIS DITA XML Specification. The Toolkit transforms DITA content into many deliverable formats.", 1 );
append( sb, "", 0 );
if ( goal == null || goal.length() <= 0 )
{
append( sb, "This plugin has 6 goals:", 0 );
append( sb, "", 0 );
}
if ( goal == null || goal.length() <= 0 || "chm2web".equals( goal ) )
{
append( sb, "dita:chm2web", 0 );
append( sb, "Convert DITA Open Toolkit\'s Microsoft CHM output file, produced by htmlhelp transtype, to pure HTML set of files. Require commercial chm2web utility from A!K Research Labs", 1 );
append( sb, "", 0 );
if ( detail )
{
append( sb, "Available parameters:", 1 );
append( sb, "", 0 );
append( sb, "attach (Default: false)", 2 );
append( sb, "Controls whether this plugin tries to archive the output directory and attach archive to the project.", 3 );
append( sb, "", 0 );
append( sb, "attachClassifier", 2 );
append( sb, "Output file classifier to be attached to the project.", 3 );
append( sb, "", 0 );
append( sb, "attachType (Default: jar)", 2 );
append( sb, "Output file extension to be attached to the project.", 3 );
append( sb, "", 0 );
append( sb, "chm2webExe (Default: c:\\Program Files\\A!K Research Labs\\chm2web\\chm2web.exe)", 2 );
append( sb, "(no description available)", 3 );
append( sb, "", 0 );
append( sb, "descriptor (Default: ${basedir}/src/main/chm2web/${project.artifactId}.chm2web)", 2 );
append( sb, "Chm2Web configuration file", 3 );
append( sb, "", 0 );
append( sb, "ignoreIfChm2WebNotExist (Default: false)", 2 );
append( sb, "Allow skipping the conversion when chm2web is not available.", 3 );
append( sb, "", 0 );
append( sb, "outputDirectory (Default: ${project.build.directory}/chm2web)", 2 );
append( sb, "Chm2Web output directory. Must match with the output directory found in your chm2web\'s descriptor file.", 3 );
append( sb, "", 0 );
append( sb, "skip (Default: false)", 2 );
append( sb, "Skip the execution", 3 );
append( sb, "", 0 );
}
}
if ( goal == null || goal.length() <= 0 || "eclipse".equals( goal ) )
{
append( sb, "dita:eclipse", 0 );
append( sb, "Generate http://www.dita-op.org\'s Eclipse configuration to allow editing, previewing DITA under Eclipse IDE.", 1 );
append( sb, "", 0 );
if ( detail )
{
append( sb, "Available parameters:", 1 );
append( sb, "", 0 );
append( sb, "projectName (Default: ${project.artifactId})", 2 );
append( sb, "If given, will be added to Ant command line", 3 );
append( sb, "", 0 );
append( sb, "skip (Default: false)", 2 );
append( sb, "Skip the execution", 3 );
append( sb, "", 0 );
}
}
if ( goal == null || goal.length() <= 0 || "help".equals( goal ) )
{
append( sb, "dita:help", 0 );
append( sb, "Display help information on dita-maven-plugin.\nCall\n\u00a0\u00a0mvn\u00a0dita: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 || "print-help".equals( goal ) )
{
append( sb, "dita:print-help", 0 );
append( sb, "Display DITA Open Toolkit\'s common Ant properties usage. This can be used a reference for antProperties used by dita:run goal.", 1 );
append( sb, "", 0 );
if ( detail )
{
append( sb, "Available parameters:", 1 );
append( sb, "", 0 );
append( sb, "antProperties", 2 );
append( sb, "Ant key/value pair properties. Default properties for all dita\'s goals\n-\tdita.dir=${env.DITA_HOME}\nDefault properties for dita:run goal\n-\tbasedir=${project.basedir}\n-\toutput.dir=${project.build.directory}/dita/out\n-\tdita.temp.dir=${project.build.directory}/dita/temp\n-\targs.logdir=${project.build.directory}/dita/log\n-\targs.input=${project.basedir}/src/main/dita/${artifactId}.ditamap\n", 3 );
append( sb, "", 0 );
append( sb, "classpathElements", 2 );
append( sb, "Internal. Compile time project dependencies to be add ed to Ant\'s classpath", 3 );
append( sb, "", 0 );
append( sb, "skip (Default: false)", 2 );
append( sb, "Skip the execution", 3 );
append( sb, "", 0 );
append( sb, "useDitaClasspath (Default: true)", 2 );
append( sb, "Add jar files under DITA Open Toolkit\'s lib directory to execution classpath", 3 );
append( sb, "", 0 );
}
}
if ( goal == null || goal.length() <= 0 || "run".equals( goal ) )
{
append( sb, "dita:run", 0 );
append( sb, "Execute DITA Open Toolkit\'s Ant command line to transform DITA files to desired output format.\n\nBehind the scene, antProperties are temporarily stored under ${dita.temp.dir}/properties.temp to be used with\n\nant -f ${dita.dir}/build.xml -propertyFile ${dita.temp.dir}/properties.temp\n", 1 );
append( sb, "", 0 );
if ( detail )
{
append( sb, "Available parameters:", 1 );
append( sb, "", 0 );
append( sb, "antArguments", 2 );
append( sb, "If given, will be added to Ant command line. Use this for trouble shooting purpose", 3 );
append( sb, "", 0 );
append( sb, "antHome", 2 );
append( sb, "Point to Ant installation directory. If given, it will override useDitaAnt and ${env.ANT_HOME}", 3 );
append( sb, "", 0 );
append( sb, "antOpts", 2 );
append( sb, "Equivalent with ANT_OPTS environment. This parameter overrides the current env.ANT_OPTS if given. Typical usage is to setup JVM\'s heap space ( example -Xmx500m )", 3 );
append( sb, "", 0 );
append( sb, "antProperties", 2 );
append( sb, "Ant key/value pair properties. Default properties for all dita\'s goals\n-\tdita.dir=${env.DITA_HOME}\nDefault properties for dita:run goal\n-\tbasedir=${project.basedir}\n-\toutput.dir=${project.build.directory}/dita/out\n-\tdita.temp.dir=${project.build.directory}/dita/temp\n-\targs.logdir=${project.build.directory}/dita/log\n-\targs.input=${project.basedir}/src/main/dita/${artifactId}.ditamap\n", 3 );
append( sb, "", 0 );
append( sb, "attach (Default: false)", 2 );
append( sb, "Controls whether this goal tries to compress the output directory and attach compressed output file to the project for install and deploy purposes.", 3 );
append( sb, "", 0 );
append( sb, "attachClassifier", 2 );
append( sb, "Output file classifier to be attached to the project.", 3 );
append( sb, "", 0 );
append( sb, "attachType (Default: jar)", 2 );
append( sb, "Output file extension to be attached to the project. When transtype is one of the pdf types or htmlhelp, the attachType will be hard coded to pdf and chm respectively.", 3 );
append( sb, "", 0 );
append( sb, "classpathElements", 2 );
append( sb, "Internal. Compile time project dependencies to be add ed to Ant\'s classpath", 3 );
append( sb, "", 0 );
append( sb, "skip (Default: false)", 2 );
append( sb, "Skip the execution", 3 );
append( sb, "", 0 );
append( sb, "useDitaAnt (Default: true)", 2 );
append( sb, "Use DITA Open Toolkit\'s tools/ant", 3 );
append( sb, "", 0 );
append( sb, "useDitaClasspath (Default: true)", 2 );
append( sb, "Add jar files under DITA Open Toolkit\'s lib directory to execution classpath", 3 );
append( sb, "", 0 );
}
}
if ( goal == null || goal.length() <= 0 || "version".equals( goal ) )
{
append( sb, "dita:version", 0 );
append( sb, "Display DITA Open Toolkit\'s built-in version, with option to insert a custom version found under ${dita.dir}/ditaotVersionPath, via version property to Maven\'s ${versionName}. It is mainly used with maven-enforcer-plugin for build validation purpose.", 1 );
append( sb, "", 0 );
if ( detail )
{
append( sb, "Available parameters:", 1 );
append( sb, "", 0 );
append( sb, "antProperties", 2 );
append( sb, "Ant key/value pair properties. Default properties for all dita\'s goals\n-\tdita.dir=${env.DITA_HOME}\nDefault properties for dita:run goal\n-\tbasedir=${project.basedir}\n-\toutput.dir=${project.build.directory}/dita/out\n-\tdita.temp.dir=${project.build.directory}/dita/temp\n-\targs.logdir=${project.build.directory}/dita/log\n-\targs.input=${project.basedir}/src/main/dita/${artifactId}.ditamap\n", 3 );
append( sb, "", 0 );
append( sb, "classpathElements", 2 );
append( sb, "Internal. Compile time project dependencies to be add ed to Ant\'s classpath", 3 );
append( sb, "", 0 );
append( sb, "displayDitaOTVersion (Default: true)", 2 );
append( sb, "Display DITA Open Toolkit\'s built-in version", 3 );
append( sb, "", 0 );
append( sb, "ditaotVersionPath (Default: custom.version.properties)", 2 );
append( sb, "Relative path to DITA-OT custom version properties file path", 3 );
append( sb, "", 0 );
append( sb, "skip (Default: false)", 2 );
append( sb, "Skip the execution", 3 );
append( sb, "", 0 );
append( sb, "useDitaClasspath (Default: true)", 2 );
append( sb, "Add jar files under DITA Open Toolkit\'s lib directory to execution classpath", 3 );
append( sb, "", 0 );
append( sb, "versionName (Default: dita.custom.version)", 2 );
append( sb, "Maven project property name to store custom version value", 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 - 2025 Weber Informatics LLC | Privacy Policy