org.apache.maven.plugin.deploy.HelpMojo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of maven-deploy-plugin Show documentation
Show all versions of maven-deploy-plugin Show documentation
Uploads the project artifacts to the internal remote repository.
package org.apache.maven.plugin.deploy;
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 maven-deploy-plugin.
Call mvn deploy:help -Ddetail=true -Dgoal=<goal-name>
to display parameter details.
*
* @version generated on Mon Aug 22 11:07:54 IST 2011
* @author org.apache.maven.tools.plugin.generator.PluginHelpGenerator (version 2.8)
* @goal help
* @requiresProject false
* @threadSafe
*/
@SuppressWarnings( "all" )
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.apache.maven.plugins:maven-deploy-plugin:2.7", 0 );
append( sb, "", 0 );
append( sb, "Maven Deploy Plugin", 0 );
append( sb, "Uploads the project artifacts to the internal remote repository.", 1 );
append( sb, "", 0 );
if ( goal == null || goal.length() <= 0 )
{
append( sb, "This plugin has 3 goals:", 0 );
append( sb, "", 0 );
}
if ( goal == null || goal.length() <= 0 || "deploy".equals( goal ) )
{
append( sb, "deploy:deploy", 0 );
append( sb, "Deploys an artifact to remote repository.", 1 );
append( sb, "", 0 );
if ( detail )
{
append( sb, "Available parameters:", 1 );
append( sb, "", 0 );
append( sb, "altDeploymentRepository", 2 );
append( sb, "Specifies an alternative repository to which the project artifacts should be deployed ( other than those specified in ).\nFormat: id::layout::url", 3 );
append( sb, "Expression: ${altDeploymentRepository}", 3 );
append( sb, "", 0 );
append( sb, "retryFailedDeploymentCount (Default: 1)", 2 );
append( sb, "Parameter used to control how many times a failed deployment will be retried before giving up and failing. If a value outside the range 1-10 is specified it will be pulled to the nearest value within the range 1-10.", 3 );
append( sb, "Expression: ${retryFailedDeploymentCount}", 3 );
append( sb, "", 0 );
append( sb, "skip (Default: false)", 2 );
append( sb, "Set this to \'true\' to bypass artifact deploy", 3 );
append( sb, "Expression: ${maven.deploy.skip}", 3 );
append( sb, "", 0 );
append( sb, "updateReleaseInfo (Default: false)", 2 );
append( sb, "Parameter used to update the metadata to make the artifact as release.", 3 );
append( sb, "Expression: ${updateReleaseInfo}", 3 );
append( sb, "", 0 );
}
}
if ( goal == null || goal.length() <= 0 || "deploy-file".equals( goal ) )
{
append( sb, "deploy:deploy-file", 0 );
append( sb, "Installs the artifact in the remote repository.", 1 );
append( sb, "", 0 );
if ( detail )
{
append( sb, "Available parameters:", 1 );
append( sb, "", 0 );
append( sb, "artifactId", 2 );
append( sb, "ArtifactId of the artifact to be deployed. Retrieved from POM file if specified.", 3 );
append( sb, "Expression: ${artifactId}", 3 );
append( sb, "", 0 );
append( sb, "classifier", 2 );
append( sb, "Add classifier to the artifact", 3 );
append( sb, "Expression: ${classifier}", 3 );
append( sb, "", 0 );
append( sb, "classifiers", 2 );
append( sb, "A comma separated list of classifiers for each of the extra side artifacts to deploy. If there is a mis-match in the number of entries in files or types, then an error will be raised.", 3 );
append( sb, "Expression: ${classifiers}", 3 );
append( sb, "", 0 );
append( sb, "description", 2 );
append( sb, "Description passed to a generated POM file (in case of generatePom=true)", 3 );
append( sb, "Expression: ${generatePom.description}", 3 );
append( sb, "", 0 );
append( sb, "file", 2 );
append( sb, "File to be deployed.", 3 );
append( sb, "Required: Yes", 3 );
append( sb, "Expression: ${file}", 3 );
append( sb, "", 0 );
append( sb, "files", 2 );
append( sb, "A comma separated list of files for each of the extra side artifacts to deploy. If there is a mis-match in the number of entries in types or classifiers, then an error will be raised.", 3 );
append( sb, "Expression: ${files}", 3 );
append( sb, "", 0 );
append( sb, "generatePom (Default: true)", 2 );
append( sb, "Upload a POM for this artifact. Will generate a default POM if none is supplied with the pomFile argument.", 3 );
append( sb, "Expression: ${generatePom}", 3 );
append( sb, "", 0 );
append( sb, "groupId", 2 );
append( sb, "GroupId of the artifact to be deployed. Retrieved from POM file if specified.", 3 );
append( sb, "Expression: ${groupId}", 3 );
append( sb, "", 0 );
append( sb, "javadoc", 2 );
append( sb, "The bundled API docs for the artifact.", 3 );
append( sb, "Expression: ${javadoc}", 3 );
append( sb, "", 0 );
append( sb, "packaging", 2 );
append( sb, "Type of the artifact to be deployed. Retrieved from the element of the POM file if a POM file specified. Defaults to the file extension if it is not specified via command line or POM.\nMaven uses two terms to refer to this datum: the element for the entire POM, and the element in a dependency specification.", 3 );
append( sb, "Expression: ${packaging}", 3 );
append( sb, "", 0 );
append( sb, "pomFile", 2 );
append( sb, "Location of an existing POM file to be deployed alongside the main artifact, given by the ${file} parameter.", 3 );
append( sb, "Expression: ${pomFile}", 3 );
append( sb, "", 0 );
append( sb, "repositoryId (Default: remote-repository)", 2 );
append( sb, "Server Id to map on the under section of settings.xml In most cases, this parameter will be required for authentication.", 3 );
append( sb, "Required: Yes", 3 );
append( sb, "Expression: ${repositoryId}", 3 );
append( sb, "", 0 );
append( sb, "repositoryLayout (Default: default)", 2 );
append( sb, "The type of remote repository layout to deploy to. Try legacy for a Maven 1.x-style repository layout.", 3 );
append( sb, "Expression: ${repositoryLayout}", 3 );
append( sb, "", 0 );
append( sb, "retryFailedDeploymentCount (Default: 1)", 2 );
append( sb, "Parameter used to control how many times a failed deployment will be retried before giving up and failing. If a value outside the range 1-10 is specified it will be pulled to the nearest value within the range 1-10.", 3 );
append( sb, "Expression: ${retryFailedDeploymentCount}", 3 );
append( sb, "", 0 );
append( sb, "sources", 2 );
append( sb, "The bundled sources for the artifact.", 3 );
append( sb, "Expression: ${sources}", 3 );
append( sb, "", 0 );
append( sb, "types", 2 );
append( sb, "A comma separated list of types for each of the extra side artifacts to deploy. If there is a mis-match in the number of entries in files or classifiers, then an error will be raised.", 3 );
append( sb, "Expression: ${types}", 3 );
append( sb, "", 0 );
append( sb, "uniqueVersion (Default: true)", 2 );
append( sb, "Whether to deploy snapshots with a unique version or not.", 3 );
append( sb, "Expression: ${uniqueVersion}", 3 );
append( sb, "", 0 );
append( sb, "updateReleaseInfo (Default: false)", 2 );
append( sb, "Parameter used to update the metadata to make the artifact as release.", 3 );
append( sb, "Expression: ${updateReleaseInfo}", 3 );
append( sb, "", 0 );
append( sb, "url", 2 );
append( sb, "URL where the artifact will be deployed.\nie ( file:///C:/m2-repo or scp://host.com/path/to/repo )", 3 );
append( sb, "Required: Yes", 3 );
append( sb, "Expression: ${url}", 3 );
append( sb, "", 0 );
append( sb, "version", 2 );
append( sb, "Version of the artifact to be deployed. Retrieved from POM file if specified.", 3 );
append( sb, "Expression: ${version}", 3 );
append( sb, "", 0 );
}
}
if ( goal == null || goal.length() <= 0 || "help".equals( goal ) )
{
append( sb, "deploy:help", 0 );
append( sb, "Display help information on maven-deploy-plugin.\nCall\n\u00a0\u00a0mvn\u00a0deploy: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, "Expression: ${detail}", 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, "Expression: ${goal}", 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, "Expression: ${indentSize}", 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, "Expression: ${lineLength}", 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