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 | 0 | public class HelpMojo |
20 | |
extends AbstractMojo |
21 | |
{ |
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
private boolean detail; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
private java.lang.String goal; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
private int lineLength; |
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
private int indentSize; |
49 | |
|
50 | |
|
51 | |
|
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-deploy-plugin:2.6", 0 ); |
69 | 0 | append( sb, "", 0 ); |
70 | |
|
71 | 0 | append( sb, "Maven Deploy Plugin", 0 ); |
72 | 0 | append( sb, "Uploads the project artifacts to the internal remote repository.", 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 || "deploy".equals( goal ) ) |
82 | |
{ |
83 | 0 | append( sb, "deploy:deploy", 0 ); |
84 | 0 | append( sb, "Deploys an artifact to remote repository.", 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, "altDeploymentRepository", 2 ); |
92 | 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 ); |
93 | 0 | append( sb, "Expression: ${altDeploymentRepository}", 3 ); |
94 | 0 | append( sb, "", 0 ); |
95 | |
|
96 | 0 | append( sb, "skip (Default: false)", 2 ); |
97 | 0 | append( sb, "Set this to \'true\' to bypass artifact deploy", 3 ); |
98 | 0 | append( sb, "Expression: ${maven.deploy.skip}", 3 ); |
99 | 0 | append( sb, "", 0 ); |
100 | |
|
101 | 0 | append( sb, "updateReleaseInfo (Default: false)", 2 ); |
102 | 0 | append( sb, "Parameter used to update the metadata to make the artifact as release.", 3 ); |
103 | 0 | append( sb, "Expression: ${updateReleaseInfo}", 3 ); |
104 | 0 | append( sb, "", 0 ); |
105 | |
} |
106 | |
} |
107 | |
|
108 | 0 | if ( goal == null || goal.length() <= 0 || "deploy-file".equals( goal ) ) |
109 | |
{ |
110 | 0 | append( sb, "deploy:deploy-file", 0 ); |
111 | 0 | append( sb, "Installs the artifact in the remote repository.", 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, "artifactId", 2 ); |
119 | 0 | append( sb, "ArtifactId of the artifact to be deployed. Retrieved from POM file if specified.", 3 ); |
120 | 0 | append( sb, "Expression: ${artifactId}", 3 ); |
121 | 0 | append( sb, "", 0 ); |
122 | |
|
123 | 0 | append( sb, "classifier", 2 ); |
124 | 0 | append( sb, "Add classifier to the artifact", 3 ); |
125 | 0 | append( sb, "Expression: ${classifier}", 3 ); |
126 | 0 | append( sb, "", 0 ); |
127 | |
|
128 | 0 | append( sb, "description", 2 ); |
129 | 0 | append( sb, "Description passed to a generated POM file (in case of generatePom=true)", 3 ); |
130 | 0 | append( sb, "Expression: ${generatePom.description}", 3 ); |
131 | 0 | append( sb, "", 0 ); |
132 | |
|
133 | 0 | append( sb, "file", 2 ); |
134 | 0 | append( sb, "File to be deployed.", 3 ); |
135 | 0 | append( sb, "Required: Yes", 3 ); |
136 | 0 | append( sb, "Expression: ${file}", 3 ); |
137 | 0 | append( sb, "", 0 ); |
138 | |
|
139 | 0 | append( sb, "generatePom (Default: true)", 2 ); |
140 | 0 | append( sb, "Upload a POM for this artifact. Will generate a default POM if none is supplied with the pomFile argument.", 3 ); |
141 | 0 | append( sb, "Expression: ${generatePom}", 3 ); |
142 | 0 | append( sb, "", 0 ); |
143 | |
|
144 | 0 | append( sb, "groupId", 2 ); |
145 | 0 | append( sb, "GroupId of the artifact to be deployed. Retrieved from POM file if specified.", 3 ); |
146 | 0 | append( sb, "Expression: ${groupId}", 3 ); |
147 | 0 | append( sb, "", 0 ); |
148 | |
|
149 | 0 | append( sb, "javadoc", 2 ); |
150 | 0 | append( sb, "The bundled API docs for the artifact.", 3 ); |
151 | 0 | append( sb, "Expression: ${javadoc}", 3 ); |
152 | 0 | append( sb, "", 0 ); |
153 | |
|
154 | 0 | append( sb, "packaging", 2 ); |
155 | 0 | append( sb, "Type of the artifact to be deployed. Retrieved from POM file if specified. Defaults to file extension if not specified via command line or POM.", 3 ); |
156 | 0 | append( sb, "Expression: ${packaging}", 3 ); |
157 | 0 | append( sb, "", 0 ); |
158 | |
|
159 | 0 | append( sb, "pomFile", 2 ); |
160 | 0 | append( sb, "Location of an existing POM file to be deployed alongside the main artifact, given by the ${file} parameter.", 3 ); |
161 | 0 | append( sb, "Expression: ${pomFile}", 3 ); |
162 | 0 | append( sb, "", 0 ); |
163 | |
|
164 | 0 | append( sb, "repositoryId (Default: remote-repository)", 2 ); |
165 | 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 ); |
166 | 0 | append( sb, "Required: Yes", 3 ); |
167 | 0 | append( sb, "Expression: ${repositoryId}", 3 ); |
168 | 0 | append( sb, "", 0 ); |
169 | |
|
170 | 0 | append( sb, "repositoryLayout (Default: default)", 2 ); |
171 | 0 | append( sb, "The type of remote repository layout to deploy to. Try legacy for a Maven 1.x-style repository layout.", 3 ); |
172 | 0 | append( sb, "Expression: ${repositoryLayout}", 3 ); |
173 | 0 | append( sb, "", 0 ); |
174 | |
|
175 | 0 | append( sb, "sources", 2 ); |
176 | 0 | append( sb, "The bundled sources for the artifact.", 3 ); |
177 | 0 | append( sb, "Expression: ${sources}", 3 ); |
178 | 0 | append( sb, "", 0 ); |
179 | |
|
180 | 0 | append( sb, "uniqueVersion (Default: true)", 2 ); |
181 | 0 | append( sb, "Whether to deploy snapshots with a unique version or not.", 3 ); |
182 | 0 | append( sb, "Expression: ${uniqueVersion}", 3 ); |
183 | 0 | append( sb, "", 0 ); |
184 | |
|
185 | 0 | append( sb, "updateReleaseInfo (Default: false)", 2 ); |
186 | 0 | append( sb, "Parameter used to update the metadata to make the artifact as release.", 3 ); |
187 | 0 | append( sb, "Expression: ${updateReleaseInfo}", 3 ); |
188 | 0 | append( sb, "", 0 ); |
189 | |
|
190 | 0 | append( sb, "url", 2 ); |
191 | 0 | append( sb, "URL where the artifact will be deployed.\nie ( file:///C:/m2-repo or scp://host.com/path/to/repo )", 3 ); |
192 | 0 | append( sb, "Required: Yes", 3 ); |
193 | 0 | append( sb, "Expression: ${url}", 3 ); |
194 | 0 | append( sb, "", 0 ); |
195 | |
|
196 | 0 | append( sb, "version", 2 ); |
197 | 0 | append( sb, "Version of the artifact to be deployed. Retrieved from POM file if specified.", 3 ); |
198 | 0 | append( sb, "Expression: ${version}", 3 ); |
199 | 0 | append( sb, "", 0 ); |
200 | |
} |
201 | |
} |
202 | |
|
203 | 0 | if ( goal == null || goal.length() <= 0 || "help".equals( goal ) ) |
204 | |
{ |
205 | 0 | append( sb, "deploy:help", 0 ); |
206 | 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 ); |
207 | 0 | append( sb, "", 0 ); |
208 | 0 | if ( detail ) |
209 | |
{ |
210 | 0 | append( sb, "Available parameters:", 1 ); |
211 | 0 | append( sb, "", 0 ); |
212 | |
|
213 | 0 | append( sb, "detail (Default: false)", 2 ); |
214 | 0 | append( sb, "If true, display all settable properties for each goal.", 3 ); |
215 | 0 | append( sb, "Expression: ${detail}", 3 ); |
216 | 0 | append( sb, "", 0 ); |
217 | |
|
218 | 0 | append( sb, "goal", 2 ); |
219 | 0 | append( sb, "The name of the goal for which to show help. If unspecified, all goals will be displayed.", 3 ); |
220 | 0 | append( sb, "Expression: ${goal}", 3 ); |
221 | 0 | append( sb, "", 0 ); |
222 | |
|
223 | 0 | append( sb, "indentSize (Default: 2)", 2 ); |
224 | 0 | append( sb, "The number of spaces per indentation level, should be positive.", 3 ); |
225 | 0 | append( sb, "Expression: ${indentSize}", 3 ); |
226 | 0 | append( sb, "", 0 ); |
227 | |
|
228 | 0 | append( sb, "lineLength (Default: 80)", 2 ); |
229 | 0 | append( sb, "The maximum length of a display line, should be positive.", 3 ); |
230 | 0 | append( sb, "Expression: ${lineLength}", 3 ); |
231 | 0 | append( sb, "", 0 ); |
232 | |
} |
233 | |
} |
234 | |
|
235 | 0 | if ( getLog().isInfoEnabled() ) |
236 | |
{ |
237 | 0 | getLog().info( sb.toString() ); |
238 | |
} |
239 | 0 | } |
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
|
246 | |
|
247 | |
|
248 | |
|
249 | |
|
250 | |
private static String repeat( String str, int repeat ) |
251 | |
{ |
252 | 0 | StringBuffer buffer = new StringBuffer( repeat * str.length() ); |
253 | |
|
254 | 0 | for ( int i = 0; i < repeat; i++ ) |
255 | |
{ |
256 | 0 | buffer.append( str ); |
257 | |
} |
258 | |
|
259 | 0 | return buffer.toString(); |
260 | |
} |
261 | |
|
262 | |
|
263 | |
|
264 | |
|
265 | |
|
266 | |
|
267 | |
|
268 | |
|
269 | |
|
270 | |
private void append( StringBuffer sb, String description, int indent ) |
271 | |
{ |
272 | 0 | for ( Iterator it = toLines( description, indent, indentSize, lineLength ).iterator(); it.hasNext(); ) |
273 | |
{ |
274 | 0 | sb.append( it.next().toString() ).append( '\n' ); |
275 | |
} |
276 | 0 | } |
277 | |
|
278 | |
|
279 | |
|
280 | |
|
281 | |
|
282 | |
|
283 | |
|
284 | |
|
285 | |
|
286 | |
|
287 | |
|
288 | |
private static List toLines( String text, int indent, int indentSize, int lineLength ) |
289 | |
{ |
290 | 0 | List lines = new ArrayList(); |
291 | |
|
292 | 0 | String ind = repeat( "\t", indent ); |
293 | 0 | String[] plainLines = text.split( "(\r\n)|(\r)|(\n)" ); |
294 | 0 | for ( int i = 0; i < plainLines.length; i++ ) |
295 | |
{ |
296 | 0 | toLines( lines, ind + plainLines[i], indentSize, lineLength ); |
297 | |
} |
298 | |
|
299 | 0 | return lines; |
300 | |
} |
301 | |
|
302 | |
|
303 | |
|
304 | |
|
305 | |
|
306 | |
|
307 | |
|
308 | |
|
309 | |
|
310 | |
private static void toLines( List lines, String line, int indentSize, int lineLength ) |
311 | |
{ |
312 | 0 | int lineIndent = getIndentLevel( line ); |
313 | 0 | StringBuffer buf = new StringBuffer( 256 ); |
314 | 0 | String[] tokens = line.split( " +" ); |
315 | 0 | for ( int i = 0; i < tokens.length; i++ ) |
316 | |
{ |
317 | 0 | String token = tokens[i]; |
318 | 0 | if ( i > 0 ) |
319 | |
{ |
320 | 0 | if ( buf.length() + token.length() >= lineLength ) |
321 | |
{ |
322 | 0 | lines.add( buf.toString() ); |
323 | 0 | buf.setLength( 0 ); |
324 | 0 | buf.append( repeat( " ", lineIndent * indentSize ) ); |
325 | |
} |
326 | |
else |
327 | |
{ |
328 | 0 | buf.append( ' ' ); |
329 | |
} |
330 | |
} |
331 | 0 | for ( int j = 0; j < token.length(); j++ ) |
332 | |
{ |
333 | 0 | char c = token.charAt( j ); |
334 | 0 | if ( c == '\t' ) |
335 | |
{ |
336 | 0 | buf.append( repeat( " ", indentSize - buf.length() % indentSize ) ); |
337 | |
} |
338 | 0 | else if ( c == '\u00A0' ) |
339 | |
{ |
340 | 0 | buf.append( ' ' ); |
341 | |
} |
342 | |
else |
343 | |
{ |
344 | 0 | buf.append( c ); |
345 | |
} |
346 | |
} |
347 | |
} |
348 | 0 | lines.add( buf.toString() ); |
349 | 0 | } |
350 | |
|
351 | |
|
352 | |
|
353 | |
|
354 | |
|
355 | |
|
356 | |
|
357 | |
private static int getIndentLevel( String line ) |
358 | |
{ |
359 | 0 | int level = 0; |
360 | 0 | for ( int i = 0; i < line.length() && line.charAt( i ) == '\t'; i++ ) |
361 | |
{ |
362 | 0 | level++; |
363 | |
} |
364 | 0 | for ( int i = level + 1; i <= level + 4 && i < line.length(); i++ ) |
365 | |
{ |
366 | 0 | if ( line.charAt( i ) == '\t' ) |
367 | |
{ |
368 | 0 | level++; |
369 | 0 | break; |
370 | |
} |
371 | |
} |
372 | 0 | return level; |
373 | |
} |
374 | |
} |