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 | |
|
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-remote-resources-plugin:1.3", 0 ); |
70 | 0 | append( sb, "", 0 ); |
71 | |
|
72 | 0 | append( sb, "Maven Remote Resources Plugin", 0 ); |
73 | 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 ); |
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 || "bundle".equals( goal ) ) |
83 | |
{ |
84 | 0 | append( sb, "remote-resources:bundle", 0 ); |
85 | 0 | append( sb, "Bundle up resources that should be considered as a remote-resource.", 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, "excludes", 2 ); |
93 | 0 | append( sb, "A list of files to exclude. Can contain ant-style wildcards and double wildcards.", 3 ); |
94 | 0 | append( sb, "", 0 ); |
95 | |
|
96 | 0 | append( sb, "includes", 2 ); |
97 | 0 | append( sb, "A list of files to include. Can contain ant-style wildcards and double wildcards. The default includes are **/*.txt **/*.vm", 3 ); |
98 | 0 | append( sb, "", 0 ); |
99 | |
|
100 | 0 | append( sb, "outputDirectory (Default: ${project.build.outputDirectory})", 2 ); |
101 | 0 | append( sb, "The directory where you want the resource bundle manifest written to.", 3 ); |
102 | 0 | append( sb, "", 0 ); |
103 | |
|
104 | 0 | append( sb, "resourcesDirectory (Default: ${basedir}/src/main/resources)", 2 ); |
105 | 0 | append( sb, "The directory which contains the resources you want packaged up in this resource bundle.", 3 ); |
106 | 0 | append( sb, "", 0 ); |
107 | |
|
108 | 0 | append( sb, "sourceEncoding (Default: ${project.build.sourceEncoding})", 2 ); |
109 | 0 | append( sb, "Encoding of the bundle.", 3 ); |
110 | 0 | append( sb, "", 0 ); |
111 | |
} |
112 | |
} |
113 | |
|
114 | 0 | if ( goal == null || goal.length() <= 0 || "help".equals( goal ) ) |
115 | |
{ |
116 | 0 | append( sb, "remote-resources:help", 0 ); |
117 | 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 ); |
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, "detail (Default: false)", 2 ); |
125 | 0 | append( sb, "If true, display all settable properties for each goal.", 3 ); |
126 | 0 | append( sb, "Expression: ${detail}", 3 ); |
127 | 0 | append( sb, "", 0 ); |
128 | |
|
129 | 0 | append( sb, "goal", 2 ); |
130 | 0 | append( sb, "The name of the goal for which to show help. If unspecified, all goals will be displayed.", 3 ); |
131 | 0 | append( sb, "Expression: ${goal}", 3 ); |
132 | 0 | append( sb, "", 0 ); |
133 | |
|
134 | 0 | append( sb, "indentSize (Default: 2)", 2 ); |
135 | 0 | append( sb, "The number of spaces per indentation level, should be positive.", 3 ); |
136 | 0 | append( sb, "Expression: ${indentSize}", 3 ); |
137 | 0 | append( sb, "", 0 ); |
138 | |
|
139 | 0 | append( sb, "lineLength (Default: 80)", 2 ); |
140 | 0 | append( sb, "The maximum length of a display line, should be positive.", 3 ); |
141 | 0 | append( sb, "Expression: ${lineLength}", 3 ); |
142 | 0 | append( sb, "", 0 ); |
143 | |
} |
144 | |
} |
145 | |
|
146 | 0 | if ( goal == null || goal.length() <= 0 || "process".equals( goal ) ) |
147 | |
{ |
148 | 0 | append( sb, "remote-resources:process", 0 ); |
149 | 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 ); |
150 | 0 | append( sb, "", 0 ); |
151 | 0 | if ( detail ) |
152 | |
{ |
153 | 0 | append( sb, "Available parameters:", 1 ); |
154 | 0 | append( sb, "", 0 ); |
155 | |
|
156 | 0 | append( sb, "appendedResourcesDirectory (Default: ${basedir}/src/main/appended-resources)", 2 ); |
157 | 0 | append( sb, "The directory containing extra information appended to the generated resources.", 3 ); |
158 | 0 | append( sb, "", 0 ); |
159 | |
|
160 | 0 | append( sb, "attached (Default: true)", 2 ); |
161 | 0 | append( sb, "Attaches the resource to the project as a resource directory", 3 ); |
162 | 0 | append( sb, "", 0 ); |
163 | |
|
164 | 0 | append( sb, "encoding (Default: ${project.build.sourceEncoding})", 2 ); |
165 | 0 | append( sb, "The character encoding scheme to be applied when filtering resources.", 3 ); |
166 | 0 | append( sb, "Expression: ${encoding}", 3 ); |
167 | 0 | append( sb, "", 0 ); |
168 | |
|
169 | 0 | append( sb, "excludeArtifactIds", 2 ); |
170 | 0 | append( sb, "Comma separated list of Artifact names too exclude.", 3 ); |
171 | 0 | append( sb, "Expression: ${excludeArtifactIds}", 3 ); |
172 | 0 | append( sb, "", 0 ); |
173 | |
|
174 | 0 | append( sb, "excludeGroupIds", 2 ); |
175 | 0 | append( sb, "Comma separated list of GroupId Names to exclude.", 3 ); |
176 | 0 | append( sb, "Expression: ${excludeGroupIds}", 3 ); |
177 | 0 | append( sb, "", 0 ); |
178 | |
|
179 | 0 | append( sb, "excludeScope", 2 ); |
180 | 0 | append( sb, "Scope to exclude. An Empty string indicates no scopes (default).", 3 ); |
181 | 0 | append( sb, "Expression: ${excludeScope}", 3 ); |
182 | 0 | append( sb, "", 0 ); |
183 | |
|
184 | 0 | append( sb, "excludeTransitive (Default: false)", 2 ); |
185 | 0 | append( sb, "If we should exclude transitive dependencies", 3 ); |
186 | 0 | append( sb, "Expression: ${excludeTransitive}", 3 ); |
187 | 0 | append( sb, "", 0 ); |
188 | |
|
189 | 0 | append( sb, "filterDelimiters", 2 ); |
190 | 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 ); |
191 | 0 | append( sb, "", 0 ); |
192 | |
|
193 | 0 | append( sb, "includeArtifactIds", 2 ); |
194 | 0 | append( sb, "Comma separated list of Artifact names to include.", 3 ); |
195 | 0 | append( sb, "Expression: ${includeArtifactIds}", 3 ); |
196 | 0 | append( sb, "", 0 ); |
197 | |
|
198 | 0 | append( sb, "includeGroupIds", 2 ); |
199 | 0 | append( sb, "Comma separated list of GroupIds to include.", 3 ); |
200 | 0 | append( sb, "Expression: ${includeGroupIds}", 3 ); |
201 | 0 | append( sb, "", 0 ); |
202 | |
|
203 | 0 | append( sb, "includeProjectProperties (Default: false)", 2 ); |
204 | 0 | append( sb, "Whether to include properties defined in the project when filtering resources.", 3 ); |
205 | 0 | append( sb, "", 0 ); |
206 | |
|
207 | 0 | append( sb, "includeScope (Default: runtime)", 2 ); |
208 | 0 | append( sb, "Scope to include. An Empty string indicates all scopes (default).", 3 ); |
209 | 0 | append( sb, "Expression: ${includeScope}", 3 ); |
210 | 0 | append( sb, "", 0 ); |
211 | |
|
212 | 0 | append( sb, "outputDirectory (Default: ${project.build.directory}/maven-shared-archive-resources)", 2 ); |
213 | 0 | append( sb, "The directory where processed resources will be placed for packaging.", 3 ); |
214 | 0 | append( sb, "", 0 ); |
215 | |
|
216 | 0 | append( sb, "properties", 2 ); |
217 | 0 | append( sb, "Additional properties to be passed to velocity. 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)\nSee the javadoc for MavenProject for information about the properties on the MavenProject.", 3 ); |
218 | 0 | append( sb, "", 0 ); |
219 | |
|
220 | 0 | append( sb, "resourceBundles", 2 ); |
221 | 0 | append( sb, "The resource bundles that will be retrieved and processed.", 3 ); |
222 | 0 | append( sb, "Required: Yes", 3 ); |
223 | 0 | append( sb, "", 0 ); |
224 | |
|
225 | 0 | append( sb, "runOnlyAtExecutionRoot (Default: false)", 2 ); |
226 | 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 ); |
227 | 0 | append( sb, "", 0 ); |
228 | |
|
229 | 0 | append( sb, "skip (Default: false)", 2 ); |
230 | 0 | append( sb, "Skip remote-resource processing", 3 ); |
231 | 0 | append( sb, "Expression: ${remoteresources.skip}", 3 ); |
232 | 0 | append( sb, "", 0 ); |
233 | |
|
234 | 0 | append( sb, "supplementalModelArtifacts", 2 ); |
235 | 0 | append( sb, "List of artifacts that are added to the search path when looking for supplementalModels", 3 ); |
236 | 0 | append( sb, "", 0 ); |
237 | |
|
238 | 0 | append( sb, "supplementalModels", 2 ); |
239 | 0 | append( sb, "Supplemental model data. Useful when processing artifacts with incomplete POM metadata. By default, this Mojo looks for supplemental model data in the file \'${appendedResourcesDirectory}/supplemental-models.xml\'.", 3 ); |
240 | 0 | append( sb, "", 0 ); |
241 | |
|
242 | 0 | append( sb, "useDefaultFilterDelimiters (Default: true)", 2 ); |
243 | 0 | append( sb, "(no description available)", 3 ); |
244 | 0 | append( sb, "", 0 ); |
245 | |
} |
246 | |
} |
247 | |
|
248 | 0 | if ( getLog().isInfoEnabled() ) |
249 | |
{ |
250 | 0 | getLog().info( sb.toString() ); |
251 | |
} |
252 | 0 | } |
253 | |
|
254 | |
|
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
|
260 | |
|
261 | |
|
262 | |
|
263 | |
private static String repeat( String str, int repeat ) |
264 | |
{ |
265 | 0 | StringBuffer buffer = new StringBuffer( repeat * str.length() ); |
266 | |
|
267 | 0 | for ( int i = 0; i < repeat; i++ ) |
268 | |
{ |
269 | 0 | buffer.append( str ); |
270 | |
} |
271 | |
|
272 | 0 | return buffer.toString(); |
273 | |
} |
274 | |
|
275 | |
|
276 | |
|
277 | |
|
278 | |
|
279 | |
|
280 | |
|
281 | |
|
282 | |
|
283 | |
private void append( StringBuffer sb, String description, int indent ) |
284 | |
{ |
285 | 0 | for ( Iterator it = toLines( description, indent, indentSize, lineLength ).iterator(); it.hasNext(); ) |
286 | |
{ |
287 | 0 | sb.append( it.next().toString() ).append( '\n' ); |
288 | |
} |
289 | 0 | } |
290 | |
|
291 | |
|
292 | |
|
293 | |
|
294 | |
|
295 | |
|
296 | |
|
297 | |
|
298 | |
|
299 | |
|
300 | |
|
301 | |
private static List toLines( String text, int indent, int indentSize, int lineLength ) |
302 | |
{ |
303 | 0 | List<String> lines = new ArrayList<String>(); |
304 | |
|
305 | 0 | String ind = repeat( "\t", indent ); |
306 | 0 | String[] plainLines = text.split( "(\r\n)|(\r)|(\n)" ); |
307 | 0 | for ( int i = 0; i < plainLines.length; i++ ) |
308 | |
{ |
309 | 0 | toLines( lines, ind + plainLines[i], indentSize, lineLength ); |
310 | |
} |
311 | |
|
312 | 0 | return lines; |
313 | |
} |
314 | |
|
315 | |
|
316 | |
|
317 | |
|
318 | |
|
319 | |
|
320 | |
|
321 | |
|
322 | |
|
323 | |
private static void toLines( List<String> lines, String line, int indentSize, int lineLength ) |
324 | |
{ |
325 | 0 | int lineIndent = getIndentLevel( line ); |
326 | 0 | StringBuffer buf = new StringBuffer( 256 ); |
327 | 0 | String[] tokens = line.split( " +" ); |
328 | 0 | for ( int i = 0; i < tokens.length; i++ ) |
329 | |
{ |
330 | 0 | String token = tokens[i]; |
331 | 0 | if ( i > 0 ) |
332 | |
{ |
333 | 0 | if ( buf.length() + token.length() >= lineLength ) |
334 | |
{ |
335 | 0 | lines.add( buf.toString() ); |
336 | 0 | buf.setLength( 0 ); |
337 | 0 | buf.append( repeat( " ", lineIndent * indentSize ) ); |
338 | |
} |
339 | |
else |
340 | |
{ |
341 | 0 | buf.append( ' ' ); |
342 | |
} |
343 | |
} |
344 | 0 | for ( int j = 0; j < token.length(); j++ ) |
345 | |
{ |
346 | 0 | char c = token.charAt( j ); |
347 | 0 | if ( c == '\t' ) |
348 | |
{ |
349 | 0 | buf.append( repeat( " ", indentSize - buf.length() % indentSize ) ); |
350 | |
} |
351 | 0 | else if ( c == '\u00A0' ) |
352 | |
{ |
353 | 0 | buf.append( ' ' ); |
354 | |
} |
355 | |
else |
356 | |
{ |
357 | 0 | buf.append( c ); |
358 | |
} |
359 | |
} |
360 | |
} |
361 | 0 | lines.add( buf.toString() ); |
362 | 0 | } |
363 | |
|
364 | |
|
365 | |
|
366 | |
|
367 | |
|
368 | |
|
369 | |
|
370 | |
private static int getIndentLevel( String line ) |
371 | |
{ |
372 | 0 | int level = 0; |
373 | 0 | for ( int i = 0; i < line.length() && line.charAt( i ) == '\t'; i++ ) |
374 | |
{ |
375 | 0 | level++; |
376 | |
} |
377 | 0 | for ( int i = level + 1; i <= level + 4 && i < line.length(); i++ ) |
378 | |
{ |
379 | 0 | if ( line.charAt( i ) == '\t' ) |
380 | |
{ |
381 | 0 | level++; |
382 | 0 | break; |
383 | |
} |
384 | |
} |
385 | 0 | return level; |
386 | |
} |
387 | |
} |