Coverage Report - org.apache.maven.plugin.ear.HelpMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
HelpMojo
0%
0/241
0%
0/62
4.667
 
 1  
 package org.apache.maven.plugin.ear;
 2  
 
 3  
 import java.util.ArrayList;
 4  
 import java.util.Iterator;
 5  
 import java.util.List;
 6  
 
 7  
 import org.apache.maven.plugin.AbstractMojo;
 8  
 import org.apache.maven.plugin.MojoExecutionException;
 9  
 
 10  
 /**
 11  
  * Display help information on maven-ear-plugin.<br/> Call <pre>  mvn ear:help -Ddetail=true -Dgoal=&lt;goal-name&gt;</pre> to display parameter details.
 12  
  *
 13  
  * @version generated on Mon Jun 06 10:03:22 CEST 2011
 14  
  * @author org.apache.maven.tools.plugin.generator.PluginHelpGenerator (version 2.7)
 15  
  * @goal help
 16  
  * @requiresProject false
 17  
  * @threadSafe
 18  
  */
 19  0
 public class HelpMojo
 20  
     extends AbstractMojo
 21  
 {
 22  
     /**
 23  
      * If <code>true</code>, display all settable properties for each goal.
 24  
      * 
 25  
      * @parameter expression="${detail}" default-value="false"
 26  
      */
 27  
     private boolean detail;
 28  
 
 29  
     /**
 30  
      * The name of the goal for which to show help. If unspecified, all goals will be displayed.
 31  
      * 
 32  
      * @parameter expression="${goal}"
 33  
      */
 34  
     private java.lang.String goal;
 35  
 
 36  
     /**
 37  
      * The maximum length of a display line, should be positive.
 38  
      * 
 39  
      * @parameter expression="${lineLength}" default-value="80"
 40  
      */
 41  
     private int lineLength;
 42  
 
 43  
     /**
 44  
      * The number of spaces per indentation level, should be positive.
 45  
      * 
 46  
      * @parameter expression="${indentSize}" default-value="2"
 47  
      */
 48  
     private int indentSize;
 49  
 
 50  
 
 51  
     /** {@inheritDoc} */
 52  
     public void execute()
 53  
         throws MojoExecutionException
 54  
     {
 55  0
         if ( lineLength <= 0 )
 56  
         {
 57  0
             getLog().warn( "The parameter 'lineLength' should be positive, using '80' as default." );
 58  0
             lineLength = 80;
 59  
         }
 60  0
         if ( indentSize <= 0 )
 61  
         {
 62  0
             getLog().warn( "The parameter 'indentSize' should be positive, using '2' as default." );
 63  0
             indentSize = 2;
 64  
         }
 65  
 
 66  0
         StringBuffer sb = new StringBuffer();
 67  
 
 68  0
         append( sb, "org.apache.maven.plugins:maven-ear-plugin:2.6", 0 );
 69  0
         append( sb, "", 0 );
 70  
 
 71  0
         append( sb, "Maven EAR Plugin", 0 );
 72  0
         append( sb, "Generates a J2EE Enterprise Archive (EAR) file.", 1 );
 73  0
         append( sb, "", 0 );
 74  
 
 75  0
         if ( goal == null || goal.length() <= 0 )
 76  
         {
 77  0
             append( sb, "This plugin has 3 goals:", 0 );
 78  0
             append( sb, "", 0 );
 79  
         }
 80  
 
 81  0
         if ( goal == null || goal.length() <= 0 || "ear".equals( goal ) )
 82  
         {
 83  0
             append( sb, "ear:ear", 0 );
 84  0
             append( sb, "Builds J2EE Enterprise Archive (EAR) files.", 1 );
 85  0
             append( sb, "", 0 );
 86  0
             if ( detail )
 87  
             {
 88  0
                 append( sb, "Available parameters:", 1 );
 89  0
                 append( sb, "", 0 );
 90  
 
 91  0
                 append( sb, "applicationXml", 2 );
 92  0
                 append( sb, "The location of a custom application.xml file to be used within the ear file.", 3 );
 93  0
                 append( sb, "", 0 );
 94  
 
 95  0
                 append( sb, "archive", 2 );
 96  0
                 append( sb, "The archive configuration to use. See Maven Archiver Reference.", 3 );
 97  0
                 append( sb, "", 0 );
 98  
 
 99  0
                 append( sb, "artifactTypeMappings", 2 );
 100  0
                 append( sb, "The artifact type mappings.", 3 );
 101  0
                 append( sb, "", 0 );
 102  
 
 103  0
                 append( sb, "classifier", 2 );
 104  0
                 append( sb, "Classifier to add to the artifact generated. If given, the artifact will be an attachment instead.", 3 );
 105  0
                 append( sb, "", 0 );
 106  
 
 107  0
                 append( sb, "defaultLibBundleDir", 2 );
 108  0
                 append( sb, "The default bundle dir for libraries.", 3 );
 109  0
                 append( sb, "", 0 );
 110  
 
 111  0
                 append( sb, "earSourceDirectory (Default: ${basedir}/src/main/application)", 2 );
 112  0
                 append( sb, "Single directory for extra files to include in the EAR.", 3 );
 113  0
                 append( sb, "Required: Yes", 3 );
 114  0
                 append( sb, "", 0 );
 115  
 
 116  0
                 append( sb, "earSourceExcludes", 2 );
 117  0
                 append( sb, "The comma separated list of tokens to exclude from the EAR.", 3 );
 118  0
                 append( sb, "", 0 );
 119  
 
 120  0
                 append( sb, "earSourceIncludes (Default: **)", 2 );
 121  0
                 append( sb, "The comma separated list of tokens to include in the EAR.", 3 );
 122  0
                 append( sb, "", 0 );
 123  
 
 124  0
                 append( sb, "encoding (Default: UTF-8)", 2 );
 125  0
                 append( sb, "Character encoding for the auto-generated deployment file(s).", 3 );
 126  0
                 append( sb, "", 0 );
 127  
 
 128  0
                 append( sb, "escapedBackslashesInFilePath (Default: false)", 2 );
 129  0
                 append( sb, "To escape interpolated value with windows path c:\\foo\\bar will be replaced with c:\\\\foo\\\\bar", 3 );
 130  0
                 append( sb, "Expression: ${maven.ear.escapedBackslashesInFilePath}", 3 );
 131  0
                 append( sb, "", 0 );
 132  
 
 133  0
                 append( sb, "escapeString", 2 );
 134  0
                 append( sb, "Expression preceded with the String won\'t be interpolated \\${foo} will be replaced with ${foo}", 3 );
 135  0
                 append( sb, "Expression: ${maven.ear.escapeString}", 3 );
 136  0
                 append( sb, "", 0 );
 137  
 
 138  0
                 append( sb, "fileNameMapping", 2 );
 139  0
                 append( sb, "The file name mapping to use for all dependencies included in the EAR file.", 3 );
 140  0
                 append( sb, "", 0 );
 141  
 
 142  0
                 append( sb, "filtering (Default: false)", 2 );
 143  0
                 append( sb, "Specify that the ear sources should be filtered.", 3 );
 144  0
                 append( sb, "", 0 );
 145  
 
 146  0
                 append( sb, "filters", 2 );
 147  0
                 append( sb, "Filters (property files) to include during the interpolation of the pom.xml.", 3 );
 148  0
                 append( sb, "", 0 );
 149  
 
 150  0
                 append( sb, "finalName (Default: ${project.build.finalName})", 2 );
 151  0
                 append( sb, "The name of the EAR file to generate.", 3 );
 152  0
                 append( sb, "Required: Yes", 3 );
 153  0
                 append( sb, "", 0 );
 154  
 
 155  0
                 append( sb, "generatedDescriptorLocation (Default: ${project.build.directory})", 2 );
 156  0
                 append( sb, "Directory where the deployment descriptor file(s) will be auto-generated.", 3 );
 157  0
                 append( sb, "", 0 );
 158  
 
 159  0
                 append( sb, "includeLibInApplicationXml (Default: false)", 2 );
 160  0
                 append( sb, "Should libraries be added in application.xml", 3 );
 161  0
                 append( sb, "", 0 );
 162  
 
 163  0
                 append( sb, "jboss", 2 );
 164  0
                 append( sb, "The JBoss specific configuration.", 3 );
 165  0
                 append( sb, "", 0 );
 166  
 
 167  0
                 append( sb, "mainArtifactId", 2 );
 168  0
                 append( sb, "The id to use to define the main artifact (e.g. the artifact without a classifier) when there is multiple candidates.", 3 );
 169  0
                 append( sb, "", 0 );
 170  
 
 171  0
                 append( sb, "manifestFile", 2 );
 172  0
                 append( sb, "The location of the manifest file to be used within the ear file. If not value if specified, the default location in the workDirectory is taken. If the file does not exist, a manifest will be generated automatically.", 3 );
 173  0
                 append( sb, "", 0 );
 174  
 
 175  0
                 append( sb, "modules", 2 );
 176  0
                 append( sb, "The ear modules configuration.", 3 );
 177  0
                 append( sb, "", 0 );
 178  
 
 179  0
                 append( sb, "nonFilteredFileExtensions", 2 );
 180  0
                 append( sb, "A list of file extensions that should not be filtered if filtering is enabled.", 3 );
 181  0
                 append( sb, "", 0 );
 182  
 
 183  0
                 append( sb, "outputDirectory (Default: ${project.build.directory})", 2 );
 184  0
                 append( sb, "The directory for the generated EAR.", 3 );
 185  0
                 append( sb, "Required: Yes", 3 );
 186  0
                 append( sb, "", 0 );
 187  
 
 188  0
                 append( sb, "resourcesDir", 2 );
 189  0
                 append( sb, "Deprecated. please use earSourceDirectory instead", 3 );
 190  0
                 append( sb, "", 0 );
 191  0
                 append( sb, "The directory to get the resources from.", 3 );
 192  0
                 append( sb, "", 0 );
 193  
 
 194  0
                 append( sb, "unpackTypes", 2 );
 195  0
                 append( sb, "The comma separated list of artifact\'s type(s) to unpack by default.", 3 );
 196  0
                 append( sb, "", 0 );
 197  
 
 198  0
                 append( sb, "version (Default: 1.3)", 2 );
 199  0
                 append( sb, "The version of the application.xml to generate. Valid values are 1.3, 1.4, 5 and 6.", 3 );
 200  0
                 append( sb, "", 0 );
 201  
 
 202  0
                 append( sb, "workDirectory (Default: ${project.build.directory}/${project.build.finalName})", 2 );
 203  0
                 append( sb, "Directory that resources are copied to during the build.", 3 );
 204  0
                 append( sb, "Required: Yes", 3 );
 205  0
                 append( sb, "", 0 );
 206  
             }
 207  
         }
 208  
 
 209  0
         if ( goal == null || goal.length() <= 0 || "generate-application-xml".equals( goal ) )
 210  
         {
 211  0
             append( sb, "ear:generate-application-xml", 0 );
 212  0
             append( sb, "A Mojo that generates the EAR deployment descriptor file(s).", 1 );
 213  0
             append( sb, "", 0 );
 214  0
             if ( detail )
 215  
             {
 216  0
                 append( sb, "Available parameters:", 1 );
 217  0
                 append( sb, "", 0 );
 218  
 
 219  0
                 append( sb, "applicationName", 2 );
 220  0
                 append( sb, "Application name of the application to be used when the application.xml file is auto-generated. Since JavaEE6.", 3 );
 221  0
                 append( sb, "", 0 );
 222  
 
 223  0
                 append( sb, "artifactTypeMappings", 2 );
 224  0
                 append( sb, "The artifact type mappings.", 3 );
 225  0
                 append( sb, "", 0 );
 226  
 
 227  0
                 append( sb, "defaultLibBundleDir", 2 );
 228  0
                 append( sb, "The default bundle dir for libraries.", 3 );
 229  0
                 append( sb, "", 0 );
 230  
 
 231  0
                 append( sb, "description (Default: ${project.description})", 2 );
 232  0
                 append( sb, "Description of the application to be used when the application.xml file is auto-generated.", 3 );
 233  0
                 append( sb, "", 0 );
 234  
 
 235  0
                 append( sb, "displayName (Default: ${project.artifactId})", 2 );
 236  0
                 append( sb, "Display name of the application to be used when the application.xml file is auto-generated.", 3 );
 237  0
                 append( sb, "", 0 );
 238  
 
 239  0
                 append( sb, "encoding (Default: UTF-8)", 2 );
 240  0
                 append( sb, "Character encoding for the auto-generated deployment file(s).", 3 );
 241  0
                 append( sb, "", 0 );
 242  
 
 243  0
                 append( sb, "fileNameMapping", 2 );
 244  0
                 append( sb, "The file name mapping to use for all dependencies included in the EAR file.", 3 );
 245  0
                 append( sb, "", 0 );
 246  
 
 247  0
                 append( sb, "generateApplicationXml (Default: true)", 2 );
 248  0
                 append( sb, "Whether the application.xml should be generated or not.", 3 );
 249  0
                 append( sb, "", 0 );
 250  
 
 251  0
                 append( sb, "generatedDescriptorLocation (Default: ${project.build.directory})", 2 );
 252  0
                 append( sb, "Directory where the deployment descriptor file(s) will be auto-generated.", 3 );
 253  0
                 append( sb, "", 0 );
 254  
 
 255  0
                 append( sb, "generateModuleId (Default: false)", 2 );
 256  0
                 append( sb, "Whether a module ID should be generated if none is specified.", 3 );
 257  0
                 append( sb, "", 0 );
 258  
 
 259  0
                 append( sb, "includeLibInApplicationXml (Default: false)", 2 );
 260  0
                 append( sb, "Should libraries be added in application.xml", 3 );
 261  0
                 append( sb, "", 0 );
 262  
 
 263  0
                 append( sb, "initializeInOrder", 2 );
 264  0
                 append( sb, "Defines the value of the initialize in order element to be used when the application.xml file is auto-generated. When set to true, modules must be initialized in the order they\'re listed in this deployment descriptor, with the exception of application client modules, which can be initialized in any order. If initialize-in-order is not set or set to false, the order of initialization is unspecified and may be product-dependent. Since JavaEE6.", 3 );
 265  0
                 append( sb, "", 0 );
 266  
 
 267  0
                 append( sb, "jboss", 2 );
 268  0
                 append( sb, "The JBoss specific configuration.", 3 );
 269  0
                 append( sb, "", 0 );
 270  
 
 271  0
                 append( sb, "mainArtifactId", 2 );
 272  0
                 append( sb, "The id to use to define the main artifact (e.g. the artifact without a classifier) when there is multiple candidates.", 3 );
 273  0
                 append( sb, "", 0 );
 274  
 
 275  0
                 append( sb, "modules", 2 );
 276  0
                 append( sb, "The ear modules configuration.", 3 );
 277  0
                 append( sb, "", 0 );
 278  
 
 279  0
                 append( sb, "security", 2 );
 280  0
                 append( sb, "The security-roles to be added to the auto-generated application.xml file.", 3 );
 281  0
                 append( sb, "", 0 );
 282  
 
 283  0
                 append( sb, "version (Default: 1.3)", 2 );
 284  0
                 append( sb, "The version of the application.xml to generate. Valid values are 1.3, 1.4, 5 and 6.", 3 );
 285  0
                 append( sb, "", 0 );
 286  
 
 287  0
                 append( sb, "workDirectory (Default: ${project.build.directory}/${project.build.finalName})", 2 );
 288  0
                 append( sb, "Directory that resources are copied to during the build.", 3 );
 289  0
                 append( sb, "Required: Yes", 3 );
 290  0
                 append( sb, "", 0 );
 291  
             }
 292  
         }
 293  
 
 294  0
         if ( goal == null || goal.length() <= 0 || "help".equals( goal ) )
 295  
         {
 296  0
             append( sb, "ear:help", 0 );
 297  0
             append( sb, "Display help information on maven-ear-plugin.\nCall\n\u00a0\u00a0mvn\u00a0ear:help\u00a0-Ddetail=true\u00a0-Dgoal=<goal-name>\nto display parameter details.", 1 );
 298  0
             append( sb, "", 0 );
 299  0
             if ( detail )
 300  
             {
 301  0
                 append( sb, "Available parameters:", 1 );
 302  0
                 append( sb, "", 0 );
 303  
 
 304  0
                 append( sb, "detail (Default: false)", 2 );
 305  0
                 append( sb, "If true, display all settable properties for each goal.", 3 );
 306  0
                 append( sb, "Expression: ${detail}", 3 );
 307  0
                 append( sb, "", 0 );
 308  
 
 309  0
                 append( sb, "goal", 2 );
 310  0
                 append( sb, "The name of the goal for which to show help. If unspecified, all goals will be displayed.", 3 );
 311  0
                 append( sb, "Expression: ${goal}", 3 );
 312  0
                 append( sb, "", 0 );
 313  
 
 314  0
                 append( sb, "indentSize (Default: 2)", 2 );
 315  0
                 append( sb, "The number of spaces per indentation level, should be positive.", 3 );
 316  0
                 append( sb, "Expression: ${indentSize}", 3 );
 317  0
                 append( sb, "", 0 );
 318  
 
 319  0
                 append( sb, "lineLength (Default: 80)", 2 );
 320  0
                 append( sb, "The maximum length of a display line, should be positive.", 3 );
 321  0
                 append( sb, "Expression: ${lineLength}", 3 );
 322  0
                 append( sb, "", 0 );
 323  
             }
 324  
         }
 325  
 
 326  0
         if ( getLog().isInfoEnabled() )
 327  
         {
 328  0
             getLog().info( sb.toString() );
 329  
         }
 330  0
     }
 331  
 
 332  
     /**
 333  
      * <p>Repeat a String <code>n</code> times to form a new string.</p>
 334  
      *
 335  
      * @param str String to repeat
 336  
      * @param repeat number of times to repeat str
 337  
      * @return String with repeated String
 338  
      * @throws NegativeArraySizeException if <code>repeat < 0</code>
 339  
      * @throws NullPointerException if str is <code>null</code>
 340  
      */
 341  
     private static String repeat( String str, int repeat )
 342  
     {
 343  0
         StringBuffer buffer = new StringBuffer( repeat * str.length() );
 344  
 
 345  0
         for ( int i = 0; i < repeat; i++ )
 346  
         {
 347  0
             buffer.append( str );
 348  
         }
 349  
 
 350  0
         return buffer.toString();
 351  
     }
 352  
 
 353  
     /** 
 354  
      * Append a description to the buffer by respecting the indentSize and lineLength parameters.
 355  
      * <b>Note</b>: The last character is always a new line.
 356  
      * 
 357  
      * @param sb The buffer to append the description, not <code>null</code>.
 358  
      * @param description The description, not <code>null</code>.
 359  
      * @param indent The base indentation level of each line, must not be negative.
 360  
      */
 361  
     private void append( StringBuffer sb, String description, int indent )
 362  
     {
 363  0
         for ( Iterator it = toLines( description, indent, indentSize, lineLength ).iterator(); it.hasNext(); )
 364  
         {
 365  0
             sb.append( it.next().toString() ).append( '\n' );
 366  
         }
 367  0
     }
 368  
 
 369  
     /** 
 370  
      * Splits the specified text into lines of convenient display length.
 371  
      * 
 372  
      * @param text The text to split into lines, must not be <code>null</code>.
 373  
      * @param indent The base indentation level of each line, must not be negative.
 374  
      * @param indentSize The size of each indentation, must not be negative.
 375  
      * @param lineLength The length of the line, must not be negative.
 376  
      * @return The sequence of display lines, never <code>null</code>.
 377  
      * @throws NegativeArraySizeException if <code>indent < 0</code>
 378  
      */
 379  
     private static List toLines( String text, int indent, int indentSize, int lineLength )
 380  
     {
 381  0
         List lines = new ArrayList();
 382  
 
 383  0
         String ind = repeat( "\t", indent );
 384  0
         String[] plainLines = text.split( "(\r\n)|(\r)|(\n)" );
 385  0
         for ( int i = 0; i < plainLines.length; i++ )
 386  
         {
 387  0
             toLines( lines, ind + plainLines[i], indentSize, lineLength );
 388  
         }
 389  
 
 390  0
         return lines;
 391  
     }
 392  
 
 393  
     /** 
 394  
      * Adds the specified line to the output sequence, performing line wrapping if necessary.
 395  
      * 
 396  
      * @param lines The sequence of display lines, must not be <code>null</code>.
 397  
      * @param line The line to add, must not be <code>null</code>.
 398  
      * @param indentSize The size of each indentation, must not be negative.
 399  
      * @param lineLength The length of the line, must not be negative.
 400  
      */
 401  
     private static void toLines( List lines, String line, int indentSize, int lineLength )
 402  
     {
 403  0
         int lineIndent = getIndentLevel( line );
 404  0
         StringBuffer buf = new StringBuffer( 256 );
 405  0
         String[] tokens = line.split( " +" );
 406  0
         for ( int i = 0; i < tokens.length; i++ )
 407  
         {
 408  0
             String token = tokens[i];
 409  0
             if ( i > 0 )
 410  
             {
 411  0
                 if ( buf.length() + token.length() >= lineLength )
 412  
                 {
 413  0
                     lines.add( buf.toString() );
 414  0
                     buf.setLength( 0 );
 415  0
                     buf.append( repeat( " ", lineIndent * indentSize ) );
 416  
                 }
 417  
                 else
 418  
                 {
 419  0
                     buf.append( ' ' );
 420  
                 }
 421  
             }
 422  0
             for ( int j = 0; j < token.length(); j++ )
 423  
             {
 424  0
                 char c = token.charAt( j );
 425  0
                 if ( c == '\t' )
 426  
                 {
 427  0
                     buf.append( repeat( " ", indentSize - buf.length() % indentSize ) );
 428  
                 }
 429  0
                 else if ( c == '\u00A0' )
 430  
                 {
 431  0
                     buf.append( ' ' );
 432  
                 }
 433  
                 else
 434  
                 {
 435  0
                     buf.append( c );
 436  
                 }
 437  
             }
 438  
         }
 439  0
         lines.add( buf.toString() );
 440  0
     }
 441  
 
 442  
     /** 
 443  
      * Gets the indentation level of the specified line.
 444  
      * 
 445  
      * @param line The line whose indentation level should be retrieved, must not be <code>null</code>.
 446  
      * @return The indentation level of the line.
 447  
      */
 448  
     private static int getIndentLevel( String line )
 449  
     {
 450  0
         int level = 0;
 451  0
         for ( int i = 0; i < line.length() && line.charAt( i ) == '\t'; i++ )
 452  
         {
 453  0
             level++;
 454  
         }
 455  0
         for ( int i = level + 1; i <= level + 4 && i < line.length(); i++ )
 456  
         {
 457  0
             if ( line.charAt( i ) == '\t' )
 458  
             {
 459  0
                 level++;
 460  0
                 break;
 461  
             }
 462  
         }
 463  0
         return level;
 464  
     }
 465  
 }