Coverage Report - org.apache.maven.report.projectinfo.HelpMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
HelpMojo
0%
0/227
0%
0/146
8
 
 1  
 package org.apache.maven.report.projectinfo;
 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-project-info-reports-plugin. Call <pre>  mvn project-info-reports:help -Ddetail=true -Dgoal=&lt;goal-name&gt;</pre> to display parameter details.
 12  
  *
 13  
  * @version generated on Fri Jul 25 10:16:00 EDT 2008
 14  
  * @goal help
 15  
  * @requiresProject false
 16  
  */
 17  0
 public class HelpMojo
 18  
     extends AbstractMojo
 19  
 {
 20  
     /**
 21  
      * If <code>true</code>, display all settable properties for each goal.
 22  
      * 
 23  
      * @parameter expression="${detail}" default-value="false"
 24  
      */
 25  
     private boolean detail;
 26  
 
 27  
     /**
 28  
      * The name of the goal for which to show help. If unspecified, all goals will be displayed.
 29  
      * 
 30  
      * @parameter expression="${goal}"
 31  
      */
 32  
     private java.lang.String goal;
 33  
 
 34  
     /**
 35  
      * The maximum length of a display line.
 36  
      * 
 37  
      * @parameter expression="${lineLength}" default-value="80"
 38  
      */
 39  
     private int lineLength;
 40  
 
 41  
     /**
 42  
      * The number of spaces per indentation level.
 43  
      * 
 44  
      * @parameter expression="${indentSize}" default-value="2"
 45  
      */
 46  
     private int indentSize;
 47  
 
 48  
 
 49  
     /** {@inheritDoc} */
 50  
     public void execute()
 51  
         throws MojoExecutionException
 52  
     {
 53  0
         StringBuffer sb = new StringBuffer();
 54  
 
 55  0
         append( sb, "org.apache.maven.plugins:maven-project-info-reports-plugin:2.1", 0 );
 56  0
         append( sb, "", 0 );
 57  
 
 58  0
         append( sb, "Maven Project Info Reports Plugin 2.1", 0 );
 59  0
         append( sb, "The Maven Project Info Reports Plugin is a plugin that generates standard reports for the specified project.", 1 );
 60  0
         append( sb, "", 0 );
 61  
 
 62  0
         if ( goal == null || goal.length() <= 0 )
 63  
         {
 64  0
             append( sb, "This plugin has 14 goals:", 0 );
 65  0
             append( sb, "", 0 );
 66  
         }
 67  
 
 68  0
         if ( goal == null || goal.length() <= 0 || "cim".equals( goal ) )
 69  
         {
 70  0
             append( sb, "project-info-reports:cim", 0 );
 71  0
             append( sb, "Generates the Project Continuous Integration System report.", 1 );
 72  0
             append( sb, "", 0 );
 73  0
             if ( detail )
 74  
             {
 75  0
                 append( sb, "Available parameters:", 1 );
 76  0
                 append( sb, "", 0 );
 77  
 
 78  0
                 append( sb, "outputDirectory", 2 );
 79  0
                 append( sb, "The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from the command line. If the goal is run indirectly as part of a site generation, the output directory configured in the Maven Site Plugin is used instead.", 3 );
 80  0
                 append( sb, "", 0 );
 81  
             }
 82  
         }
 83  
 
 84  0
         if ( goal == null || goal.length() <= 0 || "dependencies".equals( goal ) )
 85  
         {
 86  0
             append( sb, "project-info-reports:dependencies", 0 );
 87  0
             append( sb, "Generates the Project Dependencies report.", 1 );
 88  0
             append( sb, "", 0 );
 89  0
             if ( detail )
 90  
             {
 91  0
                 append( sb, "Available parameters:", 1 );
 92  0
                 append( sb, "", 0 );
 93  
 
 94  0
                 append( sb, "dependencyDetailsEnabled (Default: true)", 2 );
 95  0
                 append( sb, "Display file details for each dependency, such as: file size, number of classes, number of packages etc.", 3 );
 96  0
                 append( sb, "", 0 );
 97  
 
 98  0
                 append( sb, "dependencyLocationsEnabled (Default: true)", 2 );
 99  0
                 append( sb, "Display the repository locations of the dependencies. If Maven is configured to be offline, this parameter will be ignored.", 3 );
 100  0
                 append( sb, "", 0 );
 101  
 
 102  0
                 append( sb, "outputDirectory", 2 );
 103  0
                 append( sb, "The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from the command line. If the goal is run indirectly as part of a site generation, the output directory configured in the Maven Site Plugin is used instead.", 3 );
 104  0
                 append( sb, "", 0 );
 105  
             }
 106  
         }
 107  
 
 108  0
         if ( goal == null || goal.length() <= 0 || "dependency-convergence".equals( goal ) )
 109  
         {
 110  0
             append( sb, "project-info-reports:dependency-convergence", 0 );
 111  0
             append( sb, "Generates the Dependency Convergence report for reactor builds.", 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, "outputDirectory", 2 );
 119  0
                 append( sb, "The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from the command line. If the goal is run indirectly as part of a site generation, the output directory configured in the Maven Site Plugin is used instead.", 3 );
 120  0
                 append( sb, "", 0 );
 121  
             }
 122  
         }
 123  
 
 124  0
         if ( goal == null || goal.length() <= 0 || "dependency-management".equals( goal ) )
 125  
         {
 126  0
             append( sb, "project-info-reports:dependency-management", 0 );
 127  0
             append( sb, "Generates the Project Dependency Management report.", 1 );
 128  0
             append( sb, "", 0 );
 129  0
             if ( detail )
 130  
             {
 131  0
                 append( sb, "Available parameters:", 1 );
 132  0
                 append( sb, "", 0 );
 133  
 
 134  0
                 append( sb, "outputDirectory", 2 );
 135  0
                 append( sb, "The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from the command line. If the goal is run indirectly as part of a site generation, the output directory configured in the Maven Site Plugin is used instead.", 3 );
 136  0
                 append( sb, "", 0 );
 137  
 
 138  0
                 append( sb, "remoteRepositories", 2 );
 139  0
                 append( sb, "Remote repositories used for the project.", 3 );
 140  0
                 append( sb, "", 0 );
 141  
             }
 142  
         }
 143  
 
 144  0
         if ( goal == null || goal.length() <= 0 || "help".equals( goal ) )
 145  
         {
 146  0
             append( sb, "project-info-reports:help", 0 );
 147  0
             append( sb, "Display help information on maven-project-info-reports-plugin. Call\n\u00a0\u00a0mvn\u00a0project-info-reports:help\u00a0-Ddetail=true\u00a0-Dgoal=<goal-name>\nto display parameter details.", 1 );
 148  0
             append( sb, "", 0 );
 149  0
             if ( detail )
 150  
             {
 151  0
                 append( sb, "Available parameters:", 1 );
 152  0
                 append( sb, "", 0 );
 153  
 
 154  0
                 append( sb, "detail (Default: false)", 2 );
 155  0
                 append( sb, "If true, display all settable properties for each goal.", 3 );
 156  0
                 append( sb, "", 0 );
 157  
 
 158  0
                 append( sb, "goal", 2 );
 159  0
                 append( sb, "The name of the goal for which to show help. If unspecified, all goals will be displayed.", 3 );
 160  0
                 append( sb, "", 0 );
 161  
 
 162  0
                 append( sb, "lineLength (Default: 80)", 2 );
 163  0
                 append( sb, "The maximum length of a display line.", 3 );
 164  0
                 append( sb, "", 0 );
 165  
 
 166  0
                 append( sb, "indentSize (Default: 2)", 2 );
 167  0
                 append( sb, "The number of spaces per indentation level.", 3 );
 168  0
                 append( sb, "", 0 );
 169  
             }
 170  
         }
 171  
 
 172  0
         if ( goal == null || goal.length() <= 0 || "index".equals( goal ) )
 173  
         {
 174  0
             append( sb, "project-info-reports:index", 0 );
 175  0
             append( sb, "Generates the project index page.", 1 );
 176  0
             append( sb, "", 0 );
 177  0
             if ( detail )
 178  
             {
 179  0
                 append( sb, "Available parameters:", 1 );
 180  0
                 append( sb, "", 0 );
 181  
 
 182  0
                 append( sb, "outputDirectory", 2 );
 183  0
                 append( sb, "The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from the command line. If the goal is run indirectly as part of a site generation, the output directory configured in the Maven Site Plugin is used instead.", 3 );
 184  0
                 append( sb, "", 0 );
 185  
             }
 186  
         }
 187  
 
 188  0
         if ( goal == null || goal.length() <= 0 || "issue-tracking".equals( goal ) )
 189  
         {
 190  0
             append( sb, "project-info-reports:issue-tracking", 0 );
 191  0
             append( sb, "Generates the Project Issue Tracking report.", 1 );
 192  0
             append( sb, "", 0 );
 193  0
             if ( detail )
 194  
             {
 195  0
                 append( sb, "Available parameters:", 1 );
 196  0
                 append( sb, "", 0 );
 197  
 
 198  0
                 append( sb, "outputDirectory", 2 );
 199  0
                 append( sb, "The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from the command line. If the goal is run indirectly as part of a site generation, the output directory configured in the Maven Site Plugin is used instead.", 3 );
 200  0
                 append( sb, "", 0 );
 201  
             }
 202  
         }
 203  
 
 204  0
         if ( goal == null || goal.length() <= 0 || "license".equals( goal ) )
 205  
         {
 206  0
             append( sb, "project-info-reports:license", 0 );
 207  0
             append( sb, "Generates the Project License report.", 1 );
 208  0
             append( sb, "", 0 );
 209  0
             if ( detail )
 210  
             {
 211  0
                 append( sb, "Available parameters:", 1 );
 212  0
                 append( sb, "", 0 );
 213  
 
 214  0
                 append( sb, "offline", 2 );
 215  0
                 append( sb, "Whether the system is currently offline.", 3 );
 216  0
                 append( sb, "", 0 );
 217  
 
 218  0
                 append( sb, "outputDirectory", 2 );
 219  0
                 append( sb, "The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from the command line. If the goal is run indirectly as part of a site generation, the output directory configured in the Maven Site Plugin is used instead.", 3 );
 220  0
                 append( sb, "", 0 );
 221  
             }
 222  
         }
 223  
 
 224  0
         if ( goal == null || goal.length() <= 0 || "mailing-list".equals( goal ) )
 225  
         {
 226  0
             append( sb, "project-info-reports:mailing-list", 0 );
 227  0
             append( sb, "Generates the Mailing List report.", 1 );
 228  0
             append( sb, "", 0 );
 229  0
             if ( detail )
 230  
             {
 231  0
                 append( sb, "Available parameters:", 1 );
 232  0
                 append( sb, "", 0 );
 233  
 
 234  0
                 append( sb, "outputDirectory", 2 );
 235  0
                 append( sb, "The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from the command line. If the goal is run indirectly as part of a site generation, the output directory configured in the Maven Site Plugin is used instead.", 3 );
 236  0
                 append( sb, "", 0 );
 237  
             }
 238  
         }
 239  
 
 240  0
         if ( goal == null || goal.length() <= 0 || "plugin-management".equals( goal ) )
 241  
         {
 242  0
             append( sb, "project-info-reports:plugin-management", 0 );
 243  0
             append( sb, "Generates the Project Plugin Management report.", 1 );
 244  0
             append( sb, "", 0 );
 245  0
             if ( detail )
 246  
             {
 247  0
                 append( sb, "Available parameters:", 1 );
 248  0
                 append( sb, "", 0 );
 249  
 
 250  0
                 append( sb, "outputDirectory", 2 );
 251  0
                 append( sb, "The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from the command line. If the goal is run indirectly as part of a site generation, the output directory configured in the Maven Site Plugin is used instead.", 3 );
 252  0
                 append( sb, "", 0 );
 253  
             }
 254  
         }
 255  
 
 256  0
         if ( goal == null || goal.length() <= 0 || "plugins".equals( goal ) )
 257  
         {
 258  0
             append( sb, "project-info-reports:plugins", 0 );
 259  0
             append( sb, "Generates the Project Plugins report.", 1 );
 260  0
             append( sb, "", 0 );
 261  0
             if ( detail )
 262  
             {
 263  0
                 append( sb, "Available parameters:", 1 );
 264  0
                 append( sb, "", 0 );
 265  
 
 266  0
                 append( sb, "outputDirectory", 2 );
 267  0
                 append( sb, "The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from the command line. If the goal is run indirectly as part of a site generation, the output directory configured in the Maven Site Plugin is used instead.", 3 );
 268  0
                 append( sb, "", 0 );
 269  
             }
 270  
         }
 271  
 
 272  0
         if ( goal == null || goal.length() <= 0 || "project-team".equals( goal ) )
 273  
         {
 274  0
             append( sb, "project-info-reports:project-team", 0 );
 275  0
             append( sb, "Generates the Project Team report.", 1 );
 276  0
             append( sb, "", 0 );
 277  0
             if ( detail )
 278  
             {
 279  0
                 append( sb, "Available parameters:", 1 );
 280  0
                 append( sb, "", 0 );
 281  
 
 282  0
                 append( sb, "outputDirectory", 2 );
 283  0
                 append( sb, "The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from the command line. If the goal is run indirectly as part of a site generation, the output directory configured in the Maven Site Plugin is used instead.", 3 );
 284  0
                 append( sb, "", 0 );
 285  
             }
 286  
         }
 287  
 
 288  0
         if ( goal == null || goal.length() <= 0 || "scm".equals( goal ) )
 289  
         {
 290  0
             append( sb, "project-info-reports:scm", 0 );
 291  0
             append( sb, "Generates the Project Source Code Management (SCM) report.", 1 );
 292  0
             append( sb, "", 0 );
 293  0
             if ( detail )
 294  
             {
 295  0
                 append( sb, "Available parameters:", 1 );
 296  0
                 append( sb, "", 0 );
 297  
 
 298  0
                 append( sb, "anonymousConnection (Default: ${project.scm.connection})", 2 );
 299  0
                 append( sb, "The SCM anonymous connection url respecting the SCM URL Format.", 3 );
 300  0
                 append( sb, "", 0 );
 301  
 
 302  0
                 append( sb, "checkoutDirectoryName", 2 );
 303  0
                 append( sb, "The directory name to checkout right after the SCM url.", 3 );
 304  0
                 append( sb, "", 0 );
 305  
 
 306  0
                 append( sb, "developerConnection (Default: ${project.scm.developerConnection})", 2 );
 307  0
                 append( sb, "The SCM developer connection url respecting the SCM URL Format.", 3 );
 308  0
                 append( sb, "", 0 );
 309  
 
 310  0
                 append( sb, "outputDirectory", 2 );
 311  0
                 append( sb, "The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from the command line. If the goal is run indirectly as part of a site generation, the output directory configured in the Maven Site Plugin is used instead.", 3 );
 312  0
                 append( sb, "", 0 );
 313  
 
 314  0
                 append( sb, "webAccessUrl (Default: ${project.scm.url})", 2 );
 315  0
                 append( sb, "The SCM web access url.", 3 );
 316  0
                 append( sb, "", 0 );
 317  
             }
 318  
         }
 319  
 
 320  0
         if ( goal == null || goal.length() <= 0 || "summary".equals( goal ) )
 321  
         {
 322  0
             append( sb, "project-info-reports:summary", 0 );
 323  0
             append( sb, "Generates the project information reports summary.", 1 );
 324  0
             append( sb, "", 0 );
 325  0
             if ( detail )
 326  
             {
 327  0
                 append( sb, "Available parameters:", 1 );
 328  0
                 append( sb, "", 0 );
 329  
 
 330  0
                 append( sb, "outputDirectory", 2 );
 331  0
                 append( sb, "The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from the command line. If the goal is run indirectly as part of a site generation, the output directory configured in the Maven Site Plugin is used instead.", 3 );
 332  0
                 append( sb, "", 0 );
 333  
             }
 334  
         }
 335  
 
 336  0
         if ( getLog().isInfoEnabled() )
 337  
         {
 338  0
             getLog().info( sb.toString() );
 339  
         }
 340  0
     }
 341  
 
 342  
     /**
 343  
      * <p>Repeat a String <code>n</code> times to form a new string.</p>
 344  
      *
 345  
      * @param str String to repeat
 346  
      * @param repeat number of times to repeat str
 347  
      * @return String with repeated String
 348  
      * @throws NegativeArraySizeException if <code>repeat < 0</code>
 349  
      * @throws NullPointerException if str is <code>null</code>
 350  
      */
 351  
     private static String repeat( String str, int repeat )
 352  
     {
 353  0
         StringBuffer buffer = new StringBuffer( repeat * str.length() );
 354  
 
 355  0
         for ( int i = 0; i < repeat; i++ )
 356  
         {
 357  0
             buffer.append( str );
 358  
         }
 359  
 
 360  0
         return buffer.toString();
 361  
     }
 362  
 
 363  
     private void append( StringBuffer sb, String description, int indent )
 364  
     {
 365  0
         for ( Iterator it = toLines( description, indent ).iterator(); it.hasNext(); )
 366  
         {
 367  0
             sb.append( it.next().toString() ).append( '\n' );
 368  
         }
 369  0
     }
 370  
 
 371  
     /** 
 372  
      * Splits the specified text into lines of convenient display length.
 373  
      * 
 374  
      * @param text The text to split into lines, must not be <code>null</code>.
 375  
      * @param indent The base indentation level of each line, must not be negative.
 376  
      * @return The sequence of display lines, never <code>null</code>.
 377  
      */
 378  
     private List toLines( String text, int indent )
 379  
     {
 380  0
         List lines = new ArrayList();
 381  
 
 382  0
         String ind = repeat( "\t", indent );
 383  0
         String[] plainLines = text.split( "(\r\n)|(\r)|(\n)" );
 384  0
         for ( int i = 0; i < plainLines.length; i++ )
 385  
         {
 386  0
             toLines( lines, ind + plainLines[i] );
 387  
         }
 388  
 
 389  0
         return lines;
 390  
     }
 391  
 
 392  
     /** 
 393  
      * Adds the specified line to the output sequence, performing line wrapping if necessary.
 394  
      * 
 395  
      * @param lines The sequence of display lines, must not be <code>null</code>.
 396  
      * @param line The line to add, must not be <code>null</code>.
 397  
      */
 398  
     private void toLines( List lines, String line )
 399  
     {
 400  0
         int lineIndent = getIndentLevel( line );
 401  0
         StringBuffer buf = new StringBuffer( 256 );
 402  0
         String[] tokens = line.split( " +" );
 403  0
         for ( int i = 0; i < tokens.length; i++ )
 404  
         {
 405  0
             String token = tokens[i];
 406  0
             if ( i > 0 )
 407  
             {
 408  0
                 if ( buf.length() + token.length() >= lineLength )
 409  
                 {
 410  0
                     lines.add( buf.toString() );
 411  0
                     buf.setLength( 0 );
 412  0
                     buf.append( repeat( " ", lineIndent * indentSize ) );
 413  
                 }
 414  
                 else
 415  
                 {
 416  0
                     buf.append( ' ' );
 417  
                 }
 418  
             }
 419  0
             for ( int j = 0; j < token.length(); j++ )
 420  
             {
 421  0
                 char c = token.charAt( j );
 422  0
                 if ( c == '\t' )
 423  
                 {
 424  0
                     buf.append( repeat( " ", indentSize - buf.length() % indentSize ) );
 425  
                 }
 426  0
                 else if ( c == '\u00A0' )
 427  
                 {
 428  0
                     buf.append( ' ' );
 429  
                 }
 430  
                 else
 431  
                 {
 432  0
                     buf.append( c );
 433  
                 }
 434  
             }
 435  
         }
 436  0
         lines.add( buf.toString() );
 437  0
     }
 438  
 
 439  
     /** 
 440  
      * Gets the indentation level of the specified line.
 441  
      * 
 442  
      * @param line The line whose indentation level should be retrieved, must not be <code>null</code>.
 443  
      * @return The indentation level of the line.
 444  
      */
 445  
     private static int getIndentLevel( String line )
 446  
     {
 447  0
         int level = 0;
 448  0
         for ( int i = 0; i < line.length() && line.charAt( i ) == '\t'; i++ )
 449  
         {
 450  0
             level++;
 451  
         }
 452  0
         for ( int i = level + 1; i <= level + 4 && i < line.length(); i++ )
 453  
         {
 454  0
             if ( line.charAt( i ) == '\t' )
 455  
             {
 456  0
                 level++;
 457  0
                 break;
 458  
             }
 459  
         }
 460  0
         return level;
 461  
     }
 462  
 }