Coverage Report - org.apache.maven.plugin.resources.remote.HelpMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
HelpMojo
0%
0/187
0%
0/62
4.667
 
 1  
 package org.apache.maven.plugin.resources.remote;
 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-remote-resources-plugin.<br/> Call <pre>  mvn remote-resources:help -Ddetail=true -Dgoal=&lt;goal-name&gt;</pre> to display parameter details.
 12  
  *
 13  
  * @version generated on Tue Jun 14 21:26:10 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-remote-resources-plugin:1.2.1", 0 );
 69  0
         append( sb, "", 0 );
 70  
 
 71  0
         append( sb, "Maven Remote Resources Plugin", 0 );
 72  0
         append( sb, "Process resources packaged in JARs that have been deployed to a remote repository. The primary use case being satisfied is the consistent inclusion of common resources in a large set of projects. Maven projects at Apache use this plug-in to satisfy licensing requirements at Apache where each project must include license and notice files for each release.", 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 || "bundle".equals( goal ) )
 82  
         {
 83  0
             append( sb, "remote-resources:bundle", 0 );
 84  0
             append( sb, "Bundle up resources that should be considered as a remote-resource.", 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, "excludes", 2 );
 92  0
                 append( sb, "A list of files to exclude. Can contain ant-style wildcards and double wildcards.", 3 );
 93  0
                 append( sb, "", 0 );
 94  
 
 95  0
                 append( sb, "includes", 2 );
 96  0
                 append( sb, "A list of files to include. Can contain ant-style wildcards and double wildcards. The default includes are **/*.txt **/*.vm", 3 );
 97  0
                 append( sb, "", 0 );
 98  
 
 99  0
                 append( sb, "outputDirectory", 2 );
 100  0
                 append( sb, "The directory where you want the resource bundle manifest written to.", 3 );
 101  0
                 append( sb, "Expression: ${project.build.outputDirectory}", 3 );
 102  0
                 append( sb, "", 0 );
 103  
 
 104  0
                 append( sb, "resourcesDirectory", 2 );
 105  0
                 append( sb, "The directory which contains the resources you want packaged up in this resource bundle.", 3 );
 106  0
                 append( sb, "Expression: ${basedir}/src/main/resources", 3 );
 107  0
                 append( sb, "", 0 );
 108  
 
 109  0
                 append( sb, "sourceEncoding", 2 );
 110  0
                 append( sb, "Encoding of the bundle.", 3 );
 111  0
                 append( sb, "Expression: ${project.build.sourceEncoding}", 3 );
 112  0
                 append( sb, "", 0 );
 113  
             }
 114  
         }
 115  
 
 116  0
         if ( goal == null || goal.length() <= 0 || "help".equals( goal ) )
 117  
         {
 118  0
             append( sb, "remote-resources:help", 0 );
 119  0
             append( sb, "Display help information on maven-remote-resources-plugin.\nCall\n\u00a0\u00a0mvn\u00a0remote-resources:help\u00a0-Ddetail=true\u00a0-Dgoal=<goal-name>\nto display parameter details.", 1 );
 120  0
             append( sb, "", 0 );
 121  0
             if ( detail )
 122  
             {
 123  0
                 append( sb, "Available parameters:", 1 );
 124  0
                 append( sb, "", 0 );
 125  
 
 126  0
                 append( sb, "detail (Default: false)", 2 );
 127  0
                 append( sb, "If true, display all settable properties for each goal.", 3 );
 128  0
                 append( sb, "Expression: ${detail}", 3 );
 129  0
                 append( sb, "", 0 );
 130  
 
 131  0
                 append( sb, "goal", 2 );
 132  0
                 append( sb, "The name of the goal for which to show help. If unspecified, all goals will be displayed.", 3 );
 133  0
                 append( sb, "Expression: ${goal}", 3 );
 134  0
                 append( sb, "", 0 );
 135  
 
 136  0
                 append( sb, "indentSize (Default: 2)", 2 );
 137  0
                 append( sb, "The number of spaces per indentation level, should be positive.", 3 );
 138  0
                 append( sb, "Expression: ${indentSize}", 3 );
 139  0
                 append( sb, "", 0 );
 140  
 
 141  0
                 append( sb, "lineLength (Default: 80)", 2 );
 142  0
                 append( sb, "The maximum length of a display line, should be positive.", 3 );
 143  0
                 append( sb, "Expression: ${lineLength}", 3 );
 144  0
                 append( sb, "", 0 );
 145  
             }
 146  
         }
 147  
 
 148  0
         if ( goal == null || goal.length() <= 0 || "process".equals( goal ) )
 149  
         {
 150  0
             append( sb, "remote-resources:process", 0 );
 151  0
             append( sb, "Pull down resourceBundles containing remote resources and process the resources contained inside. When that is done the resources are injected into the current (in-memory) Maven project, making them available to the process-resources phase.\n\nResources that end in \'.vm\' are treated as velocity templates. For those, the \'.vm\' is stripped off for the final artifact name and it\'s fed through velocity to have properties expanded, conditions processed, etc...\n\nResources that don\'t end in \'.vm\' are copied \'as is\'.\n", 1 );
 152  0
             append( sb, "", 0 );
 153  0
             if ( detail )
 154  
             {
 155  0
                 append( sb, "Available parameters:", 1 );
 156  0
                 append( sb, "", 0 );
 157  
 
 158  0
                 append( sb, "appendedResourcesDirectory", 2 );
 159  0
                 append( sb, "The directory containing extra information appended to the generated resources.", 3 );
 160  0
                 append( sb, "Expression: ${basedir}/src/main/appended-resources", 3 );
 161  0
                 append( sb, "", 0 );
 162  
 
 163  0
                 append( sb, "attached (Default: true)", 2 );
 164  0
                 append( sb, "Attaches the resource to the project as a resource directory", 3 );
 165  0
                 append( sb, "", 0 );
 166  
 
 167  0
                 append( sb, "encoding (Default: ${project.build.sourceEncoding})", 2 );
 168  0
                 append( sb, "The character encoding scheme to be applied when filtering resources.", 3 );
 169  0
                 append( sb, "Expression: ${encoding}", 3 );
 170  0
                 append( sb, "", 0 );
 171  
 
 172  0
                 append( sb, "excludeArtifactIds", 2 );
 173  0
                 append( sb, "Comma separated list of Artifact names too exclude.", 3 );
 174  0
                 append( sb, "Expression: ${excludeArtifactIds}", 3 );
 175  0
                 append( sb, "", 0 );
 176  
 
 177  0
                 append( sb, "excludeGroupIds", 2 );
 178  0
                 append( sb, "Comma separated list of GroupId Names to exclude.", 3 );
 179  0
                 append( sb, "Expression: ${excludeGroupIds}", 3 );
 180  0
                 append( sb, "", 0 );
 181  
 
 182  0
                 append( sb, "excludeScope", 2 );
 183  0
                 append( sb, "Scope to exclude. An Empty string indicates no scopes (default).", 3 );
 184  0
                 append( sb, "Expression: ${excludeScope}", 3 );
 185  0
                 append( sb, "", 0 );
 186  
 
 187  0
                 append( sb, "excludeTransitive (Default: false)", 2 );
 188  0
                 append( sb, "If we should exclude transitive dependencies", 3 );
 189  0
                 append( sb, "Expression: ${excludeTransitive}", 3 );
 190  0
                 append( sb, "", 0 );
 191  
 
 192  0
                 append( sb, "filterDelimiters", 2 );
 193  0
                 append( sb, "In cases where a local resource overrides one from a remote resource bundle, that resource should be filtered if the resource set specifies it. In those cases, this parameter defines the list of delimiters for filterable expressions. These delimiters are specified in the form \'beginToken*endToken\'. If no \'*\' is given, the delimiter is assumed to be the same for start and end.\n\nSo, the default filtering delimiters might be specified as:\n\n<delimiters>\n\u00a0\u00a0<delimiter>${*}</delimiter>\n\u00a0\u00a0<delimiter>@</delimiter>\n</delimiters>\n\nSince the \'@\' delimiter is the same on both ends, we don\'t need to specify \'@*@\' (though we can).\n", 3 );
 194  0
                 append( sb, "", 0 );
 195  
 
 196  0
                 append( sb, "includeArtifactIds", 2 );
 197  0
                 append( sb, "Comma separated list of Artifact names to include.", 3 );
 198  0
                 append( sb, "Expression: ${includeArtifactIds}", 3 );
 199  0
                 append( sb, "", 0 );
 200  
 
 201  0
                 append( sb, "includeGroupIds", 2 );
 202  0
                 append( sb, "Comma separated list of GroupIds to include.", 3 );
 203  0
                 append( sb, "Expression: ${includeGroupIds}", 3 );
 204  0
                 append( sb, "", 0 );
 205  
 
 206  0
                 append( sb, "includeProjectProperties (Default: false)", 2 );
 207  0
                 append( sb, "Whether to include properties defined in the project when filtering resources.", 3 );
 208  0
                 append( sb, "", 0 );
 209  
 
 210  0
                 append( sb, "includeScope (Default: runtime)", 2 );
 211  0
                 append( sb, "Scope to include. An Empty string indicates all scopes (default).", 3 );
 212  0
                 append( sb, "Expression: ${includeScope}", 3 );
 213  0
                 append( sb, "", 0 );
 214  
 
 215  0
                 append( sb, "outputDirectory", 2 );
 216  0
                 append( sb, "The directory where processed resources will be placed for packaging.", 3 );
 217  0
                 append( sb, "Expression: ${project.build.directory}/maven-shared-archive-resources", 3 );
 218  0
                 append( sb, "", 0 );
 219  
 
 220  0
                 append( sb, "properties", 2 );
 221  0
                 append( sb, "Additional properties to be passed to velocity.\n>Several properties are automatically added:\nproject - the current MavenProject\nprojects - the list of dependency projects\nprojectTimespan - the timespan of the current project (requires inceptionYear in pom)\n\n\n>See the javadoc for MavenProject for information about the properties on the MavenProject.\n", 3 );
 222  0
                 append( sb, "", 0 );
 223  
 
 224  0
                 append( sb, "resourceBundles", 2 );
 225  0
                 append( sb, "The resource bundles that will be retrieved and processed.", 3 );
 226  0
                 append( sb, "Required: Yes", 3 );
 227  0
                 append( sb, "", 0 );
 228  
 
 229  0
                 append( sb, "runOnlyAtExecutionRoot (Default: false)", 2 );
 230  0
                 append( sb, "If true, only generate resources in the directory of the root project in a multimodule build. Dependencies from all modules will be aggregated before resource-generation takes place.", 3 );
 231  0
                 append( sb, "", 0 );
 232  
 
 233  0
                 append( sb, "skip (Default: false)", 2 );
 234  0
                 append( sb, "Skip remote-resource processing", 3 );
 235  0
                 append( sb, "Expression: ${remoteresources.skip}", 3 );
 236  0
                 append( sb, "", 0 );
 237  
 
 238  0
                 append( sb, "supplementalModelArtifacts", 2 );
 239  0
                 append( sb, "List of artifacts that are added to the search path when looking for supplementalModels", 3 );
 240  0
                 append( sb, "", 0 );
 241  
 
 242  0
                 append( sb, "supplementalModels", 2 );
 243  0
                 append( sb, "Supplemental model data. Useful when processing artifacts with incomplete POM metadata.\n>By default, this Mojo looks for supplemental model data in the file \'${appendedResourcesDirectory}\nsupplemental-models.xml\'.", 3 );
 244  0
                 append( sb, "", 0 );
 245  
 
 246  0
                 append( sb, "useDefaultFilterDelimiters (Default: true)", 2 );
 247  0
                 append( sb, "(no description available)", 3 );
 248  0
                 append( sb, "", 0 );
 249  
             }
 250  
         }
 251  
 
 252  0
         if ( getLog().isInfoEnabled() )
 253  
         {
 254  0
             getLog().info( sb.toString() );
 255  
         }
 256  0
     }
 257  
 
 258  
     /**
 259  
      * <p>Repeat a String <code>n</code> times to form a new string.</p>
 260  
      *
 261  
      * @param str String to repeat
 262  
      * @param repeat number of times to repeat str
 263  
      * @return String with repeated String
 264  
      * @throws NegativeArraySizeException if <code>repeat < 0</code>
 265  
      * @throws NullPointerException if str is <code>null</code>
 266  
      */
 267  
     private static String repeat( String str, int repeat )
 268  
     {
 269  0
         StringBuffer buffer = new StringBuffer( repeat * str.length() );
 270  
 
 271  0
         for ( int i = 0; i < repeat; i++ )
 272  
         {
 273  0
             buffer.append( str );
 274  
         }
 275  
 
 276  0
         return buffer.toString();
 277  
     }
 278  
 
 279  
     /** 
 280  
      * Append a description to the buffer by respecting the indentSize and lineLength parameters.
 281  
      * <b>Note</b>: The last character is always a new line.
 282  
      * 
 283  
      * @param sb The buffer to append the description, not <code>null</code>.
 284  
      * @param description The description, not <code>null</code>.
 285  
      * @param indent The base indentation level of each line, must not be negative.
 286  
      */
 287  
     private void append( StringBuffer sb, String description, int indent )
 288  
     {
 289  0
         for ( Iterator it = toLines( description, indent, indentSize, lineLength ).iterator(); it.hasNext(); )
 290  
         {
 291  0
             sb.append( it.next().toString() ).append( '\n' );
 292  
         }
 293  0
     }
 294  
 
 295  
     /** 
 296  
      * Splits the specified text into lines of convenient display length.
 297  
      * 
 298  
      * @param text The text to split into lines, must not be <code>null</code>.
 299  
      * @param indent The base indentation level of each line, must not be negative.
 300  
      * @param indentSize The size of each indentation, must not be negative.
 301  
      * @param lineLength The length of the line, must not be negative.
 302  
      * @return The sequence of display lines, never <code>null</code>.
 303  
      * @throws NegativeArraySizeException if <code>indent < 0</code>
 304  
      */
 305  
     private static List toLines( String text, int indent, int indentSize, int lineLength )
 306  
     {
 307  0
         List lines = new ArrayList();
 308  
 
 309  0
         String ind = repeat( "\t", indent );
 310  0
         String[] plainLines = text.split( "(\r\n)|(\r)|(\n)" );
 311  0
         for ( int i = 0; i < plainLines.length; i++ )
 312  
         {
 313  0
             toLines( lines, ind + plainLines[i], indentSize, lineLength );
 314  
         }
 315  
 
 316  0
         return lines;
 317  
     }
 318  
 
 319  
     /** 
 320  
      * Adds the specified line to the output sequence, performing line wrapping if necessary.
 321  
      * 
 322  
      * @param lines The sequence of display lines, must not be <code>null</code>.
 323  
      * @param line The line to add, must not be <code>null</code>.
 324  
      * @param indentSize The size of each indentation, must not be negative.
 325  
      * @param lineLength The length of the line, must not be negative.
 326  
      */
 327  
     private static void toLines( List lines, String line, int indentSize, int lineLength )
 328  
     {
 329  0
         int lineIndent = getIndentLevel( line );
 330  0
         StringBuffer buf = new StringBuffer( 256 );
 331  0
         String[] tokens = line.split( " +" );
 332  0
         for ( int i = 0; i < tokens.length; i++ )
 333  
         {
 334  0
             String token = tokens[i];
 335  0
             if ( i > 0 )
 336  
             {
 337  0
                 if ( buf.length() + token.length() >= lineLength )
 338  
                 {
 339  0
                     lines.add( buf.toString() );
 340  0
                     buf.setLength( 0 );
 341  0
                     buf.append( repeat( " ", lineIndent * indentSize ) );
 342  
                 }
 343  
                 else
 344  
                 {
 345  0
                     buf.append( ' ' );
 346  
                 }
 347  
             }
 348  0
             for ( int j = 0; j < token.length(); j++ )
 349  
             {
 350  0
                 char c = token.charAt( j );
 351  0
                 if ( c == '\t' )
 352  
                 {
 353  0
                     buf.append( repeat( " ", indentSize - buf.length() % indentSize ) );
 354  
                 }
 355  0
                 else if ( c == '\u00A0' )
 356  
                 {
 357  0
                     buf.append( ' ' );
 358  
                 }
 359  
                 else
 360  
                 {
 361  0
                     buf.append( c );
 362  
                 }
 363  
             }
 364  
         }
 365  0
         lines.add( buf.toString() );
 366  0
     }
 367  
 
 368  
     /** 
 369  
      * Gets the indentation level of the specified line.
 370  
      * 
 371  
      * @param line The line whose indentation level should be retrieved, must not be <code>null</code>.
 372  
      * @return The indentation level of the line.
 373  
      */
 374  
     private static int getIndentLevel( String line )
 375  
     {
 376  0
         int level = 0;
 377  0
         for ( int i = 0; i < line.length() && line.charAt( i ) == '\t'; i++ )
 378  
         {
 379  0
             level++;
 380  
         }
 381  0
         for ( int i = level + 1; i <= level + 4 && i < line.length(); i++ )
 382  
         {
 383  0
             if ( line.charAt( i ) == '\t' )
 384  
             {
 385  0
                 level++;
 386  0
                 break;
 387  
             }
 388  
         }
 389  0
         return level;
 390  
     }
 391  
 }