1 | |
package org.apache.maven.plugin.idea; |
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 | 0 | public class HelpMojo |
18 | |
extends AbstractMojo |
19 | |
{ |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
private boolean detail; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
private java.lang.String goal; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
private int lineLength; |
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
private int indentSize; |
47 | |
|
48 | |
|
49 | |
|
50 | |
public void execute() |
51 | |
throws MojoExecutionException |
52 | |
{ |
53 | 0 | StringBuffer sb = new StringBuffer(); |
54 | |
|
55 | 0 | append( sb, "org.apache.maven.plugins:maven-idea-plugin:2.2", 0 ); |
56 | 0 | append( sb, "", 0 ); |
57 | |
|
58 | 0 | append( sb, "Maven IDEA Plugin 2.2", 0 ); |
59 | 0 | append( sb, "Maven Plugins", 1 ); |
60 | 0 | append( sb, "", 0 ); |
61 | |
|
62 | 0 | if ( goal == null || goal.length() <= 0 ) |
63 | |
{ |
64 | 0 | append( sb, "This plugin has 6 goals:", 0 ); |
65 | 0 | append( sb, "", 0 ); |
66 | |
} |
67 | |
|
68 | 0 | if ( goal == null || goal.length() <= 0 || "clean".equals( goal ) ) |
69 | |
{ |
70 | 0 | append( sb, "idea:clean", 0 ); |
71 | 0 | append( sb, "Removes all existing IDEA files for the project.", 1 ); |
72 | 0 | append( sb, "", 0 ); |
73 | 0 | if ( detail ) |
74 | |
{ |
75 | 0 | append( sb, "Available parameters:", 1 ); |
76 | 0 | append( sb, "", 0 ); |
77 | |
} |
78 | |
} |
79 | |
|
80 | 0 | if ( goal == null || goal.length() <= 0 || "help".equals( goal ) ) |
81 | |
{ |
82 | 0 | append( sb, "idea:help", 0 ); |
83 | 0 | append( sb, "Display help information on maven-idea-plugin. Call\n\u00a0\u00a0mvn\u00a0idea:help\u00a0-Ddetail=true\u00a0-Dgoal=<goal-name>\nto display parameter details.", 1 ); |
84 | 0 | append( sb, "", 0 ); |
85 | 0 | if ( detail ) |
86 | |
{ |
87 | 0 | append( sb, "Available parameters:", 1 ); |
88 | 0 | append( sb, "", 0 ); |
89 | |
|
90 | 0 | append( sb, "detail (Default: false)", 2 ); |
91 | 0 | append( sb, "If true, display all settable properties for each goal.", 3 ); |
92 | 0 | append( sb, "", 0 ); |
93 | |
|
94 | 0 | append( sb, "goal", 2 ); |
95 | 0 | append( sb, "The name of the goal for which to show help. If unspecified, all goals will be displayed.", 3 ); |
96 | 0 | append( sb, "", 0 ); |
97 | |
|
98 | 0 | append( sb, "lineLength (Default: 80)", 2 ); |
99 | 0 | append( sb, "The maximum length of a display line.", 3 ); |
100 | 0 | append( sb, "", 0 ); |
101 | |
|
102 | 0 | append( sb, "indentSize (Default: 2)", 2 ); |
103 | 0 | append( sb, "The number of spaces per indentation level.", 3 ); |
104 | 0 | append( sb, "", 0 ); |
105 | |
} |
106 | |
} |
107 | |
|
108 | 0 | if ( goal == null || goal.length() <= 0 || "idea".equals( goal ) ) |
109 | |
{ |
110 | 0 | append( sb, "idea:idea", 0 ); |
111 | 0 | append( sb, "Goal for generating IDEA files from a POM. This plug-in provides the ability to generate project files (.ipr, .iml and .iws files) for IDEA.", 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, "dependenciesAsLibraries (Default: false)", 2 ); |
119 | 0 | append( sb, "Causes the module libraries to use a short name for all dependencies. This is very convenient but has been reported to cause problems with IDEA.", 3 ); |
120 | 0 | append( sb, "", 0 ); |
121 | |
|
122 | 0 | append( sb, "deploymentDescriptorFile", 2 ); |
123 | 0 | append( sb, "Specify the location of the deployment descriptor file, if one is provided.", 3 ); |
124 | 0 | append( sb, "", 0 ); |
125 | |
|
126 | 0 | append( sb, "downloadJavadocs (Default: false)", 2 ); |
127 | 0 | append( sb, "Enables/disables the downloading of javadoc attachments.", 3 ); |
128 | 0 | append( sb, "", 0 ); |
129 | |
|
130 | 0 | append( sb, "downloadSources (Default: false)", 2 ); |
131 | 0 | append( sb, "Enables/disables the downloading of source attachments.", 3 ); |
132 | 0 | append( sb, "", 0 ); |
133 | |
|
134 | 0 | append( sb, "exclude", 2 ); |
135 | 0 | append( sb, "A comma-separated list of directories that should be excluded. These directories are in addition to those already excluded, such as target/classes. A common use of this is to exclude the entire target directory.", 3 ); |
136 | 0 | append( sb, "", 0 ); |
137 | |
|
138 | 0 | append( sb, "ideaPlugin (Default: false)", 2 ); |
139 | 0 | append( sb, "Tell IntelliJ IDEA that this module is an IntelliJ IDEA Plugin.", 3 ); |
140 | 0 | append( sb, "", 0 ); |
141 | |
|
142 | 0 | append( sb, "ideaVersion (Default: 5.x)", 2 ); |
143 | 0 | append( sb, "Specify the version of IDEA to target. This is needed to identify the default formatting of project-jdk-name used by IDEA. Currently supports 4.x and 5.x.\n>This will only be used when parameter jdkName is not set.\n", 3 ); |
144 | 0 | append( sb, "", 0 ); |
145 | |
|
146 | 0 | append( sb, "javadocClassifier (Default: javadoc)", 2 ); |
147 | 0 | append( sb, "Sets the classifier string attached to an artifact javadoc archive name.", 3 ); |
148 | 0 | append( sb, "", 0 ); |
149 | |
|
150 | 0 | append( sb, "jdkLevel", 2 ); |
151 | 0 | append( sb, "Specify the version of the JDK to use for the project for the purpose of enabled assertions and Java 5.0 language features. The default value is the specification version of the executing JVM.", 3 ); |
152 | 0 | append( sb, "", 0 ); |
153 | |
|
154 | 0 | append( sb, "jdkName", 2 ); |
155 | 0 | append( sb, "Specify the name of the registered IDEA JDK to use for the project.", 3 ); |
156 | 0 | append( sb, "", 0 ); |
157 | |
|
158 | 0 | append( sb, "libraries", 2 ); |
159 | 0 | append( sb, "An optional set of Library objects that allow you to specify a comma separated list of source dirs, class dirs, or to indicate that the library should be excluded from the module. For example:\n>\n\n<libraries>\n<library>\n<name>webwork</name>\n<sources>file://$webwork$/src/java</sources>\n<!--\n<classes>...</classes>\n<exclude>true</exclude>\n-->\n</library>\n</libraries>\n", 3 ); |
160 | 0 | append( sb, "", 0 ); |
161 | |
|
162 | 0 | append( sb, "linkModules (Default: true)", 2 ); |
163 | 0 | append( sb, "Whether to link the reactor projects as dependency modules or as libraries.", 3 ); |
164 | 0 | append( sb, "", 0 ); |
165 | |
|
166 | 0 | append( sb, "overwrite (Default: false)", 2 ); |
167 | 0 | append( sb, "Whether to update the existing project files or overwrite them.", 3 ); |
168 | 0 | append( sb, "", 0 ); |
169 | |
|
170 | 0 | append( sb, "sourceClassifier (Default: sources)", 2 ); |
171 | 0 | append( sb, "Sets the classifier string attached to an artifact source archive name.", 3 ); |
172 | 0 | append( sb, "", 0 ); |
173 | |
|
174 | 0 | append( sb, "useFullNames (Default: false)", 2 ); |
175 | 0 | append( sb, "Whether to use full artifact names when referencing libraries.", 3 ); |
176 | 0 | append( sb, "", 0 ); |
177 | |
|
178 | 0 | append( sb, "wildcardResourcePatterns (Default: !?*.java)", 2 ); |
179 | 0 | append( sb, "Specify the resource pattern in wildcard format, for example \'?*.xml;?*.properties\'. Currently supports 4.x and 5.x. Because IDEA doesn\'t distinguish between source and resources directories, this is needed. The default value corresponds to any file without a java extension. Please note that the default value includes package.html files as it\'s not possible to exclude those.", 3 ); |
180 | 0 | append( sb, "", 0 ); |
181 | |
} |
182 | |
} |
183 | |
|
184 | 0 | if ( goal == null || goal.length() <= 0 || "module".equals( goal ) ) |
185 | |
{ |
186 | 0 | append( sb, "idea:module", 0 ); |
187 | 0 | append( sb, "Creates the module files (*.iml) for IntelliJ IDEA.", 1 ); |
188 | 0 | append( sb, "", 0 ); |
189 | 0 | if ( detail ) |
190 | |
{ |
191 | 0 | append( sb, "Available parameters:", 1 ); |
192 | 0 | append( sb, "", 0 ); |
193 | |
|
194 | 0 | append( sb, "dependenciesAsLibraries (Default: false)", 2 ); |
195 | 0 | append( sb, "Causes the module libraries to use a short name for all dependencies. This is very convenient but has been reported to cause problems with IDEA.", 3 ); |
196 | 0 | append( sb, "", 0 ); |
197 | |
|
198 | 0 | append( sb, "deploymentDescriptorFile", 2 ); |
199 | 0 | append( sb, "Specify the location of the deployment descriptor file, if one is provided.", 3 ); |
200 | 0 | append( sb, "", 0 ); |
201 | |
|
202 | 0 | append( sb, "downloadJavadocs (Default: false)", 2 ); |
203 | 0 | append( sb, "Enables/disables the downloading of javadoc attachments.", 3 ); |
204 | 0 | append( sb, "", 0 ); |
205 | |
|
206 | 0 | append( sb, "downloadSources (Default: false)", 2 ); |
207 | 0 | append( sb, "Enables/disables the downloading of source attachments.", 3 ); |
208 | 0 | append( sb, "", 0 ); |
209 | |
|
210 | 0 | append( sb, "exclude", 2 ); |
211 | 0 | append( sb, "A comma-separated list of directories that should be excluded. These directories are in addition to those already excluded, such as target.", 3 ); |
212 | 0 | append( sb, "", 0 ); |
213 | |
|
214 | 0 | append( sb, "ideaPlugin (Default: false)", 2 ); |
215 | 0 | append( sb, "Tell IntelliJ IDEA that this module is an IntelliJ IDEA Plugin.", 3 ); |
216 | 0 | append( sb, "", 0 ); |
217 | |
|
218 | 0 | append( sb, "ideaVersion (Default: 5.x)", 2 ); |
219 | 0 | append( sb, "Specify the version of IDEA to target. This is needed to identify the default formatting of project-jdk-name used by IDEA. Currently supports 4.x and 5.x.\n>This will only be used when parameter jdkName is not set.\n", 3 ); |
220 | 0 | append( sb, "", 0 ); |
221 | |
|
222 | 0 | append( sb, "javadocClassifier (Default: javadoc)", 2 ); |
223 | 0 | append( sb, "Sets the classifier string attached to an artifact javadoc archive name.", 3 ); |
224 | 0 | append( sb, "", 0 ); |
225 | |
|
226 | 0 | append( sb, "libraries", 2 ); |
227 | 0 | append( sb, "An optional set of Library objects that allow you to specify a comma separated list of source dirs, class dirs, or to indicate that the library should be excluded from the module. For example:\n>\n\n<libraries>\n<library>\n<name>webwork</name>\n<sources>file://$webwork$/src/java</sources>\n<!--\n<classes>...</classes>\n<exclude>true</exclude>\n-->\n</library>\n</libraries>\n", 3 ); |
228 | 0 | append( sb, "", 0 ); |
229 | |
|
230 | 0 | append( sb, "linkModules (Default: true)", 2 ); |
231 | 0 | append( sb, "Whether to link the reactor projects as dependency modules or as libraries.", 3 ); |
232 | 0 | append( sb, "", 0 ); |
233 | |
|
234 | 0 | append( sb, "overwrite (Default: false)", 2 ); |
235 | 0 | append( sb, "Whether to update the existing project files or overwrite them.", 3 ); |
236 | 0 | append( sb, "", 0 ); |
237 | |
|
238 | 0 | append( sb, "sourceClassifier (Default: sources)", 2 ); |
239 | 0 | append( sb, "Sets the classifier string attached to an artifact source archive name.", 3 ); |
240 | 0 | append( sb, "", 0 ); |
241 | |
|
242 | 0 | append( sb, "useFullNames (Default: false)", 2 ); |
243 | 0 | append( sb, "Whether to use full artifact names when referencing libraries.", 3 ); |
244 | 0 | append( sb, "", 0 ); |
245 | |
} |
246 | |
} |
247 | |
|
248 | 0 | if ( goal == null || goal.length() <= 0 || "project".equals( goal ) ) |
249 | |
{ |
250 | 0 | append( sb, "idea:project", 0 ); |
251 | 0 | append( sb, "Creates the project file (*.ipr) for IntelliJ IDEA.", 1 ); |
252 | 0 | append( sb, "", 0 ); |
253 | 0 | if ( detail ) |
254 | |
{ |
255 | 0 | append( sb, "Available parameters:", 1 ); |
256 | 0 | append( sb, "", 0 ); |
257 | |
|
258 | 0 | append( sb, "ideaVersion (Default: 5.x)", 2 ); |
259 | 0 | append( sb, "Specify the version of IDEA to target. This is needed to identify the default formatting of project-jdk-name used by IDEA. Currently supports 4.x and 5.x.\n>This will only be used when parameter jdkName is not set.\n", 3 ); |
260 | 0 | append( sb, "", 0 ); |
261 | |
|
262 | 0 | append( sb, "jdkLevel", 2 ); |
263 | 0 | append( sb, "Specify the version of the JDK to use for the project for the purpose of enabled assertions and Java 5.0 language features. The default value is the specification version of the executing JVM.", 3 ); |
264 | 0 | append( sb, "", 0 ); |
265 | |
|
266 | 0 | append( sb, "jdkName", 2 ); |
267 | 0 | append( sb, "Specify the name of the registered IDEA JDK to use for the project.", 3 ); |
268 | 0 | append( sb, "", 0 ); |
269 | |
|
270 | 0 | append( sb, "overwrite (Default: false)", 2 ); |
271 | 0 | append( sb, "Whether to update the existing project files or overwrite them.", 3 ); |
272 | 0 | append( sb, "", 0 ); |
273 | |
|
274 | 0 | append( sb, "wildcardResourcePatterns (Default: !?*.java)", 2 ); |
275 | 0 | append( sb, "Specify the resource pattern in wildcard format, for example \'?*.xml;?*.properties\'. Currently supports 4.x and 5.x. Because IDEA doesn\'t distinguish between source and resources directories, this is needed. The default value corresponds to any file without a java extension. Please note that the default value includes package.html files as it\'s not possible to exclude those.", 3 ); |
276 | 0 | append( sb, "", 0 ); |
277 | |
} |
278 | |
} |
279 | |
|
280 | 0 | if ( goal == null || goal.length() <= 0 || "workspace".equals( goal ) ) |
281 | |
{ |
282 | 0 | append( sb, "idea:workspace", 0 ); |
283 | 0 | append( sb, "Creates the workspace file (*.iws) for IntelliJ IDEA.", 1 ); |
284 | 0 | append( sb, "", 0 ); |
285 | 0 | if ( detail ) |
286 | |
{ |
287 | 0 | append( sb, "Available parameters:", 1 ); |
288 | 0 | append( sb, "", 0 ); |
289 | |
|
290 | 0 | append( sb, "overwrite (Default: false)", 2 ); |
291 | 0 | append( sb, "Whether to update the existing project files or overwrite them.", 3 ); |
292 | 0 | append( sb, "", 0 ); |
293 | |
} |
294 | |
} |
295 | |
|
296 | 0 | if ( getLog().isInfoEnabled() ) |
297 | |
{ |
298 | 0 | getLog().info( sb.toString() ); |
299 | |
} |
300 | 0 | } |
301 | |
|
302 | |
|
303 | |
|
304 | |
|
305 | |
|
306 | |
|
307 | |
|
308 | |
|
309 | |
|
310 | |
|
311 | |
private static String repeat( String str, int repeat ) |
312 | |
{ |
313 | 0 | StringBuffer buffer = new StringBuffer( repeat * str.length() ); |
314 | |
|
315 | 0 | for ( int i = 0; i < repeat; i++ ) |
316 | |
{ |
317 | 0 | buffer.append( str ); |
318 | |
} |
319 | |
|
320 | 0 | return buffer.toString(); |
321 | |
} |
322 | |
|
323 | |
private void append( StringBuffer sb, String description, int indent ) |
324 | |
{ |
325 | 0 | for ( Iterator it = toLines( description, indent ).iterator(); it.hasNext(); ) |
326 | |
{ |
327 | 0 | sb.append( it.next().toString() ).append( '\n' ); |
328 | |
} |
329 | 0 | } |
330 | |
|
331 | |
|
332 | |
|
333 | |
|
334 | |
|
335 | |
|
336 | |
|
337 | |
|
338 | |
private List toLines( String text, int indent ) |
339 | |
{ |
340 | 0 | List lines = new ArrayList(); |
341 | |
|
342 | 0 | String ind = repeat( "\t", indent ); |
343 | 0 | String[] plainLines = text.split( "(\r\n)|(\r)|(\n)" ); |
344 | 0 | for ( int i = 0; i < plainLines.length; i++ ) |
345 | |
{ |
346 | 0 | toLines( lines, ind + plainLines[i] ); |
347 | |
} |
348 | |
|
349 | 0 | return lines; |
350 | |
} |
351 | |
|
352 | |
|
353 | |
|
354 | |
|
355 | |
|
356 | |
|
357 | |
|
358 | |
private void toLines( List lines, String line ) |
359 | |
{ |
360 | 0 | int lineIndent = getIndentLevel( line ); |
361 | 0 | StringBuffer buf = new StringBuffer( 256 ); |
362 | 0 | String[] tokens = line.split( " +" ); |
363 | 0 | for ( int i = 0; i < tokens.length; i++ ) |
364 | |
{ |
365 | 0 | String token = tokens[i]; |
366 | 0 | if ( i > 0 ) |
367 | |
{ |
368 | 0 | if ( buf.length() + token.length() >= lineLength ) |
369 | |
{ |
370 | 0 | lines.add( buf.toString() ); |
371 | 0 | buf.setLength( 0 ); |
372 | 0 | buf.append( repeat( " ", lineIndent * indentSize ) ); |
373 | |
} |
374 | |
else |
375 | |
{ |
376 | 0 | buf.append( ' ' ); |
377 | |
} |
378 | |
} |
379 | 0 | for ( int j = 0; j < token.length(); j++ ) |
380 | |
{ |
381 | 0 | char c = token.charAt( j ); |
382 | 0 | if ( c == '\t' ) |
383 | |
{ |
384 | 0 | buf.append( repeat( " ", indentSize - buf.length() % indentSize ) ); |
385 | |
} |
386 | 0 | else if ( c == '\u00A0' ) |
387 | |
{ |
388 | 0 | buf.append( ' ' ); |
389 | |
} |
390 | |
else |
391 | |
{ |
392 | 0 | buf.append( c ); |
393 | |
} |
394 | |
} |
395 | |
} |
396 | 0 | lines.add( buf.toString() ); |
397 | 0 | } |
398 | |
|
399 | |
|
400 | |
|
401 | |
|
402 | |
|
403 | |
|
404 | |
|
405 | |
private static int getIndentLevel( String line ) |
406 | |
{ |
407 | 0 | int level = 0; |
408 | 0 | for ( int i = 0; i < line.length() && line.charAt( i ) == '\t'; i++ ) |
409 | |
{ |
410 | 0 | level++; |
411 | |
} |
412 | 0 | for ( int i = level + 1; i <= level + 4 && i < line.length(); i++ ) |
413 | |
{ |
414 | 0 | if ( line.charAt( i ) == '\t' ) |
415 | |
{ |
416 | 0 | level++; |
417 | 0 | break; |
418 | |
} |
419 | |
} |
420 | 0 | return level; |
421 | |
} |
422 | |
} |