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