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