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 | 0 | 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 | 0 | if ( lineLength <= 0 ) |
57 | |
{ |
58 | 0 | getLog().warn( "The parameter 'lineLength' should be positive, using '80' as default." ); |
59 | 0 | lineLength = 80; |
60 | |
} |
61 | 0 | if ( indentSize <= 0 ) |
62 | |
{ |
63 | 0 | getLog().warn( "The parameter 'indentSize' should be positive, using '2' as default." ); |
64 | 0 | indentSize = 2; |
65 | |
} |
66 | |
|
67 | 0 | StringBuffer sb = new StringBuffer(); |
68 | |
|
69 | 0 | append( sb, "org.apache.maven.plugins:maven-deploy-plugin:2.7", 0 ); |
70 | 0 | append( sb, "", 0 ); |
71 | |
|
72 | 0 | append( sb, "Maven Deploy Plugin", 0 ); |
73 | 0 | append( sb, "Uploads the project artifacts to the internal remote repository.", 1 ); |
74 | 0 | append( sb, "", 0 ); |
75 | |
|
76 | 0 | if ( goal == null || goal.length() <= 0 ) |
77 | |
{ |
78 | 0 | append( sb, "This plugin has 3 goals:", 0 ); |
79 | 0 | append( sb, "", 0 ); |
80 | |
} |
81 | |
|
82 | 0 | if ( goal == null || goal.length() <= 0 || "deploy".equals( goal ) ) |
83 | |
{ |
84 | 0 | append( sb, "deploy:deploy", 0 ); |
85 | 0 | append( sb, "Deploys an artifact to remote repository.", 1 ); |
86 | 0 | append( sb, "", 0 ); |
87 | 0 | if ( detail ) |
88 | |
{ |
89 | 0 | append( sb, "Available parameters:", 1 ); |
90 | 0 | append( sb, "", 0 ); |
91 | |
|
92 | 0 | append( sb, "altDeploymentRepository", 2 ); |
93 | 0 | 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 | 0 | append( sb, "Expression: ${altDeploymentRepository}", 3 ); |
95 | 0 | append( sb, "", 0 ); |
96 | |
|
97 | 0 | append( sb, "retryFailedDeploymentCount (Default: 1)", 2 ); |
98 | 0 | 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 | 0 | append( sb, "Expression: ${retryFailedDeploymentCount}", 3 ); |
100 | 0 | append( sb, "", 0 ); |
101 | |
|
102 | 0 | append( sb, "skip (Default: false)", 2 ); |
103 | 0 | append( sb, "Set this to \'true\' to bypass artifact deploy", 3 ); |
104 | 0 | append( sb, "Expression: ${maven.deploy.skip}", 3 ); |
105 | 0 | append( sb, "", 0 ); |
106 | |
|
107 | 0 | append( sb, "updateReleaseInfo (Default: false)", 2 ); |
108 | 0 | append( sb, "Parameter used to update the metadata to make the artifact as release.", 3 ); |
109 | 0 | append( sb, "Expression: ${updateReleaseInfo}", 3 ); |
110 | 0 | append( sb, "", 0 ); |
111 | |
} |
112 | |
} |
113 | |
|
114 | 0 | if ( goal == null || goal.length() <= 0 || "deploy-file".equals( goal ) ) |
115 | |
{ |
116 | 0 | append( sb, "deploy:deploy-file", 0 ); |
117 | 0 | append( sb, "Installs the artifact in the remote repository.", 1 ); |
118 | 0 | append( sb, "", 0 ); |
119 | 0 | if ( detail ) |
120 | |
{ |
121 | 0 | append( sb, "Available parameters:", 1 ); |
122 | 0 | append( sb, "", 0 ); |
123 | |
|
124 | 0 | append( sb, "artifactId", 2 ); |
125 | 0 | append( sb, "ArtifactId of the artifact to be deployed. Retrieved from POM file if specified.", 3 ); |
126 | 0 | append( sb, "Expression: ${artifactId}", 3 ); |
127 | 0 | append( sb, "", 0 ); |
128 | |
|
129 | 0 | append( sb, "classifier", 2 ); |
130 | 0 | append( sb, "Add classifier to the artifact", 3 ); |
131 | 0 | append( sb, "Expression: ${classifier}", 3 ); |
132 | 0 | append( sb, "", 0 ); |
133 | |
|
134 | 0 | append( sb, "classifiers", 2 ); |
135 | 0 | 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 | 0 | append( sb, "Expression: ${classifiers}", 3 ); |
137 | 0 | append( sb, "", 0 ); |
138 | |
|
139 | 0 | append( sb, "description", 2 ); |
140 | 0 | append( sb, "Description passed to a generated POM file (in case of generatePom=true)", 3 ); |
141 | 0 | append( sb, "Expression: ${generatePom.description}", 3 ); |
142 | 0 | append( sb, "", 0 ); |
143 | |
|
144 | 0 | append( sb, "file", 2 ); |
145 | 0 | append( sb, "File to be deployed.", 3 ); |
146 | 0 | append( sb, "Required: Yes", 3 ); |
147 | 0 | append( sb, "Expression: ${file}", 3 ); |
148 | 0 | append( sb, "", 0 ); |
149 | |
|
150 | 0 | append( sb, "files", 2 ); |
151 | 0 | 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 | 0 | append( sb, "Expression: ${files}", 3 ); |
153 | 0 | append( sb, "", 0 ); |
154 | |
|
155 | 0 | append( sb, "generatePom (Default: true)", 2 ); |
156 | 0 | append( sb, "Upload a POM for this artifact. Will generate a default POM if none is supplied with the pomFile argument.", 3 ); |
157 | 0 | append( sb, "Expression: ${generatePom}", 3 ); |
158 | 0 | append( sb, "", 0 ); |
159 | |
|
160 | 0 | append( sb, "groupId", 2 ); |
161 | 0 | append( sb, "GroupId of the artifact to be deployed. Retrieved from POM file if specified.", 3 ); |
162 | 0 | append( sb, "Expression: ${groupId}", 3 ); |
163 | 0 | append( sb, "", 0 ); |
164 | |
|
165 | 0 | append( sb, "javadoc", 2 ); |
166 | 0 | append( sb, "The bundled API docs for the artifact.", 3 ); |
167 | 0 | append( sb, "Expression: ${javadoc}", 3 ); |
168 | 0 | append( sb, "", 0 ); |
169 | |
|
170 | 0 | append( sb, "packaging", 2 ); |
171 | 0 | 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 | 0 | append( sb, "Expression: ${packaging}", 3 ); |
173 | 0 | append( sb, "", 0 ); |
174 | |
|
175 | 0 | append( sb, "pomFile", 2 ); |
176 | 0 | append( sb, "Location of an existing POM file to be deployed alongside the main artifact, given by the ${file} parameter.", 3 ); |
177 | 0 | append( sb, "Expression: ${pomFile}", 3 ); |
178 | 0 | append( sb, "", 0 ); |
179 | |
|
180 | 0 | append( sb, "repositoryId (Default: remote-repository)", 2 ); |
181 | 0 | 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 | 0 | append( sb, "Required: Yes", 3 ); |
183 | 0 | append( sb, "Expression: ${repositoryId}", 3 ); |
184 | 0 | append( sb, "", 0 ); |
185 | |
|
186 | 0 | append( sb, "repositoryLayout (Default: default)", 2 ); |
187 | 0 | append( sb, "The type of remote repository layout to deploy to. Try legacy for a Maven 1.x-style repository layout.", 3 ); |
188 | 0 | append( sb, "Expression: ${repositoryLayout}", 3 ); |
189 | 0 | append( sb, "", 0 ); |
190 | |
|
191 | 0 | append( sb, "retryFailedDeploymentCount (Default: 1)", 2 ); |
192 | 0 | 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 | 0 | append( sb, "Expression: ${retryFailedDeploymentCount}", 3 ); |
194 | 0 | append( sb, "", 0 ); |
195 | |
|
196 | 0 | append( sb, "sources", 2 ); |
197 | 0 | append( sb, "The bundled sources for the artifact.", 3 ); |
198 | 0 | append( sb, "Expression: ${sources}", 3 ); |
199 | 0 | append( sb, "", 0 ); |
200 | |
|
201 | 0 | append( sb, "types", 2 ); |
202 | 0 | 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 | 0 | append( sb, "Expression: ${types}", 3 ); |
204 | 0 | append( sb, "", 0 ); |
205 | |
|
206 | 0 | append( sb, "uniqueVersion (Default: true)", 2 ); |
207 | 0 | append( sb, "Whether to deploy snapshots with a unique version or not.", 3 ); |
208 | 0 | append( sb, "Expression: ${uniqueVersion}", 3 ); |
209 | 0 | append( sb, "", 0 ); |
210 | |
|
211 | 0 | append( sb, "updateReleaseInfo (Default: false)", 2 ); |
212 | 0 | append( sb, "Parameter used to update the metadata to make the artifact as release.", 3 ); |
213 | 0 | append( sb, "Expression: ${updateReleaseInfo}", 3 ); |
214 | 0 | append( sb, "", 0 ); |
215 | |
|
216 | 0 | append( sb, "url", 2 ); |
217 | 0 | append( sb, "URL where the artifact will be deployed.\nie ( file:///C:/m2-repo or scp://host.com/path/to/repo )", 3 ); |
218 | 0 | append( sb, "Required: Yes", 3 ); |
219 | 0 | append( sb, "Expression: ${url}", 3 ); |
220 | 0 | append( sb, "", 0 ); |
221 | |
|
222 | 0 | append( sb, "version", 2 ); |
223 | 0 | append( sb, "Version of the artifact to be deployed. Retrieved from POM file if specified.", 3 ); |
224 | 0 | append( sb, "Expression: ${version}", 3 ); |
225 | 0 | append( sb, "", 0 ); |
226 | |
} |
227 | |
} |
228 | |
|
229 | 0 | if ( goal == null || goal.length() <= 0 || "help".equals( goal ) ) |
230 | |
{ |
231 | 0 | append( sb, "deploy:help", 0 ); |
232 | 0 | 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 | 0 | append( sb, "", 0 ); |
234 | 0 | if ( detail ) |
235 | |
{ |
236 | 0 | append( sb, "Available parameters:", 1 ); |
237 | 0 | append( sb, "", 0 ); |
238 | |
|
239 | 0 | append( sb, "detail (Default: false)", 2 ); |
240 | 0 | append( sb, "If true, display all settable properties for each goal.", 3 ); |
241 | 0 | append( sb, "Expression: ${detail}", 3 ); |
242 | 0 | append( sb, "", 0 ); |
243 | |
|
244 | 0 | append( sb, "goal", 2 ); |
245 | 0 | append( sb, "The name of the goal for which to show help. If unspecified, all goals will be displayed.", 3 ); |
246 | 0 | append( sb, "Expression: ${goal}", 3 ); |
247 | 0 | append( sb, "", 0 ); |
248 | |
|
249 | 0 | append( sb, "indentSize (Default: 2)", 2 ); |
250 | 0 | append( sb, "The number of spaces per indentation level, should be positive.", 3 ); |
251 | 0 | append( sb, "Expression: ${indentSize}", 3 ); |
252 | 0 | append( sb, "", 0 ); |
253 | |
|
254 | 0 | append( sb, "lineLength (Default: 80)", 2 ); |
255 | 0 | append( sb, "The maximum length of a display line, should be positive.", 3 ); |
256 | 0 | append( sb, "Expression: ${lineLength}", 3 ); |
257 | 0 | append( sb, "", 0 ); |
258 | |
} |
259 | |
} |
260 | |
|
261 | 0 | if ( getLog().isInfoEnabled() ) |
262 | |
{ |
263 | 0 | getLog().info( sb.toString() ); |
264 | |
} |
265 | 0 | } |
266 | |
|
267 | |
|
268 | |
|
269 | |
|
270 | |
|
271 | |
|
272 | |
|
273 | |
|
274 | |
|
275 | |
|
276 | |
private static String repeat( String str, int repeat ) |
277 | |
{ |
278 | 0 | StringBuffer buffer = new StringBuffer( repeat * str.length() ); |
279 | |
|
280 | 0 | for ( int i = 0; i < repeat; i++ ) |
281 | |
{ |
282 | 0 | buffer.append( str ); |
283 | |
} |
284 | |
|
285 | 0 | 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 | 0 | for ( Iterator it = toLines( description, indent, indentSize, lineLength ).iterator(); it.hasNext(); ) |
299 | |
{ |
300 | 0 | sb.append( it.next().toString() ).append( '\n' ); |
301 | |
} |
302 | 0 | } |
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 | 0 | List<String> lines = new ArrayList<String>(); |
317 | |
|
318 | 0 | String ind = repeat( "\t", indent ); |
319 | 0 | String[] plainLines = text.split( "(\r\n)|(\r)|(\n)" ); |
320 | 0 | for ( int i = 0; i < plainLines.length; i++ ) |
321 | |
{ |
322 | 0 | toLines( lines, ind + plainLines[i], indentSize, lineLength ); |
323 | |
} |
324 | |
|
325 | 0 | 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 | 0 | int lineIndent = getIndentLevel( line ); |
339 | 0 | StringBuffer buf = new StringBuffer( 256 ); |
340 | 0 | String[] tokens = line.split( " +" ); |
341 | 0 | for ( int i = 0; i < tokens.length; i++ ) |
342 | |
{ |
343 | 0 | String token = tokens[i]; |
344 | 0 | if ( i > 0 ) |
345 | |
{ |
346 | 0 | if ( buf.length() + token.length() >= lineLength ) |
347 | |
{ |
348 | 0 | lines.add( buf.toString() ); |
349 | 0 | buf.setLength( 0 ); |
350 | 0 | buf.append( repeat( " ", lineIndent * indentSize ) ); |
351 | |
} |
352 | |
else |
353 | |
{ |
354 | 0 | buf.append( ' ' ); |
355 | |
} |
356 | |
} |
357 | 0 | for ( int j = 0; j < token.length(); j++ ) |
358 | |
{ |
359 | 0 | char c = token.charAt( j ); |
360 | 0 | if ( c == '\t' ) |
361 | |
{ |
362 | 0 | buf.append( repeat( " ", indentSize - buf.length() % indentSize ) ); |
363 | |
} |
364 | 0 | else if ( c == '\u00A0' ) |
365 | |
{ |
366 | 0 | buf.append( ' ' ); |
367 | |
} |
368 | |
else |
369 | |
{ |
370 | 0 | buf.append( c ); |
371 | |
} |
372 | |
} |
373 | |
} |
374 | 0 | lines.add( buf.toString() ); |
375 | 0 | } |
376 | |
|
377 | |
|
378 | |
|
379 | |
|
380 | |
|
381 | |
|
382 | |
|
383 | |
private static int getIndentLevel( String line ) |
384 | |
{ |
385 | 0 | int level = 0; |
386 | 0 | for ( int i = 0; i < line.length() && line.charAt( i ) == '\t'; i++ ) |
387 | |
{ |
388 | 0 | level++; |
389 | |
} |
390 | 0 | for ( int i = level + 1; i <= level + 4 && i < line.length(); i++ ) |
391 | |
{ |
392 | 0 | if ( line.charAt( i ) == '\t' ) |
393 | |
{ |
394 | 0 | level++; |
395 | 0 | break; |
396 | |
} |
397 | |
} |
398 | 0 | return level; |
399 | |
} |
400 | |
} |