Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   package org.apache.maven.plugins.help;
   
   /*
    * Licensed to the Apache Software Foundation (ASF) under one
    * or more contributor license agreements.  See the NOTICE file
    * distributed with this work for additional information
    * regarding copyright ownership.  The ASF licenses this file
    * to you under the Apache License, Version 2.0 (the
    * "License"); you may not use this file except in compliance
   * with the License.  You may obtain a copy of the License at
   *
   *   http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing,
   * software distributed under the License is distributed on an
   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   * KIND, either express or implied.  See the License for the
   * specific language governing permissions and limitations
   * under the License.
   */
  
  import java.util.List;
  
  import  org.apache.maven.artifact.factory.ArtifactFactory;
Displays a list of the attributes for a Maven Plugin and/or goals (aka Mojo - Maven plain Old Java Object).

Version:
$Id: DescribeMojo.java 1446806 2013-02-15 23:07:28Z rfscholte $
Since:
2.0
See also:
What is a Mojo?
  
  @Mojo( name = "describe", requiresProject = false, aggregator = true )
  public class DescribeMojo
      extends AbstractHelpMojo
  {
    
The default indent size when writing description's Mojo.
  
      private static final int INDENT_SIZE = 2;

    
For unknown values
  
      private static final String UNKNOWN = "Unknown";

    
For not defined values
  
      private static final String NOT_DEFINED = "Not defined";

    
For deprecated values
  
      private static final String NO_REASON = "No reason given";
      
      private static final Pattern EXPRESSION = Pattern.compile"^\\$\\{([^}]+)\\}$" );
  
     // ----------------------------------------------------------------------
     // Mojo components
     // ----------------------------------------------------------------------
 
    
Maven Artifact Factory component.

Since:
2.1
 
     @Component
     private ArtifactFactory artifactFactory;

    
The Plugin manager instance used to resolve Plugin descriptors.
 
     @Component( role = PluginManager.class )
     private PluginManager pluginManager;

    
The project builder instance used to retrieve the super-project instance in the event there is no current MavenProject instance. Some MavenProject instance has to be present to use in the plugin manager APIs.
 
     @Component( role = MavenProjectBuilder.class )
 
     // ----------------------------------------------------------------------
     // Mojo parameters
     // ----------------------------------------------------------------------
 
    
The current project, if there is one. This is listed as optional, since the help plugin should be able to function on its own. If this parameter is empty at execution time, this Mojo will instead use the super-project.
 
     @Component
     private MavenProject project;

    
The current build session instance. This is used for plugin manager API calls.
 
     @Component
     private MavenSession session;

    
The local repository ArtifactRepository instance. This is used for plugin manager API calls.
 
     @org.apache.maven.plugins.annotations.Parameter( defaultValue = "${localRepository}", required = true, readonly = true )
     private ArtifactRepository localRepository;

    
Remote repositories used for the project.

Since:
2.1
 
     @org.apache.maven.plugins.annotations.Parameter( defaultValue = "${project.remoteArtifactRepositories}",
                     required = true, readonly = true )
     private List<ArtifactRepositoryremoteRepositories;

    
The Maven Plugin to describe. This must be specified in one of three ways:
  1. plugin-prefix, i.e. 'help'
  2. groupId:artifactId, i.e. 'org.apache.maven.plugins:maven-help-plugin'
  3. groupId:artifactId:version, i.e. 'org.apache.maven.plugins:maven-help-plugin:2.0'
 
     @org.apache.maven.plugins.annotations.Parameter( property = "plugin", alias = "prefix" )
     private String plugin;

    
The Maven Plugin groupId to describe.
Note: Should be used with artifactId parameter.
 
     @org.apache.maven.plugins.annotations.Parameter( property = "groupId" )
     private String groupId;

    
The Maven Plugin artifactId to describe.
Note: Should be used with groupId parameter.
 
     @org.apache.maven.plugins.annotations.Parameter( property = "artifactId" )
     private String artifactId;

    
The Maven Plugin version to describe.
Note: Should be used with groupId/artifactId parameters.
 
     @org.apache.maven.plugins.annotations.Parameter( property = "version" )
     private String version;

    
The goal name of a Mojo to describe within the specified Maven Plugin. If this parameter is specified, only the corresponding goal (Mojo) will be described, rather than the whole Plugin.

Since:
2.1, was mojo in 2.0.x
 
     @org.apache.maven.plugins.annotations.Parameter( property = "goal", alias = "mojo" )
     private String goal;

    
This flag specifies that a detailed (verbose) list of goal (Mojo) information should be given.

Since:
2.1, was full in 2.0.x
 
     @org.apache.maven.plugins.annotations.Parameter( property = "detail", defaultValue = "false", alias = "full" )
     private boolean detail;

    
This flag specifies that a medium list of goal (Mojo) information should be given.

Since:
2.0.2
 
     @org.apache.maven.plugins.annotations.Parameter( property = "medium", defaultValue = "true" )
     private boolean medium;

    
This flag specifies that a minimal list of goal (Mojo) information should be given.

Since:
2.1
 
     @org.apache.maven.plugins.annotations.Parameter( property = "minimal", defaultValue = "false" )
     private boolean minimal;

    
A Maven command like a single goal or a single phase following the Maven command line:
mvn [options] [<goal(s)>] [<phase(s)>]

Since:
2.1
 
     @org.apache.maven.plugins.annotations.Parameter( property = "cmd" )
     private String cmd;
 
     // ----------------------------------------------------------------------
     // Public methods
     // ----------------------------------------------------------------------
 
    
 
     public void execute()
     {
         validateParameters();
 
         if (  == null )
         {
             try
             {
             }
             catch ( ProjectBuildingException e )
             {
                 throw new MojoExecutionException"Error while retrieving the super-project."e );
             }
         }
 
         StringBuilder descriptionBuffer = new StringBuilder();
 
         boolean describePlugin = true;
         if ( StringUtils.isNotEmpty ) )
         {
             describePlugin = describeCommanddescriptionBuffer );
         }
 
         if ( describePlugin )
         {
             PluginInfo pi = new PluginInfo();
 
             parsePluginLookupInfopi );
 
             PluginDescriptor descriptor = lookupPluginDescriptorpi );
 
             if ( StringUtils.isNotEmpty ) )
             {
                 MojoDescriptor mojo = descriptor.getMojo );
                 if ( mojo == null )
                 {
                     throw new MojoFailureException(
                         "The mojo '" +  + "' does not exist in the plugin '" + pi.getPrefix() + "'" );
                 }
 
                 describeMojomojodescriptionBuffer );
             }
             else
             {
                 describePlugindescriptordescriptionBuffer );
             }
         }
 
         writeDescriptiondescriptionBuffer );
     }
 
     // ----------------------------------------------------------------------
     // Private methods
     // ----------------------------------------------------------------------
 
    
Validate parameters
 
     private void validateParameters()
     {
         // support legacy parameters "mojo" and "full"
         if (  == null && .getExecutionProperties().get"mojo" ) != null )
         {
              = .getExecutionProperties().getProperty"mojo" );
         }
 
         if ( ! && .getExecutionProperties().get"full" ) != null )
         {
             String full = .getExecutionProperties().getProperty"full" );
              = Boolean.valueOffull );
         }
 
         if (  ||  )
         {
              = false;
         }
     }

    
Method to write the Mojo description into the output file

Parameters:
descriptionBuffer contains the description to be written to the file
Throws:
MojoExecutionException if any
 
     private void writeDescriptionStringBuilder descriptionBuffer )
         throws MojoExecutionException
     {
         if (  != null )
         {
             try
             {
                 writeFiledescriptionBuffer );
             }
             catch ( IOException e )
             {
                 throw new MojoExecutionException"Cannot write plugin/mojo description to output: " + e );
             }
 
             if ( getLog().isInfoEnabled() )
             {
                 getLog().info"Wrote descriptions to: " +  );
             }
         }
         else
         {
             if ( getLog().isInfoEnabled() )
             {
                 getLog().infodescriptionBuffer.toString() );
             }
         }
     }

    
Method for retrieving the description of the plugin

Parameters:
pi holds information of the plugin whose description is to be retrieved
Returns:
a PluginDescriptor where the plugin description is to be retrieved
Throws:
MojoExecutionException if the plugin could not be verify
MojoFailureException if groupId or artifactId is empty
 
     {
         PluginDescriptor descriptor = null;
 
         Plugin forLookup = null;
 
         if ( StringUtils.isNotEmptypi.getPrefix() ) )
         {
             descriptor = .getPluginDescriptorForPrefixpi.getPrefix() );
             if ( descriptor == null )
             {
                 forLookup = .getPluginDefinitionForPrefixpi.getPrefix(),  );
             }
         }
         else if ( StringUtils.isNotEmptypi.getGroupId() ) && StringUtils.isNotEmptypi.getArtifactId() ) )
         {
             forLookup = new Plugin();
 
             forLookup.setGroupIdpi.getGroupId() );
             forLookup.setArtifactIdpi.getArtifactId() );
 
             if ( StringUtils.isNotEmptypi.getVersion() ) )
             {
                 forLookup.setVersionpi.getVersion() );
             }
         }
         else
         {
             StringBuilder msg = new StringBuilder();
             msg.append"You must specify either: both 'groupId' and 'artifactId' parameters OR a 'plugin' parameter"
                             + " OR a 'cmd' parameter. For instance:\n" );
             msg.append"  # mvn help:describe -Dcmd=install\n" );
             msg.append"or\n" );
             msg.append"  # mvn help:describe -Dcmd=help:describe\n" );
             msg.append"or\n" );
             msg.append"  # mvn help:describe -Dplugin=org.apache.maven.plugins:maven-help-plugin\n" );
             msg.append"or\n" );
             msg.append"  # mvn help:describe -DgroupId=org.apache.maven.plugins -DartifactId=maven-help-plugin\n\n" );
             msg.append"Try 'mvn help:help -Ddetail=true' for more information." );
 
             throw new MojoFailureExceptionmsg.toString() );
         }
 
         if ( descriptor == null && forLookup != null )
         {
             try
             {
                 descriptor = .loadPluginDescriptorforLookup );
             }
             catch ( ArtifactResolutionException e )
             {
                 throw new MojoExecutionException(
                     "Error retrieving plugin descriptor for:\n\ngroupId: '" +  + "'\nartifactId: '" + 
                         + "'\nversion: '" +  + "'\n\n"e );
             }
             catch ( PluginManagerException e )
             {
                 throw new MojoExecutionException(
                     "Error retrieving plugin descriptor for:\n\ngroupId: '" +  + "'\nartifactId: '" + 
                         + "'\nversion: '" +  + "'\n\n"e );
             }
             catch ( PluginVersionResolutionException e )
             {
                 throw new MojoExecutionException(
                     "Error retrieving plugin descriptor for:\n\ngroupId: '" +  + "'\nartifactId: '" + 
                         + "'\nversion: '" +  + "'\n\n"e );
             }
             catch ( ArtifactNotFoundException e )
             {
                 throw new MojoExecutionException"Plugin dependency does not exist: " + e.getMessage(), e );
             }
             catch ( InvalidVersionSpecificationException e )
             {
                 throw new MojoExecutionException(
                     "Error retrieving plugin descriptor for:\n\ngroupId: '" +  + "'\nartifactId: '" + 
                         + "'\nversion: '" +  + "'\n\n"e );
             }
             catch ( InvalidPluginException e )
             {
                 throw new MojoExecutionException(
                     "Error retrieving plugin descriptor for:\n\ngroupId: '" +  + "'\nartifactId: '" + 
                         + "'\nversion: '" +  + "'\n\n"e );
             }
             catch ( PluginNotFoundException e )
             {
                 if ( getLog().isDebugEnabled() )
                 {
                     getLog().debug"Unable to find plugin"e );
                 }
                 throw new MojoFailureException"Plugin does not exist: " + e.getMessage() );
             }
             catch ( PluginVersionNotFoundException e )
             {
                 if ( getLog().isDebugEnabled() )
                 {
                     getLog().debug"Unable to find plugin version"e );
                 }
                 throw new MojoFailureExceptione.getMessage() );
             }
         }
 
         if ( descriptor == null )
         {
             throw new MojoFailureException"Plugin could not be found. If you believe it is correct,"
                 + " check your pluginGroups setting, and run with -U to update the remote configuration" );
         }
 
         return descriptor;
     }

    
Method for parsing the plugin parameter

Parameters:
pi contains information about the plugin whose description is to be retrieved
Throws:
MojoFailureException if plugin<*code> parameter is not conform to groupId:artifactId[:version]
 
     private void parsePluginLookupInfoPluginInfo pi )
         throws MojoFailureException
     {
         if ( StringUtils.isNotEmpty ) )
         {
             if ( .indexOf':' ) > -1 )
             {
                 String[] pluginParts = .split":" );
 
                 switch ( pluginParts.length )
                 {
                     case ( 1 ):
                         pi.setPrefixpluginParts[0] );
                         break;
                     case ( 2 ):
                         pi.setGroupIdpluginParts[0] );
                         pi.setArtifactIdpluginParts[1] );
                         break;
                     case ( 3 ):
                         pi.setGroupIdpluginParts[0] );
                         pi.setArtifactIdpluginParts[1] );
                         pi.setVersionpluginParts[2] );
                         break;
                     default:
                         throw new MojoFailureException"plugin parameter must be a plugin prefix,"
                                                             + " or conform to: 'groupId:artifactId[:version]'." );
                 }
             }
             else
             {
                 pi.setPrefix );
             }
         }
         else
         {
             pi.setGroupId );
             pi.setArtifactId );
             pi.setVersion );
         }
     }

    
Method for retrieving the plugin description

Parameters:
pd contains the plugin description
buffer contains the information to be displayed or printed
Throws:
MojoFailureException if any reflection exceptions occur.
MojoExecutionException if any
 
     private void describePluginPluginDescriptor pdStringBuilder buffer )
     {
         appendbufferpd.getId(), 0 );
         buffer.append"\n" );
 
         String name = pd.getName();
         if ( name == null )
         {
             // Always null see MPLUGIN-137
             // TODO remove when maven-plugin-tools-api:2.4.4
             try
             {
                 Artifact artifact = .createPluginArtifact( pd.getGroupId(), pd.getArtifactId(),
                                                                           VersionRange.createFromVersion(
                                                                               pd.getVersion() ) );
                 MavenProject pluginProject =
                     .buildFromRepositoryartifact );
 
                 name = pluginProject.getName();
             }
             catch ( ProjectBuildingException e )
             {
                 // oh well, we tried our best.
                 name = pd.getId();
             }
         }
         appendbuffer"Name"name, 0 );
         appendAsParagraphbuffer"Description"toDescriptionpd.getDescription() ), 0 );
         appendbuffer"Group Id"pd.getGroupId(), 0 );
         appendbuffer"Artifact Id"pd.getArtifactId(), 0 );
         appendbuffer"Version"pd.getVersion(), 0 );
         appendbuffer"Goal Prefix"pd.getGoalPrefix(), 0 );
         buffer.append"\n" );
 
         @SuppressWarnings"unchecked" )
         List<MojoDescriptormojos = pd.getMojos();
 
         if ( mojos == null )
         {
             appendbuffer"This plugin has no goals.", 0 );
             return;
         }
 
         if ( (  ||  ) && ! )
         {
             appendbuffer"This plugin has " + mojos.size() + " goal" + ( mojos.size() > 1 ? "s" : "" ) + ":", 0 );
             buffer.append"\n" );
 
             mojos = new ArrayList<MojoDescriptor>( mojos );
             PluginUtils.sortMojosmojos );
 
             for ( MojoDescriptor md : mojos )
             {
                 if (  )
                 {
                     describeMojoGutsmdbuffertrue );
                 }
                 else
                 {
                     describeMojoGutsmdbufferfalse );
                 }
 
                 buffer.append"\n" );
             }
         }
 
         if ( ! )
         {
             buffer.append"For more information, run 'mvn help:describe [...] -Ddetail'" );
             buffer.append"\n" );
         }
     }

    
Displays information about the Plugin Mojo

Parameters:
md contains the description of the Plugin Mojo
buffer the displayed output
Throws:
MojoFailureException if any reflection exceptions occur.
MojoExecutionException if any
 
     private void describeMojoMojoDescriptor mdStringBuilder buffer )
     {
         buffer.append"Mojo: '" ).appendmd.getFullGoalName() ).append"'" );
         buffer.append'\n' );
 
         describeMojoGutsmdbuffer );
         buffer.append"\n" );
 
         if ( ! )
         {
             buffer.append"For more information, run 'mvn help:describe [...] -Ddetail'" );
             buffer.append"\n" );
         }
     }

    
Displays detailed information about the Plugin Mojo

Parameters:
md contains the description of the Plugin Mojo
buffer contains information to be printed or displayed
fullDescription specifies whether all the details about the Plugin Mojo is to be displayed
Throws:
MojoFailureException if any reflection exceptions occur.
MojoExecutionException if any
 
     private void describeMojoGutsMojoDescriptor mdStringBuilder bufferboolean fullDescription )
     {
         appendbuffermd.getFullGoalName(), 0 );
 
         // indent 1
         appendAsParagraphbuffer"Description"toDescriptionmd.getDescription() ), 1 );
 
         String deprecation = md.getDeprecated();
         if ( deprecation != null && deprecation.length() <= 0 )
         {
             deprecation = ;
         }
 
         if ( StringUtils.isNotEmptydeprecation ) )
         {
             appendbuffer"Deprecated. " + deprecation, 1 );
         }
 
         if ( !fullDescription )
         {
             return;
         }
 
         appendbuffer"Implementation"md.getImplementation(), 1 );
         appendbuffer"Language"md.getLanguage(), 1 );
 
         String phase = md.getPhase();
         if ( StringUtils.isNotEmptyphase ) )
         {
             appendbuffer"Bound to phase"phase, 1 );
         }
 
         String eGoal = md.getExecuteGoal();
         String eLife = md.getExecuteLifecycle();
         String ePhase = md.getExecutePhase();
 
         if ( StringUtils.isNotEmptyeGoal ) || StringUtils.isNotEmptyePhase ) )
         {
             appendbuffer"Before this mojo executes, it will call:", 1 );
 
             if ( StringUtils.isNotEmptyeGoal ) )
             {
                 appendbuffer"Single mojo""'" + eGoal + "'", 2 );
             }
 
             if ( StringUtils.isNotEmptyePhase ) )
             {
                 String s = "Phase: '" + ePhase + "'";
 
                 if ( StringUtils.isNotEmptyeLife ) )
                 {
                     s += " in Lifecycle Overlay: '" + eLife + "'";
                 }
 
                 appendbuffers, 2 );
             }
         }
 
         buffer.append"\n" );
 
         describeMojoParametersmdbuffer );
     }

    
Displays parameter information of the Plugin Mojo

Parameters:
md contains the description of the Plugin Mojo
buffer contains information to be printed or displayed
Throws:
MojoFailureException if any reflection exceptions occur.
MojoExecutionException if any
 
     private void describeMojoParametersMojoDescriptor mdStringBuilder buffer )
     {
         @SuppressWarnings"unchecked" )
         List<Parameterparams = md.getParameters();
 
         if ( params == null || params.isEmpty() )
         {
             appendbuffer"This mojo doesn't use any parameters.", 1 );
             return;
         }
 
         params = new ArrayList<Parameter>( params );
         // TODO remove when maven-plugin-tools-api:2.4.4 is out see PluginUtils.sortMojoParameters()
         Collections.sortparamsnew Comparator<Parameter>()
         {
            
 
             public int compareParameter parameter1Parameter parameter2 )
             {
                 return parameter1.getName().compareToIgnoreCaseparameter2.getName() );
             }
         } );
 
         appendbuffer"Available parameters:", 1 );
 
         // indent 2
         for ( Parameter parameter : params )
         {
             if ( !parameter.isEditable() )
             {
                 continue;
             }
 
             buffer.append"\n" );
 
             // DGF wouldn't it be nice if this worked?
             String defaultVal = parameter.getDefaultValue();
             if ( defaultVal == null )
             {
                 // defaultVal is ALWAYS null, this is a bug in PluginDescriptorBuilder (cf. MNG-4941)
                 defaultVal =
                     md.getMojoConfiguration().getChildparameter.getName() ).getAttribute"default-value"null );
             }
 
             if ( StringUtils.isNotEmptydefaultVal ) )
             {
                 defaultVal = " (Default: " + defaultVal + ")";
             }
             else
             {
                 defaultVal = "";
             }
             appendbufferparameter.getName() + defaultVal, 2 );
 
             if ( parameter.isRequired() )
             {
                 appendbuffer"Required""true", 3 );
             }
 
             String expression = parameter.getExpression();
             if ( StringUtils.isEmptyexpression ) )
             {
                 // expression is ALWAYS null, this is a bug in PluginDescriptorBuilder (cf. MNG-4941).
                 // Fixed with Maven-3.0.1
                 expression = md.getMojoConfiguration().getChildparameter.getName() ).getValuenull );
             }
             if ( StringUtils.isNotEmptyexpression ) )
             {
                 Matcher matcher = .matcherexpression );
                 if ( matcher.matches() )
                 {
                     appendbuffer"User property"matcher.group( 1 ), 3 );
                 }
                 else
                 {
                     appendbuffer"Expression"expression, 3 );
                 }
             }
 
             appendbuffertoDescriptionparameter.getDescription() ), 3 );
 
             String deprecation = parameter.getDeprecated();
             if ( deprecation != null && deprecation.length() <= 0 )
             {
                 deprecation = ;
             }
 
             if ( StringUtils.isNotEmptydeprecation ) )
             {
                 appendbuffer"Deprecated. " + deprecation, 3 );
             }
         }
     }

    
Describe the cmd parameter

Parameters:
descriptionBuffer not null
Returns:
true if it implies to describe a plugin, false otherwise.
Throws:
MojoFailureException if any reflection exceptions occur or missing components.
MojoExecutionException if any
 
     private boolean describeCommandStringBuilder descriptionBuffer )
     {
         if ( .indexOf':' ) == -1 )
         {
             // phase
             try
             {
                 DefaultLifecycleExecutor lifecycleExecutor =
                     (DefaultLifecycleExecutor.lookup. );
 
                 Lifecycle lifecycle = (LifecyclelifecycleExecutor.getPhaseToLifecycleMap().get );
                 if ( lifecycle == null )
                 {
                     throw new MojoExecutionException"The given phase '" +  + "' is an unknown phase." );
                 }
 
                 LifecycleMapping lifecycleMapping =
                     (LifecycleMapping.lookup..getPackaging() );
                 @SuppressWarnings"unchecked" )
                 List<Stringphases = lifecycle.getPhases();
 
                 if ( lifecycle.getDefaultPhases() == null )
                 {
                     descriptionBuffer.append"'" +  + "' is a phase corresponding to this plugin:\n" );
                     for ( String key : phases )
                     {
                         if ( !key.equals ) )
                         {
                             continue;
                         }
 
                         if ( lifecycleMapping.getPhases"default" ).getkey ) != null )
                         {
                             descriptionBuffer.appendlifecycleMapping.getPhases"default" ).getkey ) );
                             descriptionBuffer.append"\n" );
                         }
                     }
 
                     descriptionBuffer.append"\n" );
                     descriptionBuffer.append(
                         "It is a part of the lifecycle for the POM packaging '" + .getPackaging()
                             + "'. This lifecycle includes the following phases:" );
                     descriptionBuffer.append"\n" );
                     for ( String key : phases )
                     {
                         descriptionBuffer.append"* " + key + ": " );
                         String value = (StringlifecycleMapping.getPhases"default" ).getkey );
                         if ( StringUtils.isNotEmptyvalue ) )
                         {
                             for ( StringTokenizer tok = new StringTokenizervalue"," ); tok.hasMoreTokens(); )
                             {
                                 descriptionBuffer.appendtok.nextToken().trim() );
 
                                 if ( !tok.hasMoreTokens() )
                                 {
                                     descriptionBuffer.append"\n" );
                                 }
                                 else
                                 {
                                     descriptionBuffer.append", " );
                                 }
                             }
                         }
                         else
                         {
                             descriptionBuffer.append ).append"\n" );
                         }
                     }
                 }
                 else
                 {
                     descriptionBuffer.append"'" +  + "' is a lifecycle with the following phases: " );
                     descriptionBuffer.append"\n" );
 
                     for ( String key : phases )
                     {
                         descriptionBuffer.append"* " + key + ": " );
                         if ( lifecycle.getDefaultPhases().getkey ) != null )
                         {
                             descriptionBuffer.appendlifecycle.getDefaultPhases().getkey ) ).append"\n" );
                         }
                         else
                         {
                             descriptionBuffer.append ).append"\n" );
                         }
                     }
                 }
             }
             catch ( ComponentLookupException e )
             {
                 throw new MojoFailureException"ComponentLookupException: " + e.getMessage() );
             }
             catch ( LifecycleExecutionException e )
             {
                 throw new MojoFailureException"LifecycleExecutionException: " + e.getMessage() );
             }
 
             return false;
         }
 
         // goals
         MojoDescriptor mojoDescriptor = HelpUtil.getMojoDescriptortruefalse );
 
         descriptionBuffer.append"'" +  + "' is a plugin goal (aka mojo)" ).append".\n" );
          = mojoDescriptor.getPluginDescriptor().getId();
          = mojoDescriptor.getGoal();
 
         return true;
     }

    
Invoke the following private method HelpMojo#toLines(String, int, int, int)

Parameters:
text The text to split into lines, must not be null.
indent The base indentation level of each line, must not be negative.
indentSize The size of each indentation, must not be negative.
lineLength The length of the line, must not be negative.
Returns:
The sequence of display lines, never null.
Throws:
MojoFailureException if any can not invoke the method
MojoExecutionException if no line was found for text
See also:
HelpMojo.toLines(String, int, int, int)
 
     private static List<StringtoLinesString textint indentint indentSizeint lineLength )
     {
         try
         {
             Method m = HelpMojo.class.getDeclaredMethod"toLines",
                                                          new Class[]{ String.class..,
                                                              . } );
             m.setAccessibletrue );
             List<Stringoutput = (List<String>) m.invokeHelpMojo.class,
                                            new Object[]{ text, Integer.valueOfindent ), Integer.valueOfindentSize ),
                                                Integer.valueOflineLength ) } );
 
             if ( output == null )
             {
                 throw new MojoExecutionException"No output was specified." );
             }
 
             return output;
         }
         catch ( SecurityException e )
         {
             throw new MojoFailureException"SecurityException: " + e.getMessage() );
         }
         catch ( IllegalArgumentException e )
         {
             throw new MojoFailureException"IllegalArgumentException: " + e.getMessage() );
         }
         catch ( NoSuchMethodException e )
         {
             throw new MojoFailureException"NoSuchMethodException: " + e.getMessage() );
         }
         catch ( IllegalAccessException e )
         {
             throw new MojoFailureException"IllegalAccessException: " + e.getMessage() );
         }
         catch ( InvocationTargetException e )
         {
             Throwable cause = e.getCause();
 
             if ( cause instanceof NegativeArraySizeException )
             {
                 throw new MojoFailureException"NegativeArraySizeException: " + cause.getMessage() );
             }
 
             throw new MojoFailureException"InvocationTargetException: " + e.getMessage() );
         }
     }

    
Append a description to the buffer by respecting the indentSize and lineLength parameters. Note: The last character is always a new line.

Parameters:
sb The buffer to append the description, not null.
description The description, not null.
indent The base indentation level of each line, must not be negative.
Throws:
MojoFailureException if any reflection exceptions occur.
MojoExecutionException if any
See also:
toLines(String, int, int, int)
    private static void appendStringBuilder sbString descriptionint indent )
    {
        if ( StringUtils.isEmptydescription ) )
        {
            sb.append ).append'\n' );
            return;
        }
        for ( String line : toLinesdescriptionindent ) )
        {
            sb.appendline ).append'\n' );
        }
    }

    
Append a description to the buffer by respecting the indentSize and lineLength parameters. Note: The last character is always a new line.

Parameters:
sb The buffer to append the description, not null.
key The key, not null.
value The value associated to the key, could be null.
indent The base indentation level of each line, must not be negative.
Throws:
MojoFailureException if any reflection exceptions occur.
MojoExecutionException if any
See also:
toLines(String, int, int, int)
    private static void appendStringBuilder sbString keyString valueint indent )
    {
        if ( StringUtils.isEmptykey ) )
        {
            throw new IllegalArgumentException"Key is required!" );
        }
        if ( StringUtils.isEmptyvalue ) )
        {
            value = ;
        }
        String description = key + ": " + value;
        for ( String line : toLinesdescriptionindent ) )
        {
            sb.appendline ).append'\n' );
        }
    }

    
Append a description to the buffer by respecting the indentSize and lineLength parameters for the first line, and append the next lines with indent + 1 like a paragraph. Note: The last character is always a new line.

Parameters:
sb The buffer to append the description, not null.
key The key, not null.
value The value, could be null.
indent The base indentation level of each line, must not be negative.
Throws:
MojoFailureException if any reflection exceptions occur.
MojoExecutionException if any
See also:
toLines(String, int, int, int)
    private static void appendAsParagraphStringBuilder sbString keyString valueint indent )
    {
        if ( StringUtils.isEmptyvalue ) )
        {
            value = ;
        }
        String description;
        if ( key == null )
        {
            description = value;
        }
        else
        {
            description = key + ": " + value;
        }
        List<Stringl1 = toLinesdescriptionindent -  );
        List<Stringl2 = toLinesdescriptionindent + 1,  );
        l2.set( 0, l1.get( 0 ) );
        for ( String line : l2 )
        {
            sb.appendline ).append'\n' );
        }
    }

    
Gets the effective string to use for the plugin/mojo/parameter description.

Parameters:
description The description of the element, may be null.
Returns:
The effective description string, never null.
    private static String toDescriptionString description )
    {
        if ( StringUtils.isNotEmptydescription ) )
        {
            return PluginUtils.toTextdescription );
        }
        return "(no description available)";
    }

    
Class to wrap Plugin information.
    static class PluginInfo
    {
        private String prefix;
        private String groupId;
        private String artifactId;
        private String version;
        private String mojo;
        private Plugin plugin;
        private PluginDescriptor pluginDescriptor;

        

Returns:
the prefix
        public String getPrefix()
        {
            return ;
        }

        

Parameters:
prefix the prefix to set
        public void setPrefixString prefix )
        {
            this. = prefix;
        }

        

Returns:
the groupId
        public String getGroupId()
        {
            return ;
        }

        

Parameters:
groupId the groupId to set
        public void setGroupIdString groupId )
        {
            this. = groupId;
        }

        

Returns:
the artifactId
        public String getArtifactId()
        {
            return ;
        }

        

Parameters:
artifactId the artifactId to set
        public void setArtifactIdString artifactId )
        {
            this. = artifactId;
        }

        

Returns:
the version
        public String getVersion()
        {
            return ;
        }

        

Parameters:
version the version to set
        public void setVersionString version )
        {
            this. = version;
        }

        

Returns:
the mojo
        public String getMojo()
        {
            return ;
        }

        

Parameters:
mojo the mojo to set
        public void setMojoString mojo )
        {
            this. = mojo;
        }

        

Returns:
the plugin
        public Plugin getPlugin()
        {
            return ;
        }

        

Parameters:
plugin the plugin to set
        public void setPluginPlugin plugin )
        {
            this. = plugin;
        }

        

Returns:
the pluginDescriptor
        public PluginDescriptor getPluginDescriptor()
        {
            return ;
        }

        

Parameters:
pluginDescriptor the pluginDescriptor to set
        public void setPluginDescriptorPluginDescriptor pluginDescriptor )
        {
            this. = pluginDescriptor;
        }
    }