1 package org.apache.maven.plugin.deploy;
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-deploy-plugin:2.7", 0 );
70 append( sb, "", 0 );
71
72 append( sb, "Maven Deploy Plugin", 0 );
73 append( sb, "Uploads the project artifacts to the internal remote repository.", 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 || "deploy".equals( goal ) )
83 {
84 append( sb, "deploy:deploy", 0 );
85 append( sb, "Deploys an artifact to remote repository.", 1 );
86 append( sb, "", 0 );
87 if ( detail )
88 {
89 append( sb, "Available parameters:", 1 );
90 append( sb, "", 0 );
91
92 append( sb, "altDeploymentRepository", 2 );
93 append( sb, "Specifies an alternative repository to which the project artifacts should be deployed ( other than those specified in <distributionManagement> ).\nFormat: id::layout::url", 3 );
94 append( sb, "Expression: ${altDeploymentRepository}", 3 );
95 append( sb, "", 0 );
96
97 append( sb, "retryFailedDeploymentCount (Default: 1)", 2 );
98 append( sb, "Parameter used to control how many times a failed deployment will be retried before giving up and failing. If a value outside the range 1-10 is specified it will be pulled to the nearest value within the range 1-10.", 3 );
99 append( sb, "Expression: ${retryFailedDeploymentCount}", 3 );
100 append( sb, "", 0 );
101
102 append( sb, "skip (Default: false)", 2 );
103 append( sb, "Set this to \'true\' to bypass artifact deploy", 3 );
104 append( sb, "Expression: ${maven.deploy.skip}", 3 );
105 append( sb, "", 0 );
106
107 append( sb, "updateReleaseInfo (Default: false)", 2 );
108 append( sb, "Parameter used to update the metadata to make the artifact as release.", 3 );
109 append( sb, "Expression: ${updateReleaseInfo}", 3 );
110 append( sb, "", 0 );
111 }
112 }
113
114 if ( goal == null || goal.length() <= 0 || "deploy-file".equals( goal ) )
115 {
116 append( sb, "deploy:deploy-file", 0 );
117 append( sb, "Installs the artifact in the remote repository.", 1 );
118 append( sb, "", 0 );
119 if ( detail )
120 {
121 append( sb, "Available parameters:", 1 );
122 append( sb, "", 0 );
123
124 append( sb, "artifactId", 2 );
125 append( sb, "ArtifactId of the artifact to be deployed. Retrieved from POM file if specified.", 3 );
126 append( sb, "Expression: ${artifactId}", 3 );
127 append( sb, "", 0 );
128
129 append( sb, "classifier", 2 );
130 append( sb, "Add classifier to the artifact", 3 );
131 append( sb, "Expression: ${classifier}", 3 );
132 append( sb, "", 0 );
133
134 append( sb, "classifiers", 2 );
135 append( sb, "A comma separated list of classifiers for each of the extra side artifacts to deploy. If there is a mis-match in the number of entries in files or types, then an error will be raised.", 3 );
136 append( sb, "Expression: ${classifiers}", 3 );
137 append( sb, "", 0 );
138
139 append( sb, "description", 2 );
140 append( sb, "Description passed to a generated POM file (in case of generatePom=true)", 3 );
141 append( sb, "Expression: ${generatePom.description}", 3 );
142 append( sb, "", 0 );
143
144 append( sb, "file", 2 );
145 append( sb, "File to be deployed.", 3 );
146 append( sb, "Required: Yes", 3 );
147 append( sb, "Expression: ${file}", 3 );
148 append( sb, "", 0 );
149
150 append( sb, "files", 2 );
151 append( sb, "A comma separated list of files for each of the extra side artifacts to deploy. If there is a mis-match in the number of entries in types or classifiers, then an error will be raised.", 3 );
152 append( sb, "Expression: ${files}", 3 );
153 append( sb, "", 0 );
154
155 append( sb, "generatePom (Default: true)", 2 );
156 append( sb, "Upload a POM for this artifact. Will generate a default POM if none is supplied with the pomFile argument.", 3 );
157 append( sb, "Expression: ${generatePom}", 3 );
158 append( sb, "", 0 );
159
160 append( sb, "groupId", 2 );
161 append( sb, "GroupId of the artifact to be deployed. Retrieved from POM file if specified.", 3 );
162 append( sb, "Expression: ${groupId}", 3 );
163 append( sb, "", 0 );
164
165 append( sb, "javadoc", 2 );
166 append( sb, "The bundled API docs for the artifact.", 3 );
167 append( sb, "Expression: ${javadoc}", 3 );
168 append( sb, "", 0 );
169
170 append( sb, "packaging", 2 );
171 append( sb, "Type of the artifact to be deployed. Retrieved from the <packaging> element of the POM file if a POM file specified. Defaults to the file extension if it is not specified via command line or POM.\nMaven uses two terms to refer to this datum: the <packaging> element for the entire POM, and the <type> element in a dependency specification.", 3 );
172 append( sb, "Expression: ${packaging}", 3 );
173 append( sb, "", 0 );
174
175 append( sb, "pomFile", 2 );
176 append( sb, "Location of an existing POM file to be deployed alongside the main artifact, given by the ${file} parameter.", 3 );
177 append( sb, "Expression: ${pomFile}", 3 );
178 append( sb, "", 0 );
179
180 append( sb, "repositoryId (Default: remote-repository)", 2 );
181 append( sb, "Server Id to map on the <id> under <server> section of settings.xml In most cases, this parameter will be required for authentication.", 3 );
182 append( sb, "Required: Yes", 3 );
183 append( sb, "Expression: ${repositoryId}", 3 );
184 append( sb, "", 0 );
185
186 append( sb, "repositoryLayout (Default: default)", 2 );
187 append( sb, "The type of remote repository layout to deploy to. Try legacy for a Maven 1.x-style repository layout.", 3 );
188 append( sb, "Expression: ${repositoryLayout}", 3 );
189 append( sb, "", 0 );
190
191 append( sb, "retryFailedDeploymentCount (Default: 1)", 2 );
192 append( sb, "Parameter used to control how many times a failed deployment will be retried before giving up and failing. If a value outside the range 1-10 is specified it will be pulled to the nearest value within the range 1-10.", 3 );
193 append( sb, "Expression: ${retryFailedDeploymentCount}", 3 );
194 append( sb, "", 0 );
195
196 append( sb, "sources", 2 );
197 append( sb, "The bundled sources for the artifact.", 3 );
198 append( sb, "Expression: ${sources}", 3 );
199 append( sb, "", 0 );
200
201 append( sb, "types", 2 );
202 append( sb, "A comma separated list of types for each of the extra side artifacts to deploy. If there is a mis-match in the number of entries in files or classifiers, then an error will be raised.", 3 );
203 append( sb, "Expression: ${types}", 3 );
204 append( sb, "", 0 );
205
206 append( sb, "uniqueVersion (Default: true)", 2 );
207 append( sb, "Whether to deploy snapshots with a unique version or not.", 3 );
208 append( sb, "Expression: ${uniqueVersion}", 3 );
209 append( sb, "", 0 );
210
211 append( sb, "updateReleaseInfo (Default: false)", 2 );
212 append( sb, "Parameter used to update the metadata to make the artifact as release.", 3 );
213 append( sb, "Expression: ${updateReleaseInfo}", 3 );
214 append( sb, "", 0 );
215
216 append( sb, "url", 2 );
217 append( sb, "URL where the artifact will be deployed.\nie ( file:///C:/m2-repo or scp://host.com/path/to/repo )", 3 );
218 append( sb, "Required: Yes", 3 );
219 append( sb, "Expression: ${url}", 3 );
220 append( sb, "", 0 );
221
222 append( sb, "version", 2 );
223 append( sb, "Version of the artifact to be deployed. Retrieved from POM file if specified.", 3 );
224 append( sb, "Expression: ${version}", 3 );
225 append( sb, "", 0 );
226 }
227 }
228
229 if ( goal == null || goal.length() <= 0 || "help".equals( goal ) )
230 {
231 append( sb, "deploy:help", 0 );
232 append( sb, "Display help information on maven-deploy-plugin.\nCall\n\u00a0\u00a0mvn\u00a0deploy:help\u00a0-Ddetail=true\u00a0-Dgoal=<goal-name>\nto display parameter details.", 1 );
233 append( sb, "", 0 );
234 if ( detail )
235 {
236 append( sb, "Available parameters:", 1 );
237 append( sb, "", 0 );
238
239 append( sb, "detail (Default: false)", 2 );
240 append( sb, "If true, display all settable properties for each goal.", 3 );
241 append( sb, "Expression: ${detail}", 3 );
242 append( sb, "", 0 );
243
244 append( sb, "goal", 2 );
245 append( sb, "The name of the goal for which to show help. If unspecified, all goals will be displayed.", 3 );
246 append( sb, "Expression: ${goal}", 3 );
247 append( sb, "", 0 );
248
249 append( sb, "indentSize (Default: 2)", 2 );
250 append( sb, "The number of spaces per indentation level, should be positive.", 3 );
251 append( sb, "Expression: ${indentSize}", 3 );
252 append( sb, "", 0 );
253
254 append( sb, "lineLength (Default: 80)", 2 );
255 append( sb, "The maximum length of a display line, should be positive.", 3 );
256 append( sb, "Expression: ${lineLength}", 3 );
257 append( sb, "", 0 );
258 }
259 }
260
261 if ( getLog().isInfoEnabled() )
262 {
263 getLog().info( sb.toString() );
264 }
265 }
266
267
268
269
270
271
272
273
274
275
276 private static String repeat( String str, int repeat )
277 {
278 StringBuffer buffer = new StringBuffer( repeat * str.length() );
279
280 for ( int i = 0; i < repeat; i++ )
281 {
282 buffer.append( str );
283 }
284
285 return buffer.toString();
286 }
287
288
289
290
291
292
293
294
295
296 private void append( StringBuffer sb, String description, int indent )
297 {
298 for ( Iterator it = toLines( description, indent, indentSize, lineLength ).iterator(); it.hasNext(); )
299 {
300 sb.append( it.next().toString() ).append( '\n' );
301 }
302 }
303
304
305
306
307
308
309
310
311
312
313
314 private static List toLines( String text, int indent, int indentSize, int lineLength )
315 {
316 List<String> lines = new ArrayList<String>();
317
318 String ind = repeat( "\t", indent );
319 String[] plainLines = text.split( "(\r\n)|(\r)|(\n)" );
320 for ( int i = 0; i < plainLines.length; i++ )
321 {
322 toLines( lines, ind + plainLines[i], indentSize, lineLength );
323 }
324
325 return lines;
326 }
327
328
329
330
331
332
333
334
335
336 private static void toLines( List<String> lines, String line, int indentSize, int lineLength )
337 {
338 int lineIndent = getIndentLevel( line );
339 StringBuffer buf = new StringBuffer( 256 );
340 String[] tokens = line.split( " +" );
341 for ( int i = 0; i < tokens.length; i++ )
342 {
343 String token = tokens[i];
344 if ( i > 0 )
345 {
346 if ( buf.length() + token.length() >= lineLength )
347 {
348 lines.add( buf.toString() );
349 buf.setLength( 0 );
350 buf.append( repeat( " ", lineIndent * indentSize ) );
351 }
352 else
353 {
354 buf.append( ' ' );
355 }
356 }
357 for ( int j = 0; j < token.length(); j++ )
358 {
359 char c = token.charAt( j );
360 if ( c == '\t' )
361 {
362 buf.append( repeat( " ", indentSize - buf.length() % indentSize ) );
363 }
364 else if ( c == '\u00A0' )
365 {
366 buf.append( ' ' );
367 }
368 else
369 {
370 buf.append( c );
371 }
372 }
373 }
374 lines.add( buf.toString() );
375 }
376
377
378
379
380
381
382
383 private static int getIndentLevel( String line )
384 {
385 int level = 0;
386 for ( int i = 0; i < line.length() && line.charAt( i ) == '\t'; i++ )
387 {
388 level++;
389 }
390 for ( int i = level + 1; i <= level + 4 && i < line.length(); i++ )
391 {
392 if ( line.charAt( i ) == '\t' )
393 {
394 level++;
395 break;
396 }
397 }
398 return level;
399 }
400 }