Coverage Report - org.apache.maven.plugins.jarsigner.HelpMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
HelpMojo
0%
0/208
0%
0/62
4,667
 
 1  
 package org.apache.maven.plugins.jarsigner;
 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-jarsigner-plugin.<br/> Call <pre>  mvn jarsigner:help -Ddetail=true -Dgoal=&lt;goal-name&gt;</pre> to display parameter details.
 12  
  *
 13  
  * @version generated on Sat Sep 26 17:41:52 CEST 2009
 14  
  * @author org.apache.maven.tools.plugin.generator.PluginHelpGenerator (version 2.5)
 15  
  * @goal help
 16  
  * @requiresProject false
 17  
  */
 18  0
 public class HelpMojo
 19  
     extends AbstractMojo
 20  
 {
 21  
     /**
 22  
      * If <code>true</code>, display all settable properties for each goal.
 23  
      * 
 24  
      * @parameter expression="${detail}" default-value="false"
 25  
      */
 26  
     private boolean detail;
 27  
 
 28  
     /**
 29  
      * The name of the goal for which to show help. If unspecified, all goals will be displayed.
 30  
      * 
 31  
      * @parameter expression="${goal}"
 32  
      */
 33  
     private java.lang.String goal;
 34  
 
 35  
     /**
 36  
      * The maximum length of a display line, should be positive.
 37  
      * 
 38  
      * @parameter expression="${lineLength}" default-value="80"
 39  
      */
 40  
     private int lineLength;
 41  
 
 42  
     /**
 43  
      * The number of spaces per indentation level, should be positive.
 44  
      * 
 45  
      * @parameter expression="${indentSize}" default-value="2"
 46  
      */
 47  
     private int indentSize;
 48  
 
 49  
 
 50  
     /** {@inheritDoc} */
 51  
     public void execute()
 52  
         throws MojoExecutionException
 53  
     {
 54  0
         if ( lineLength <= 0 )
 55  
         {
 56  0
             getLog().warn( "The parameter 'lineLength' should be positive, using '80' as default." );
 57  0
             lineLength = 80;
 58  
         }
 59  0
         if ( indentSize <= 0 )
 60  
         {
 61  0
             getLog().warn( "The parameter 'indentSize' should be positive, using '2' as default." );
 62  0
             indentSize = 2;
 63  
         }
 64  
 
 65  0
         StringBuffer sb = new StringBuffer();
 66  
 
 67  0
         append( sb, "org.apache.maven.plugins:maven-jarsigner-plugin:1.2", 0 );
 68  0
         append( sb, "", 0 );
 69  
 
 70  0
         append( sb, "Maven Jarsigner Plugin", 0 );
 71  0
         append( sb, "Signs or verifies a project artifact and attachments using jarsigner.", 1 );
 72  0
         append( sb, "", 0 );
 73  
 
 74  0
         if ( goal == null || goal.length() <= 0 )
 75  
         {
 76  0
             append( sb, "This plugin has 3 goals:", 0 );
 77  0
             append( sb, "", 0 );
 78  
         }
 79  
 
 80  0
         if ( goal == null || goal.length() <= 0 || "help".equals( goal ) )
 81  
         {
 82  0
             append( sb, "jarsigner:help", 0 );
 83  0
             append( sb, "Display help information on maven-jarsigner-plugin.\nCall\n\u00a0\u00a0mvn\u00a0jarsigner:help\u00a0-Ddetail=true\u00a0-Dgoal=<goal-name>\nto display parameter details.", 1 );
 84  0
             append( sb, "", 0 );
 85  0
             if ( detail )
 86  
             {
 87  0
                 append( sb, "Available parameters:", 1 );
 88  0
                 append( sb, "", 0 );
 89  
 
 90  0
                 append( sb, "detail (Default: false)", 2 );
 91  0
                 append( sb, "If true, display all settable properties for each goal.", 3 );
 92  0
                 append( sb, "", 0 );
 93  
 
 94  0
                 append( sb, "goal", 2 );
 95  0
                 append( sb, "The name of the goal for which to show help. If unspecified, all goals will be displayed.", 3 );
 96  0
                 append( sb, "", 0 );
 97  
 
 98  0
                 append( sb, "indentSize (Default: 2)", 2 );
 99  0
                 append( sb, "The number of spaces per indentation level, should be positive.", 3 );
 100  0
                 append( sb, "", 0 );
 101  
 
 102  0
                 append( sb, "lineLength (Default: 80)", 2 );
 103  0
                 append( sb, "The maximum length of a display line, should be positive.", 3 );
 104  0
                 append( sb, "", 0 );
 105  
             }
 106  
         }
 107  
 
 108  0
         if ( goal == null || goal.length() <= 0 || "sign".equals( goal ) )
 109  
         {
 110  0
             append( sb, "jarsigner:sign", 0 );
 111  0
             append( sb, "Signs a project artifact and attachments using jarsigner.", 1 );
 112  0
             append( sb, "", 0 );
 113  0
             if ( detail )
 114  
             {
 115  0
                 append( sb, "Available parameters:", 1 );
 116  0
                 append( sb, "", 0 );
 117  
 
 118  0
                 append( sb, "alias", 2 );
 119  0
                 append( sb, "See options.", 3 );
 120  0
                 append( sb, "", 0 );
 121  
 
 122  0
                 append( sb, "archive", 2 );
 123  0
                 append( sb, "Archive to process. If set, neither the project artifact nor any attachments or archive sets are processed.", 3 );
 124  0
                 append( sb, "", 0 );
 125  
 
 126  0
                 append( sb, "archiveDirectory", 2 );
 127  0
                 append( sb, "The base directory to scan for JAR files using Ant-like inclusion/exclusion patterns.", 3 );
 128  0
                 append( sb, "", 0 );
 129  
 
 130  0
                 append( sb, "arguments", 2 );
 131  0
                 append( sb, "List of additional arguments to append to the jarsigner command line.", 3 );
 132  0
                 append( sb, "", 0 );
 133  
 
 134  0
                 append( sb, "attachments", 2 );
 135  0
                 append( sb, "Deprecated. As of version 1.1 in favor of the new parameter processAttachedArtifacts.", 3 );
 136  0
                 append( sb, "", 0 );
 137  0
                 append( sb, "Controls processing of project attachments.", 3 );
 138  0
                 append( sb, "", 0 );
 139  
 
 140  0
                 append( sb, "excludeClassifiers", 2 );
 141  0
                 append( sb, "A set of artifact classifiers describing the project attachments that should not be processed. This parameter is only relevant if processAttachedArtifacts is true. If empty, no attachments are excluded.", 3 );
 142  0
                 append( sb, "", 0 );
 143  
 
 144  0
                 append( sb, "excludes", 2 );
 145  0
                 append( sb, "The Ant-like exclusion patterns used to exclude JAR files from processing. The patterns must be relative to the directory given by the parameter archiveDirectory.", 3 );
 146  0
                 append( sb, "", 0 );
 147  
 
 148  0
                 append( sb, "includeClassifiers", 2 );
 149  0
                 append( sb, "A set of artifact classifiers describing the project attachments that should be processed. This parameter is only relevant if processAttachedArtifacts is true. If empty, all attachments are included.", 3 );
 150  0
                 append( sb, "", 0 );
 151  
 
 152  0
                 append( sb, "includes", 2 );
 153  0
                 append( sb, "The Ant-like inclusion patterns used to select JAR files to process. The patterns must be relative to the directory given by the parameter archiveDirectory. By default, the pattern **/*.?ar is used.", 3 );
 154  0
                 append( sb, "", 0 );
 155  
 
 156  0
                 append( sb, "keypass", 2 );
 157  0
                 append( sb, "See options.", 3 );
 158  0
                 append( sb, "", 0 );
 159  
 
 160  0
                 append( sb, "keystore", 2 );
 161  0
                 append( sb, "See options.", 3 );
 162  0
                 append( sb, "", 0 );
 163  
 
 164  0
                 append( sb, "maxMemory", 2 );
 165  0
                 append( sb, "The maximum memory available to the JAR signer, e.g. 256M. See -Xmx for more details.", 3 );
 166  0
                 append( sb, "", 0 );
 167  
 
 168  0
                 append( sb, "processAttachedArtifacts (Default: true)", 2 );
 169  0
                 append( sb, "Controls processing of project attachments. If enabled, attached artifacts that are no JAR/ZIP files will be automatically excluded from processing.", 3 );
 170  0
                 append( sb, "", 0 );
 171  
 
 172  0
                 append( sb, "processMainArtifact (Default: true)", 2 );
 173  0
                 append( sb, "Controls processing of the main artifact produced by the project.", 3 );
 174  0
                 append( sb, "", 0 );
 175  
 
 176  0
                 append( sb, "providerArg", 2 );
 177  0
                 append( sb, "See options.", 3 );
 178  0
                 append( sb, "", 0 );
 179  
 
 180  0
                 append( sb, "providerClass", 2 );
 181  0
                 append( sb, "See options.", 3 );
 182  0
                 append( sb, "", 0 );
 183  
 
 184  0
                 append( sb, "providerName", 2 );
 185  0
                 append( sb, "See options.", 3 );
 186  0
                 append( sb, "", 0 );
 187  
 
 188  0
                 append( sb, "removeExistingSignatures (Default: false)", 2 );
 189  0
                 append( sb, "Indicates whether existing signatures should be removed from the processed JAR files prior to signing them. If enabled, the resulting JAR will appear as being signed only once.", 3 );
 190  0
                 append( sb, "", 0 );
 191  
 
 192  0
                 append( sb, "sigfile", 2 );
 193  0
                 append( sb, "See options.", 3 );
 194  0
                 append( sb, "", 0 );
 195  
 
 196  0
                 append( sb, "skip (Default: false)", 2 );
 197  0
                 append( sb, "Set to true to disable the plugin.", 3 );
 198  0
                 append( sb, "", 0 );
 199  
 
 200  0
                 append( sb, "storepass", 2 );
 201  0
                 append( sb, "See options.", 3 );
 202  0
                 append( sb, "", 0 );
 203  
 
 204  0
                 append( sb, "storetype", 2 );
 205  0
                 append( sb, "See options.", 3 );
 206  0
                 append( sb, "", 0 );
 207  
 
 208  0
                 append( sb, "verbose (Default: false)", 2 );
 209  0
                 append( sb, "See options.", 3 );
 210  0
                 append( sb, "", 0 );
 211  
             }
 212  
         }
 213  
 
 214  0
         if ( goal == null || goal.length() <= 0 || "verify".equals( goal ) )
 215  
         {
 216  0
             append( sb, "jarsigner:verify", 0 );
 217  0
             append( sb, "Checks the signatures of a project artifact and attachments using jarsigner.", 1 );
 218  0
             append( sb, "", 0 );
 219  0
             if ( detail )
 220  
             {
 221  0
                 append( sb, "Available parameters:", 1 );
 222  0
                 append( sb, "", 0 );
 223  
 
 224  0
                 append( sb, "archive", 2 );
 225  0
                 append( sb, "Archive to process. If set, neither the project artifact nor any attachments or archive sets are processed.", 3 );
 226  0
                 append( sb, "", 0 );
 227  
 
 228  0
                 append( sb, "archiveDirectory", 2 );
 229  0
                 append( sb, "The base directory to scan for JAR files using Ant-like inclusion/exclusion patterns.", 3 );
 230  0
                 append( sb, "", 0 );
 231  
 
 232  0
                 append( sb, "arguments", 2 );
 233  0
                 append( sb, "List of additional arguments to append to the jarsigner command line.", 3 );
 234  0
                 append( sb, "", 0 );
 235  
 
 236  0
                 append( sb, "attachments", 2 );
 237  0
                 append( sb, "Deprecated. As of version 1.1 in favor of the new parameter processAttachedArtifacts.", 3 );
 238  0
                 append( sb, "", 0 );
 239  0
                 append( sb, "Controls processing of project attachments.", 3 );
 240  0
                 append( sb, "", 0 );
 241  
 
 242  0
                 append( sb, "certs (Default: false)", 2 );
 243  0
                 append( sb, "See options.", 3 );
 244  0
                 append( sb, "", 0 );
 245  
 
 246  0
                 append( sb, "excludeClassifiers", 2 );
 247  0
                 append( sb, "A set of artifact classifiers describing the project attachments that should not be processed. This parameter is only relevant if processAttachedArtifacts is true. If empty, no attachments are excluded.", 3 );
 248  0
                 append( sb, "", 0 );
 249  
 
 250  0
                 append( sb, "excludes", 2 );
 251  0
                 append( sb, "The Ant-like exclusion patterns used to exclude JAR files from processing. The patterns must be relative to the directory given by the parameter archiveDirectory.", 3 );
 252  0
                 append( sb, "", 0 );
 253  
 
 254  0
                 append( sb, "includeClassifiers", 2 );
 255  0
                 append( sb, "A set of artifact classifiers describing the project attachments that should be processed. This parameter is only relevant if processAttachedArtifacts is true. If empty, all attachments are included.", 3 );
 256  0
                 append( sb, "", 0 );
 257  
 
 258  0
                 append( sb, "includes", 2 );
 259  0
                 append( sb, "The Ant-like inclusion patterns used to select JAR files to process. The patterns must be relative to the directory given by the parameter archiveDirectory. By default, the pattern **/*.?ar is used.", 3 );
 260  0
                 append( sb, "", 0 );
 261  
 
 262  0
                 append( sb, "maxMemory", 2 );
 263  0
                 append( sb, "The maximum memory available to the JAR signer, e.g. 256M. See -Xmx for more details.", 3 );
 264  0
                 append( sb, "", 0 );
 265  
 
 266  0
                 append( sb, "processAttachedArtifacts (Default: true)", 2 );
 267  0
                 append( sb, "Controls processing of project attachments. If enabled, attached artifacts that are no JAR/ZIP files will be automatically excluded from processing.", 3 );
 268  0
                 append( sb, "", 0 );
 269  
 
 270  0
                 append( sb, "processMainArtifact (Default: true)", 2 );
 271  0
                 append( sb, "Controls processing of the main artifact produced by the project.", 3 );
 272  0
                 append( sb, "", 0 );
 273  
 
 274  0
                 append( sb, "skip (Default: false)", 2 );
 275  0
                 append( sb, "Set to true to disable the plugin.", 3 );
 276  0
                 append( sb, "", 0 );
 277  
 
 278  0
                 append( sb, "verbose (Default: false)", 2 );
 279  0
                 append( sb, "See options.", 3 );
 280  0
                 append( sb, "", 0 );
 281  
             }
 282  
         }
 283  
 
 284  0
         if ( getLog().isInfoEnabled() )
 285  
         {
 286  0
             getLog().info( sb.toString() );
 287  
         }
 288  0
     }
 289  
 
 290  
     /**
 291  
      * <p>Repeat a String <code>n</code> times to form a new string.</p>
 292  
      *
 293  
      * @param str String to repeat
 294  
      * @param repeat number of times to repeat str
 295  
      * @return String with repeated String
 296  
      * @throws NegativeArraySizeException if <code>repeat < 0</code>
 297  
      * @throws NullPointerException if str is <code>null</code>
 298  
      */
 299  
     private static String repeat( String str, int repeat )
 300  
     {
 301  0
         StringBuffer buffer = new StringBuffer( repeat * str.length() );
 302  
 
 303  0
         for ( int i = 0; i < repeat; i++ )
 304  
         {
 305  0
             buffer.append( str );
 306  
         }
 307  
 
 308  0
         return buffer.toString();
 309  
     }
 310  
 
 311  
     /** 
 312  
      * Append a description to the buffer by respecting the indentSize and lineLength parameters.
 313  
      * <b>Note</b>: The last character is always a new line.
 314  
      * 
 315  
      * @param sb The buffer to append the description, not <code>null</code>.
 316  
      * @param description The description, not <code>null</code>.
 317  
      * @param indent The base indentation level of each line, must not be negative.
 318  
      */
 319  
     private void append( StringBuffer sb, String description, int indent )
 320  
     {
 321  0
         for ( Iterator it = toLines( description, indent, indentSize, lineLength ).iterator(); it.hasNext(); )
 322  
         {
 323  0
             sb.append( it.next().toString() ).append( '\n' );
 324  
         }
 325  0
     }
 326  
 
 327  
     /** 
 328  
      * Splits the specified text into lines of convenient display length.
 329  
      * 
 330  
      * @param text The text to split into lines, must not be <code>null</code>.
 331  
      * @param indent The base indentation level of each line, must not be negative.
 332  
      * @param indentSize The size of each indentation, must not be negative.
 333  
      * @param lineLength The length of the line, must not be negative.
 334  
      * @return The sequence of display lines, never <code>null</code>.
 335  
      * @throws NegativeArraySizeException if <code>indent < 0</code>
 336  
      */
 337  
     private static List toLines( String text, int indent, int indentSize, int lineLength )
 338  
     {
 339  0
         List lines = new ArrayList();
 340  
 
 341  0
         String ind = repeat( "\t", indent );
 342  0
         String[] plainLines = text.split( "(\r\n)|(\r)|(\n)" );
 343  0
         for ( int i = 0; i < plainLines.length; i++ )
 344  
         {
 345  0
             toLines( lines, ind + plainLines[i], indentSize, lineLength );
 346  
         }
 347  
 
 348  0
         return lines;
 349  
     }
 350  
 
 351  
     /** 
 352  
      * Adds the specified line to the output sequence, performing line wrapping if necessary.
 353  
      * 
 354  
      * @param lines The sequence of display lines, must not be <code>null</code>.
 355  
      * @param line The line to add, must not be <code>null</code>.
 356  
      * @param indentSize The size of each indentation, must not be negative.
 357  
      * @param lineLength The length of the line, must not be negative.
 358  
      */
 359  
     private static void toLines( List lines, String line, int indentSize, int lineLength )
 360  
     {
 361  0
         int lineIndent = getIndentLevel( line );
 362  0
         StringBuffer buf = new StringBuffer( 256 );
 363  0
         String[] tokens = line.split( " +" );
 364  0
         for ( int i = 0; i < tokens.length; i++ )
 365  
         {
 366  0
             String token = tokens[i];
 367  0
             if ( i > 0 )
 368  
             {
 369  0
                 if ( buf.length() + token.length() >= lineLength )
 370  
                 {
 371  0
                     lines.add( buf.toString() );
 372  0
                     buf.setLength( 0 );
 373  0
                     buf.append( repeat( " ", lineIndent * indentSize ) );
 374  
                 }
 375  
                 else
 376  
                 {
 377  0
                     buf.append( ' ' );
 378  
                 }
 379  
             }
 380  0
             for ( int j = 0; j < token.length(); j++ )
 381  
             {
 382  0
                 char c = token.charAt( j );
 383  0
                 if ( c == '\t' )
 384  
                 {
 385  0
                     buf.append( repeat( " ", indentSize - buf.length() % indentSize ) );
 386  
                 }
 387  0
                 else if ( c == '\u00A0' )
 388  
                 {
 389  0
                     buf.append( ' ' );
 390  
                 }
 391  
                 else
 392  
                 {
 393  0
                     buf.append( c );
 394  
                 }
 395  
             }
 396  
         }
 397  0
         lines.add( buf.toString() );
 398  0
     }
 399  
 
 400  
     /** 
 401  
      * Gets the indentation level of the specified line.
 402  
      * 
 403  
      * @param line The line whose indentation level should be retrieved, must not be <code>null</code>.
 404  
      * @return The indentation level of the line.
 405  
      */
 406  
     private static int getIndentLevel( String line )
 407  
     {
 408  0
         int level = 0;
 409  0
         for ( int i = 0; i < line.length() && line.charAt( i ) == '\t'; i++ )
 410  
         {
 411  0
             level++;
 412  
         }
 413  0
         for ( int i = level + 1; i <= level + 4 && i < line.length(); i++ )
 414  
         {
 415  0
             if ( line.charAt( i ) == '\t' )
 416  
             {
 417  0
                 level++;
 418  0
                 break;
 419  
             }
 420  
         }
 421  0
         return level;
 422  
     }
 423  
 }