1 | |
package org.apache.maven.plugin.invoker; |
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 | 0 | public class HelpMojo |
19 | |
extends AbstractMojo |
20 | |
{ |
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
private boolean detail; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
private java.lang.String goal; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
private int lineLength; |
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
private int indentSize; |
48 | |
|
49 | |
|
50 | |
|
51 | |
public void execute() |
52 | |
throws MojoExecutionException |
53 | |
{ |
54 | 0 | if ( lineLength <= 0 ) |
55 | |
{ |
56 | 0 | getLog().warn( "The parameter 'lineLength' should be positive, using '80' as default." ); |
57 | 0 | lineLength = 80; |
58 | |
} |
59 | 0 | if ( indentSize <= 0 ) |
60 | |
{ |
61 | 0 | getLog().warn( "The parameter 'indentSize' should be positive, using '2' as default." ); |
62 | 0 | indentSize = 2; |
63 | |
} |
64 | |
|
65 | 0 | StringBuffer sb = new StringBuffer(); |
66 | |
|
67 | 0 | append( sb, "org.apache.maven.plugins:maven-invoker-plugin:1.5", 0 ); |
68 | 0 | append( sb, "", 0 ); |
69 | |
|
70 | 0 | append( sb, "Maven Invoker Plugin", 0 ); |
71 | 0 | append( sb, "The Maven Invoker Plugin is used to run a set of Maven projects. The plugin can determine whether each project execution is successful, and optionally can verify the output generated from a given project execution.", 1 ); |
72 | 0 | append( sb, "", 0 ); |
73 | |
|
74 | 0 | if ( goal == null || goal.length() <= 0 ) |
75 | |
{ |
76 | 0 | append( sb, "This plugin has 6 goals:", 0 ); |
77 | 0 | append( sb, "", 0 ); |
78 | |
} |
79 | |
|
80 | 0 | if ( goal == null || goal.length() <= 0 || "help".equals( goal ) ) |
81 | |
{ |
82 | 0 | append( sb, "invoker:help", 0 ); |
83 | 0 | append( sb, "Display help information on maven-invoker-plugin.\nCall\n\u00a0\u00a0mvn\u00a0invoker: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, "indentSize (Default: 2)", 2 ); |
99 | 0 | append( sb, "The number of spaces per indentation level, should be positive.", 3 ); |
100 | 0 | append( sb, "", 0 ); |
101 | |
|
102 | 0 | append( sb, "lineLength (Default: 80)", 2 ); |
103 | 0 | append( sb, "The maximum length of a display line, should be positive.", 3 ); |
104 | 0 | append( sb, "", 0 ); |
105 | |
} |
106 | |
} |
107 | |
|
108 | 0 | if ( goal == null || goal.length() <= 0 || "install".equals( goal ) ) |
109 | |
{ |
110 | 0 | append( sb, "invoker:install", 0 ); |
111 | 0 | append( sb, "Installs the project artifacts of the main build into the local repository as a preparation to run the sub projects. More precisely, all artifacts of the project itself, all its locally reachable parent POMs and all its dependencies from the reactor will be installed to the local 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, "localRepositoryPath", 2 ); |
119 | 0 | append( sb, "The path to the local repository into which the project artifacts should be installed for the integration tests. If not set, the regular local repository will be used. To prevent soiling of your regular local repository with possibly broken artifacts, it is strongly recommended to use an isolated repository for the integration tests (e.g. ${project.build.directory}/it-repo).", 3 ); |
120 | 0 | append( sb, "", 0 ); |
121 | |
|
122 | 0 | append( sb, "skipInstallation (Default: false)", 2 ); |
123 | 0 | append( sb, "A flag used to disable the installation procedure. This is primarily intended for usage from the command line to occasionally adjust the build.", 3 ); |
124 | 0 | append( sb, "", 0 ); |
125 | |
} |
126 | |
} |
127 | |
|
128 | 0 | if ( goal == null || goal.length() <= 0 || "integration-test".equals( goal ) ) |
129 | |
{ |
130 | 0 | append( sb, "invoker:integration-test", 0 ); |
131 | 0 | append( sb, "Searches for integration test Maven projects, and executes each, collecting a log in the project directory, will never fail the build, designed to be used in conjunction with the verify mojo.", 1 ); |
132 | 0 | append( sb, "", 0 ); |
133 | 0 | if ( detail ) |
134 | |
{ |
135 | 0 | append( sb, "Available parameters:", 1 ); |
136 | 0 | append( sb, "", 0 ); |
137 | |
|
138 | 0 | append( sb, "addTestClassPath (Default: false)", 2 ); |
139 | 0 | append( sb, "A flag whether the test class path of the project under test should be included in the class path of the pre-/post-build scripts. If set to false, the class path of script interpreter consists only of the runtime dependencies of the Maven Invoker Plugin. If set the true, the project\'s test class path will be prepended to the interpreter class path. Among others, this feature allows the scripts to access utility classes from the test sources of your project.", 3 ); |
140 | 0 | append( sb, "", 0 ); |
141 | |
|
142 | 0 | append( sb, "cloneAllFiles (Default: false)", 2 ); |
143 | 0 | append( sb, "Some files are normally excluded when copying the IT projects from the directory specified by the parameter projectsDirectory to the directory given by cloneProjectsTo (e.g. .svn, CVS, *~, etc). Setting this parameter to true will cause all files to be copied to the cloneProjectsTo directory.", 3 ); |
144 | 0 | append( sb, "", 0 ); |
145 | |
|
146 | 0 | append( sb, "cloneProjectsTo", 2 ); |
147 | 0 | append( sb, "Directory to which projects should be cloned prior to execution. If not specified, each integration test will be run in the directory in which the corresponding IT POM was found. In this case, you most likely want to configure your SCM to ignore target and build.log in the test\'s base directory.", 3 ); |
148 | 0 | append( sb, "", 0 ); |
149 | |
|
150 | 0 | append( sb, "debug (Default: false)", 2 ); |
151 | 0 | append( sb, "Whether to show debug statements in the build output.", 3 ); |
152 | 0 | append( sb, "", 0 ); |
153 | |
|
154 | 0 | append( sb, "disableReports (Default: false)", 2 ); |
155 | 0 | append( sb, "A flag to disable the generation of build reports.", 3 ); |
156 | 0 | append( sb, "", 0 ); |
157 | |
|
158 | 0 | append( sb, "encoding (Default: ${project.build.sourceEncoding})", 2 ); |
159 | 0 | append( sb, "The file encoding for the pre-/post-build scripts and the list files for goals and profiles.", 3 ); |
160 | 0 | append( sb, "", 0 ); |
161 | |
|
162 | 0 | append( sb, "filterProperties", 2 ); |
163 | 0 | append( sb, "A list of additional properties which will be used to filter tokens in POMs and goal files.", 3 ); |
164 | 0 | append( sb, "", 0 ); |
165 | |
|
166 | 0 | append( sb, "goals", 2 ); |
167 | 0 | append( sb, "The list of goals to execute on each project. Default value is: package.", 3 ); |
168 | 0 | append( sb, "", 0 ); |
169 | |
|
170 | 0 | append( sb, "goalsFile (Default: goals.txt)", 2 ); |
171 | 0 | append( sb, "Deprecated. As of version 1.2, the key invoker.goals from the properties file specified by the parameter invokerPropertiesFile should be used instead.", 3 ); |
172 | 0 | append( sb, "", 0 ); |
173 | 0 | append( sb, "The name of the project-specific file that contains the enumeration of goals to execute for that test.", 3 ); |
174 | 0 | append( sb, "", 0 ); |
175 | |
|
176 | 0 | append( sb, "interpolationsProperties", 2 ); |
177 | 0 | append( sb, "Deprecated. As of version 1.3, the parameter filterProperties should be used instead.", 3 ); |
178 | 0 | append( sb, "", 0 ); |
179 | 0 | append( sb, "List of properties which will be used to interpolate goal files.", 3 ); |
180 | 0 | append( sb, "", 0 ); |
181 | |
|
182 | 0 | append( sb, "invokerPropertiesFile (Default: invoker.properties)", 2 ); |
183 | 0 | append( sb, "The name of an optional project-specific file that contains properties used to specify settings for an individual Maven invocation. Any property present in the file will override the corresponding setting from the plugin configuration. The values of the properties are filtered and may use expressions like ${project.version} to reference project properties or values from the parameter filterProperties. The snippet below describes the supported properties:\n#\u00a0A\u00a0comma\u00a0or\u00a0space\u00a0separated\u00a0list\u00a0of\u00a0goals/phases\u00a0to\u00a0execute,\u00a0may\n#\u00a0specify\u00a0an\u00a0empty\u00a0list\u00a0to\u00a0execute\u00a0the\u00a0default\u00a0goal\u00a0of\u00a0the\u00a0IT\u00a0project\ninvoker.goals\u00a0=\u00a0clean\u00a0install\n\n#\u00a0Optionally,\u00a0a\u00a0list\u00a0of\u00a0goals\u00a0to\u00a0run\u00a0during\u00a0further\u00a0invocations\u00a0of\u00a0Maven\ninvoker.goals.2\u00a0=\u00a0${project.groupId}:${project.artifactId}:${project.version}:run\n\n#\u00a0A\u00a0comma\u00a0or\u00a0space\u00a0separated\u00a0list\u00a0of\u00a0profiles\u00a0to\u00a0activate\ninvoker.profiles\u00a0=\u00a0its,jdk15\n\n#\u00a0The\u00a0path\u00a0to\u00a0an\u00a0alternative\u00a0POM\u00a0or\u00a0base\u00a0directory\u00a0to\u00a0invoke\u00a0Maven\u00a0on,\u00a0defaults\u00a0to\u00a0the\n#\u00a0project\u00a0that\u00a0was\u00a0originally\u00a0specified\u00a0in\u00a0the\u00a0plugin\u00a0configuration\n#\u00a0Since\u00a0plugin\u00a0version\u00a01.4\ninvoker.project\u00a0=\u00a0sub-module\n\n#\u00a0The\u00a0value\u00a0for\u00a0the\u00a0environment\u00a0variable\u00a0MAVEN_OPTS\ninvoker.mavenOpts\u00a0=\u00a0-Dfile.encoding=UTF-16\u00a0-Xms32m\u00a0-Xmx256m\n\n#\u00a0Possible\u00a0values\u00a0are\u00a0\'fail-fast\'\u00a0(default),\u00a0\'fail-at-end\'\u00a0and\u00a0\'fail-never\'\ninvoker.failureBehavior\u00a0=\u00a0fail-never\n\n#\u00a0The\u00a0expected\u00a0result\u00a0of\u00a0the\u00a0build,\u00a0possible\u00a0values\u00a0are\u00a0\'success\'\u00a0(default)\u00a0and\u00a0\'failure\'\ninvoker.buildResult\u00a0=\u00a0failure\n\n#\u00a0A\u00a0boolean\u00a0value\u00a0controlling\u00a0the\u00a0aggregator\u00a0mode\u00a0of\u00a0Maven,\u00a0defaults\u00a0to\u00a0\'false\'\ninvoker.nonRecursive\u00a0=\u00a0true\n\n#\u00a0A\u00a0boolean\u00a0value\u00a0controlling\u00a0the\u00a0network\u00a0behavior\u00a0of\u00a0Maven,\u00a0defaults\u00a0to\u00a0\'false\'\n#\u00a0Since\u00a0plugin\u00a0version\u00a01.4\ninvoker.offline\u00a0=\u00a0true\n\n#\u00a0The\u00a0path\u00a0to\u00a0the\u00a0properties\u00a0file\u00a0from\u00a0which\u00a0to\u00a0load\u00a0system\u00a0properties,\u00a0defaults\u00a0to\u00a0the\n#\u00a0filename\u00a0given\u00a0by\u00a0the\u00a0plugin\u00a0parameter\u00a0testPropertiesFile\n#\u00a0Since\u00a0plugin\u00a0version\u00a01.4\ninvoker.systemPropertiesFile\u00a0=\u00a0test.properties\n\n#\u00a0An\u00a0optional\u00a0human\u00a0friendly\u00a0name\u00a0for\u00a0this\u00a0build\u00a0job\u00a0to\u00a0be\u00a0included\u00a0in\u00a0the\u00a0build\u00a0reports.\n#\u00a0Since\u00a0plugin\u00a0version\u00a01.4\ninvoker.name\u00a0=\u00a0Test\u00a0Build\u00a001\n\n#\u00a0An\u00a0optional\u00a0description\u00a0for\u00a0this\u00a0build\u00a0job\u00a0to\u00a0be\u00a0included\u00a0in\u00a0the\u00a0build\u00a0reports.\n#\u00a0Since\u00a0plugin\u00a0version\u00a01.4\ninvoker.description\u00a0=\u00a0Checks\u00a0the\u00a0support\u00a0for\u00a0build\u00a0reports.\n\n#\u00a0A\u00a0comma\u00a0separated\u00a0list\u00a0of\u00a0JRE\u00a0versions\u00a0on\u00a0which\u00a0this\u00a0build\u00a0job\u00a0should\u00a0be\u00a0run.\n#\u00a0Since\u00a0plugin\u00a0version\u00a01.4\ninvoker.java.version\u00a0=\u00a01.4+,\u00a0!1.4.1,\u00a01.7-\n\n#\u00a0A\u00a0comma\u00a0separated\u00a0list\u00a0of\u00a0OS\u00a0families\u00a0on\u00a0which\u00a0this\u00a0build\u00a0job\u00a0should\u00a0be\u00a0run.\n#\u00a0Since\u00a0plugin\u00a0version\u00a01.4\ninvoker.os.family\u00a0=\u00a0!windows,\u00a0unix,\u00a0mac\n\n#\u00a0A\u00a0comma\u00a0separated\u00a0list\u00a0of\u00a0Maven\u00a0versions\u00a0on\u00a0which\u00a0this\u00a0build\u00a0should\u00a0be\u00a0run.\n#\u00a0Since\u00a0plugin\u00a0version\u00a01.5\ninvoker.maven.version\u00a0=\u00a02.0.10+,\u00a0!2.1.0,\u00a0!2.2.0\n", 3 ); |
184 | 0 | append( sb, "", 0 ); |
185 | |
|
186 | 0 | append( sb, "invokerTest", 2 ); |
187 | 0 | append( sb, "A comma separated list of project names to run. Specify this parameter to run individual tests by file name, overriding the setupIncludes, pomIncludes and pomExcludes parameters. Each pattern you specify here will be used to create an include pattern formatted like ${projectsDirectory}/pattern, so you can just type -Dinvoker.test=FirstTest,SecondTest to run builds in ${projectsDirectory}/FirstTest and ${projectsDirectory}/SecondTest.", 3 ); |
188 | 0 | append( sb, "", 0 ); |
189 | |
|
190 | 0 | append( sb, "javaHome", 2 ); |
191 | 0 | append( sb, "The JAVA_HOME environment variable to use for forked Maven invocations. Defaults to the current Java home directory.", 3 ); |
192 | 0 | append( sb, "", 0 ); |
193 | |
|
194 | 0 | append( sb, "localRepositoryPath (Default: ${settings.localRepository})", 2 ); |
195 | 0 | append( sb, "The local repository for caching artifacts. It is strongly recommended to specify a path to an isolated repository like ${project.build.directory}/it-repo. Otherwise, your ordinary local repository will be used, potentially soiling it with broken artifacts.", 3 ); |
196 | 0 | append( sb, "", 0 ); |
197 | |
|
198 | 0 | append( sb, "mavenHome", 2 ); |
199 | 0 | append( sb, "The home directory of the Maven installation to use for the forked builds. Defaults to the current Maven installation.", 3 ); |
200 | 0 | append( sb, "", 0 ); |
201 | |
|
202 | 0 | append( sb, "mavenOpts", 2 ); |
203 | 0 | append( sb, "The MAVEN_OPTS environment variable to use when invoking Maven. This value can be overridden for individual integration tests by using invokerPropertiesFile.", 3 ); |
204 | 0 | append( sb, "", 0 ); |
205 | |
|
206 | 0 | append( sb, "noLog (Default: false)", 2 ); |
207 | 0 | append( sb, "Suppress logging to the build.log file.", 3 ); |
208 | 0 | append( sb, "", 0 ); |
209 | |
|
210 | 0 | append( sb, "pom", 2 ); |
211 | 0 | append( sb, "A single POM to build, skipping any scanning parameters and behavior.", 3 ); |
212 | 0 | append( sb, "", 0 ); |
213 | |
|
214 | 0 | append( sb, "pomExcludes", 2 ); |
215 | 0 | append( sb, "Exclude patterns for searching the integration test directory. This parameter is meant to be set from the POM. By default, no POM files are excluded. For the convenience of using an include pattern like *, the custom settings file specified by the parameter settingsFile will always be excluded automatically.", 3 ); |
216 | 0 | append( sb, "", 0 ); |
217 | |
|
218 | 0 | append( sb, "pomIncludes", 2 ); |
219 | 0 | append( sb, "Include patterns for searching the integration test directory for projects. This parameter is meant to be set from the POM. If this parameter is not set, the plugin will search for all pom.xml files one directory below projectsDirectory (i.e. */pom.xml).\n\nStarting with version 1.3, mere directories can also be matched by these patterns. For example, the include pattern * will run Maven builds on all immediate sub directories of projectsDirectory, regardless if they contain a pom.xml. This allows to perform builds that need/should not depend on the existence of a POM.", 3 ); |
220 | 0 | append( sb, "", 0 ); |
221 | |
|
222 | 0 | append( sb, "postBuildHookScript (Default: postbuild)", 2 ); |
223 | 0 | append( sb, "Relative path of a cleanup/verification hook script to run after executing the build. This script may be written with either BeanShell or Groovy (since 1.3). If the file extension is omitted (e.g. verify), the plugin searches for the file by trying out the well-known extensions .bsh and .groovy. If this script exists for a particular project but returns any non-null value different from true or throws an exception, the corresponding build is flagged as a failure.", 3 ); |
224 | 0 | append( sb, "", 0 ); |
225 | |
|
226 | 0 | append( sb, "preBuildHookScript (Default: prebuild)", 2 ); |
227 | 0 | append( sb, "Relative path of a pre-build hook script to run prior to executing the build. This script may be written with either BeanShell or Groovy (since 1.3). If the file extension is omitted (e.g. prebuild), the plugin searches for the file by trying out the well-known extensions .bsh and .groovy. If this script exists for a particular project but returns any non-null value different from true or throws an exception, the corresponding build is flagged as a failure. In this case, neither Maven nor the post-build hook script will be invoked.", 3 ); |
228 | 0 | append( sb, "", 0 ); |
229 | |
|
230 | 0 | append( sb, "profiles", 2 ); |
231 | 0 | append( sb, "List of profile identifiers to explicitly trigger in the build.", 3 ); |
232 | 0 | append( sb, "", 0 ); |
233 | |
|
234 | 0 | append( sb, "profilesFile (Default: profiles.txt)", 2 ); |
235 | 0 | append( sb, "Deprecated. As of version 1.2, the key invoker.profiles from the properties file specified by the parameter invokerPropertiesFile should be used instead.", 3 ); |
236 | 0 | append( sb, "", 0 ); |
237 | 0 | append( sb, "The name of the project-specific file that contains the enumeration of profiles to use for that test. If the file exists and is empty no profiles will be used even if the parameter profiles is set.", 3 ); |
238 | 0 | append( sb, "", 0 ); |
239 | |
|
240 | 0 | append( sb, "projectsDirectory (Default: ${basedir}/src/it/)", 2 ); |
241 | 0 | append( sb, "Directory to search for integration tests.", 3 ); |
242 | 0 | append( sb, "", 0 ); |
243 | |
|
244 | 0 | append( sb, "properties", 2 ); |
245 | 0 | append( sb, "Common set of properties to pass in on each project\'s command line, via -D parameters.", 3 ); |
246 | 0 | append( sb, "", 0 ); |
247 | |
|
248 | 0 | append( sb, "reportsDirectory (Default: ${project.build.directory}/invoker-reports)", 2 ); |
249 | 0 | append( sb, "Base directory where all build reports are written to.", 3 ); |
250 | 0 | append( sb, "", 0 ); |
251 | |
|
252 | 0 | append( sb, "selectorScript (Default: selector)", 2 ); |
253 | 0 | append( sb, "Relative path of a selector script to run prior in order to decide if the build should be executed. This script may be written with either BeanShell or Groovy. If the file extension is omitted (e.g. selector), the plugin searches for the file by trying out the well-known extensions .bsh and .groovy. If this script exists for a particular project but returns any non-null value different from true, the corresponding build is flagged as skipped. In this case, none of the pre-build hook script, Maven nor the post-build hook script will be invoked. If this script throws an exception, the corresponding build is flagged as in error, and none of the pre-build hook script, Maven not the post-build hook script will be invoked.", 3 ); |
254 | 0 | append( sb, "", 0 ); |
255 | |
|
256 | 0 | append( sb, "settingsFile", 2 ); |
257 | 0 | append( sb, "Path to an alternate settings.xml to use for Maven invocation with all ITs. Note that the <localRepository> element of this settings file is always ignored, i.e. the path given by the parameter localRepositoryPath is dominant.", 3 ); |
258 | 0 | append( sb, "", 0 ); |
259 | |
|
260 | 0 | append( sb, "setupIncludes", 2 ); |
261 | 0 | append( sb, "Include patterns for searching the projects directory for projects that need to be run before the other projects. This parameter allows to declare projects that perform setup tasks like installing utility artifacts into the local repository. Projects matched by these patterns are implicitly excluded from the scan for ordinary projects. Also, the exclusions defined by the parameter pomExcludes apply to the setup projects, too. Default value is: setup*/pom.xml.", 3 ); |
262 | 0 | append( sb, "", 0 ); |
263 | |
|
264 | 0 | append( sb, "showErrors (Default: false)", 2 ); |
265 | 0 | append( sb, "Whether to show errors in the build output.", 3 ); |
266 | 0 | append( sb, "", 0 ); |
267 | |
|
268 | 0 | append( sb, "showVersion (Default: false)", 2 ); |
269 | 0 | append( sb, "flag to enable show mvn version used for running its (cli option : -V,--show-version )", 3 ); |
270 | 0 | append( sb, "", 0 ); |
271 | |
|
272 | 0 | append( sb, "skipInvocation (Default: false)", 2 ); |
273 | 0 | append( sb, "Flag used to suppress certain invocations. This is useful in tailoring the build using profiles.", 3 ); |
274 | 0 | append( sb, "", 0 ); |
275 | |
|
276 | 0 | append( sb, "streamLogs (Default: false)", 2 ); |
277 | 0 | append( sb, "Flag used to determine whether the build logs should be output to the normal mojo log.", 3 ); |
278 | 0 | append( sb, "", 0 ); |
279 | |
|
280 | 0 | append( sb, "suppressSummaries (Default: false)", 2 ); |
281 | 0 | append( sb, "Flag used to suppress the summary output notifying of successes and failures. If set to true, the only indication of the build\'s success or failure will be the effect it has on the main build (if it fails, the main build should fail as well). If streamLogs is enabled, the sub-build summary will also provide an indication.", 3 ); |
282 | 0 | append( sb, "", 0 ); |
283 | |
|
284 | 0 | append( sb, "testProperties", 2 ); |
285 | 0 | append( sb, "Deprecated. As of version 1.1, use the properties parameter instead.", 3 ); |
286 | 0 | append( sb, "", 0 ); |
287 | 0 | append( sb, "Common set of test properties to pass in on each IT\'s command line, via -D parameters.", 3 ); |
288 | 0 | append( sb, "", 0 ); |
289 | |
|
290 | 0 | append( sb, "testPropertiesFile (Default: test.properties)", 2 ); |
291 | 0 | append( sb, "Location of a properties file that defines CLI properties for the test.", 3 ); |
292 | 0 | append( sb, "", 0 ); |
293 | |
} |
294 | |
} |
295 | |
|
296 | 0 | if ( goal == null || goal.length() <= 0 || "report".equals( goal ) ) |
297 | |
{ |
298 | 0 | append( sb, "invoker:report", 0 ); |
299 | 0 | append( sb, "Generate a report based on the results of the Maven invocations. Note: This mojo doesn\'t fork any lifecycle, if you have a clean working copy, you have to use a command like mvn clean integration-test site to ensure the build results are present when this goal is invoked.", 1 ); |
300 | 0 | append( sb, "", 0 ); |
301 | 0 | if ( detail ) |
302 | |
{ |
303 | 0 | append( sb, "Available parameters:", 1 ); |
304 | 0 | append( sb, "", 0 ); |
305 | |
|
306 | 0 | append( sb, "outputDirectory (Default: ${project.reporting.outputDirectory})", 2 ); |
307 | 0 | append( sb, "The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from the command line. If the goal is run indirectly as part of a site generation, the output directory configured in the Maven Site Plugin is used instead.", 3 ); |
308 | 0 | append( sb, "", 0 ); |
309 | |
|
310 | 0 | append( sb, "reportsDirectory (Default: ${project.build.directory}/invoker-reports)", 2 ); |
311 | 0 | append( sb, "Base directory where all build reports have been written to.", 3 ); |
312 | 0 | append( sb, "", 0 ); |
313 | |
} |
314 | |
} |
315 | |
|
316 | 0 | if ( goal == null || goal.length() <= 0 || "run".equals( goal ) ) |
317 | |
{ |
318 | 0 | append( sb, "invoker:run", 0 ); |
319 | 0 | append( sb, "Searches for integration test Maven projects, and executes each, collecting a log in the project directory, and outputting the results to the command line.", 1 ); |
320 | 0 | append( sb, "", 0 ); |
321 | 0 | if ( detail ) |
322 | |
{ |
323 | 0 | append( sb, "Available parameters:", 1 ); |
324 | 0 | append( sb, "", 0 ); |
325 | |
|
326 | 0 | append( sb, "addTestClassPath (Default: false)", 2 ); |
327 | 0 | append( sb, "A flag whether the test class path of the project under test should be included in the class path of the pre-/post-build scripts. If set to false, the class path of script interpreter consists only of the runtime dependencies of the Maven Invoker Plugin. If set the true, the project\'s test class path will be prepended to the interpreter class path. Among others, this feature allows the scripts to access utility classes from the test sources of your project.", 3 ); |
328 | 0 | append( sb, "", 0 ); |
329 | |
|
330 | 0 | append( sb, "cloneAllFiles (Default: false)", 2 ); |
331 | 0 | append( sb, "Some files are normally excluded when copying the IT projects from the directory specified by the parameter projectsDirectory to the directory given by cloneProjectsTo (e.g. .svn, CVS, *~, etc). Setting this parameter to true will cause all files to be copied to the cloneProjectsTo directory.", 3 ); |
332 | 0 | append( sb, "", 0 ); |
333 | |
|
334 | 0 | append( sb, "cloneProjectsTo", 2 ); |
335 | 0 | append( sb, "Directory to which projects should be cloned prior to execution. If not specified, each integration test will be run in the directory in which the corresponding IT POM was found. In this case, you most likely want to configure your SCM to ignore target and build.log in the test\'s base directory.", 3 ); |
336 | 0 | append( sb, "", 0 ); |
337 | |
|
338 | 0 | append( sb, "debug (Default: false)", 2 ); |
339 | 0 | append( sb, "Whether to show debug statements in the build output.", 3 ); |
340 | 0 | append( sb, "", 0 ); |
341 | |
|
342 | 0 | append( sb, "disableReports (Default: false)", 2 ); |
343 | 0 | append( sb, "A flag to disable the generation of build reports.", 3 ); |
344 | 0 | append( sb, "", 0 ); |
345 | |
|
346 | 0 | append( sb, "encoding (Default: ${project.build.sourceEncoding})", 2 ); |
347 | 0 | append( sb, "The file encoding for the pre-/post-build scripts and the list files for goals and profiles.", 3 ); |
348 | 0 | append( sb, "", 0 ); |
349 | |
|
350 | 0 | append( sb, "filterProperties", 2 ); |
351 | 0 | append( sb, "A list of additional properties which will be used to filter tokens in POMs and goal files.", 3 ); |
352 | 0 | append( sb, "", 0 ); |
353 | |
|
354 | 0 | append( sb, "goals", 2 ); |
355 | 0 | append( sb, "The list of goals to execute on each project. Default value is: package.", 3 ); |
356 | 0 | append( sb, "", 0 ); |
357 | |
|
358 | 0 | append( sb, "goalsFile (Default: goals.txt)", 2 ); |
359 | 0 | append( sb, "Deprecated. As of version 1.2, the key invoker.goals from the properties file specified by the parameter invokerPropertiesFile should be used instead.", 3 ); |
360 | 0 | append( sb, "", 0 ); |
361 | 0 | append( sb, "The name of the project-specific file that contains the enumeration of goals to execute for that test.", 3 ); |
362 | 0 | append( sb, "", 0 ); |
363 | |
|
364 | 0 | append( sb, "ignoreFailures (Default: false)", 2 ); |
365 | 0 | append( sb, "A flag controlling whether failures of the sub builds should fail the main build, too. If set to true, the main build will proceed even if one or more sub builds failed.", 3 ); |
366 | 0 | append( sb, "", 0 ); |
367 | |
|
368 | 0 | append( sb, "interpolationsProperties", 2 ); |
369 | 0 | append( sb, "Deprecated. As of version 1.3, the parameter filterProperties should be used instead.", 3 ); |
370 | 0 | append( sb, "", 0 ); |
371 | 0 | append( sb, "List of properties which will be used to interpolate goal files.", 3 ); |
372 | 0 | append( sb, "", 0 ); |
373 | |
|
374 | 0 | append( sb, "invokerPropertiesFile (Default: invoker.properties)", 2 ); |
375 | 0 | append( sb, "The name of an optional project-specific file that contains properties used to specify settings for an individual Maven invocation. Any property present in the file will override the corresponding setting from the plugin configuration. The values of the properties are filtered and may use expressions like ${project.version} to reference project properties or values from the parameter filterProperties. The snippet below describes the supported properties:\n#\u00a0A\u00a0comma\u00a0or\u00a0space\u00a0separated\u00a0list\u00a0of\u00a0goals/phases\u00a0to\u00a0execute,\u00a0may\n#\u00a0specify\u00a0an\u00a0empty\u00a0list\u00a0to\u00a0execute\u00a0the\u00a0default\u00a0goal\u00a0of\u00a0the\u00a0IT\u00a0project\ninvoker.goals\u00a0=\u00a0clean\u00a0install\n\n#\u00a0Optionally,\u00a0a\u00a0list\u00a0of\u00a0goals\u00a0to\u00a0run\u00a0during\u00a0further\u00a0invocations\u00a0of\u00a0Maven\ninvoker.goals.2\u00a0=\u00a0${project.groupId}:${project.artifactId}:${project.version}:run\n\n#\u00a0A\u00a0comma\u00a0or\u00a0space\u00a0separated\u00a0list\u00a0of\u00a0profiles\u00a0to\u00a0activate\ninvoker.profiles\u00a0=\u00a0its,jdk15\n\n#\u00a0The\u00a0path\u00a0to\u00a0an\u00a0alternative\u00a0POM\u00a0or\u00a0base\u00a0directory\u00a0to\u00a0invoke\u00a0Maven\u00a0on,\u00a0defaults\u00a0to\u00a0the\n#\u00a0project\u00a0that\u00a0was\u00a0originally\u00a0specified\u00a0in\u00a0the\u00a0plugin\u00a0configuration\n#\u00a0Since\u00a0plugin\u00a0version\u00a01.4\ninvoker.project\u00a0=\u00a0sub-module\n\n#\u00a0The\u00a0value\u00a0for\u00a0the\u00a0environment\u00a0variable\u00a0MAVEN_OPTS\ninvoker.mavenOpts\u00a0=\u00a0-Dfile.encoding=UTF-16\u00a0-Xms32m\u00a0-Xmx256m\n\n#\u00a0Possible\u00a0values\u00a0are\u00a0\'fail-fast\'\u00a0(default),\u00a0\'fail-at-end\'\u00a0and\u00a0\'fail-never\'\ninvoker.failureBehavior\u00a0=\u00a0fail-never\n\n#\u00a0The\u00a0expected\u00a0result\u00a0of\u00a0the\u00a0build,\u00a0possible\u00a0values\u00a0are\u00a0\'success\'\u00a0(default)\u00a0and\u00a0\'failure\'\ninvoker.buildResult\u00a0=\u00a0failure\n\n#\u00a0A\u00a0boolean\u00a0value\u00a0controlling\u00a0the\u00a0aggregator\u00a0mode\u00a0of\u00a0Maven,\u00a0defaults\u00a0to\u00a0\'false\'\ninvoker.nonRecursive\u00a0=\u00a0true\n\n#\u00a0A\u00a0boolean\u00a0value\u00a0controlling\u00a0the\u00a0network\u00a0behavior\u00a0of\u00a0Maven,\u00a0defaults\u00a0to\u00a0\'false\'\n#\u00a0Since\u00a0plugin\u00a0version\u00a01.4\ninvoker.offline\u00a0=\u00a0true\n\n#\u00a0The\u00a0path\u00a0to\u00a0the\u00a0properties\u00a0file\u00a0from\u00a0which\u00a0to\u00a0load\u00a0system\u00a0properties,\u00a0defaults\u00a0to\u00a0the\n#\u00a0filename\u00a0given\u00a0by\u00a0the\u00a0plugin\u00a0parameter\u00a0testPropertiesFile\n#\u00a0Since\u00a0plugin\u00a0version\u00a01.4\ninvoker.systemPropertiesFile\u00a0=\u00a0test.properties\n\n#\u00a0An\u00a0optional\u00a0human\u00a0friendly\u00a0name\u00a0for\u00a0this\u00a0build\u00a0job\u00a0to\u00a0be\u00a0included\u00a0in\u00a0the\u00a0build\u00a0reports.\n#\u00a0Since\u00a0plugin\u00a0version\u00a01.4\ninvoker.name\u00a0=\u00a0Test\u00a0Build\u00a001\n\n#\u00a0An\u00a0optional\u00a0description\u00a0for\u00a0this\u00a0build\u00a0job\u00a0to\u00a0be\u00a0included\u00a0in\u00a0the\u00a0build\u00a0reports.\n#\u00a0Since\u00a0plugin\u00a0version\u00a01.4\ninvoker.description\u00a0=\u00a0Checks\u00a0the\u00a0support\u00a0for\u00a0build\u00a0reports.\n\n#\u00a0A\u00a0comma\u00a0separated\u00a0list\u00a0of\u00a0JRE\u00a0versions\u00a0on\u00a0which\u00a0this\u00a0build\u00a0job\u00a0should\u00a0be\u00a0run.\n#\u00a0Since\u00a0plugin\u00a0version\u00a01.4\ninvoker.java.version\u00a0=\u00a01.4+,\u00a0!1.4.1,\u00a01.7-\n\n#\u00a0A\u00a0comma\u00a0separated\u00a0list\u00a0of\u00a0OS\u00a0families\u00a0on\u00a0which\u00a0this\u00a0build\u00a0job\u00a0should\u00a0be\u00a0run.\n#\u00a0Since\u00a0plugin\u00a0version\u00a01.4\ninvoker.os.family\u00a0=\u00a0!windows,\u00a0unix,\u00a0mac\n\n#\u00a0A\u00a0comma\u00a0separated\u00a0list\u00a0of\u00a0Maven\u00a0versions\u00a0on\u00a0which\u00a0this\u00a0build\u00a0should\u00a0be\u00a0run.\n#\u00a0Since\u00a0plugin\u00a0version\u00a01.5\ninvoker.maven.version\u00a0=\u00a02.0.10+,\u00a0!2.1.0,\u00a0!2.2.0\n", 3 ); |
376 | 0 | append( sb, "", 0 ); |
377 | |
|
378 | 0 | append( sb, "invokerTest", 2 ); |
379 | 0 | append( sb, "A comma separated list of project names to run. Specify this parameter to run individual tests by file name, overriding the setupIncludes, pomIncludes and pomExcludes parameters. Each pattern you specify here will be used to create an include pattern formatted like ${projectsDirectory}/pattern, so you can just type -Dinvoker.test=FirstTest,SecondTest to run builds in ${projectsDirectory}/FirstTest and ${projectsDirectory}/SecondTest.", 3 ); |
380 | 0 | append( sb, "", 0 ); |
381 | |
|
382 | 0 | append( sb, "javaHome", 2 ); |
383 | 0 | append( sb, "The JAVA_HOME environment variable to use for forked Maven invocations. Defaults to the current Java home directory.", 3 ); |
384 | 0 | append( sb, "", 0 ); |
385 | |
|
386 | 0 | append( sb, "localRepositoryPath (Default: ${settings.localRepository})", 2 ); |
387 | 0 | append( sb, "The local repository for caching artifacts. It is strongly recommended to specify a path to an isolated repository like ${project.build.directory}/it-repo. Otherwise, your ordinary local repository will be used, potentially soiling it with broken artifacts.", 3 ); |
388 | 0 | append( sb, "", 0 ); |
389 | |
|
390 | 0 | append( sb, "mavenHome", 2 ); |
391 | 0 | append( sb, "The home directory of the Maven installation to use for the forked builds. Defaults to the current Maven installation.", 3 ); |
392 | 0 | append( sb, "", 0 ); |
393 | |
|
394 | 0 | append( sb, "mavenOpts", 2 ); |
395 | 0 | append( sb, "The MAVEN_OPTS environment variable to use when invoking Maven. This value can be overridden for individual integration tests by using invokerPropertiesFile.", 3 ); |
396 | 0 | append( sb, "", 0 ); |
397 | |
|
398 | 0 | append( sb, "noLog (Default: false)", 2 ); |
399 | 0 | append( sb, "Suppress logging to the build.log file.", 3 ); |
400 | 0 | append( sb, "", 0 ); |
401 | |
|
402 | 0 | append( sb, "pom", 2 ); |
403 | 0 | append( sb, "A single POM to build, skipping any scanning parameters and behavior.", 3 ); |
404 | 0 | append( sb, "", 0 ); |
405 | |
|
406 | 0 | append( sb, "pomExcludes", 2 ); |
407 | 0 | append( sb, "Exclude patterns for searching the integration test directory. This parameter is meant to be set from the POM. By default, no POM files are excluded. For the convenience of using an include pattern like *, the custom settings file specified by the parameter settingsFile will always be excluded automatically.", 3 ); |
408 | 0 | append( sb, "", 0 ); |
409 | |
|
410 | 0 | append( sb, "pomIncludes", 2 ); |
411 | 0 | append( sb, "Include patterns for searching the integration test directory for projects. This parameter is meant to be set from the POM. If this parameter is not set, the plugin will search for all pom.xml files one directory below projectsDirectory (i.e. */pom.xml).\n\nStarting with version 1.3, mere directories can also be matched by these patterns. For example, the include pattern * will run Maven builds on all immediate sub directories of projectsDirectory, regardless if they contain a pom.xml. This allows to perform builds that need/should not depend on the existence of a POM.", 3 ); |
412 | 0 | append( sb, "", 0 ); |
413 | |
|
414 | 0 | append( sb, "postBuildHookScript (Default: postbuild)", 2 ); |
415 | 0 | append( sb, "Relative path of a cleanup/verification hook script to run after executing the build. This script may be written with either BeanShell or Groovy (since 1.3). If the file extension is omitted (e.g. verify), the plugin searches for the file by trying out the well-known extensions .bsh and .groovy. If this script exists for a particular project but returns any non-null value different from true or throws an exception, the corresponding build is flagged as a failure.", 3 ); |
416 | 0 | append( sb, "", 0 ); |
417 | |
|
418 | 0 | append( sb, "preBuildHookScript (Default: prebuild)", 2 ); |
419 | 0 | append( sb, "Relative path of a pre-build hook script to run prior to executing the build. This script may be written with either BeanShell or Groovy (since 1.3). If the file extension is omitted (e.g. prebuild), the plugin searches for the file by trying out the well-known extensions .bsh and .groovy. If this script exists for a particular project but returns any non-null value different from true or throws an exception, the corresponding build is flagged as a failure. In this case, neither Maven nor the post-build hook script will be invoked.", 3 ); |
420 | 0 | append( sb, "", 0 ); |
421 | |
|
422 | 0 | append( sb, "profiles", 2 ); |
423 | 0 | append( sb, "List of profile identifiers to explicitly trigger in the build.", 3 ); |
424 | 0 | append( sb, "", 0 ); |
425 | |
|
426 | 0 | append( sb, "profilesFile (Default: profiles.txt)", 2 ); |
427 | 0 | append( sb, "Deprecated. As of version 1.2, the key invoker.profiles from the properties file specified by the parameter invokerPropertiesFile should be used instead.", 3 ); |
428 | 0 | append( sb, "", 0 ); |
429 | 0 | append( sb, "The name of the project-specific file that contains the enumeration of profiles to use for that test. If the file exists and is empty no profiles will be used even if the parameter profiles is set.", 3 ); |
430 | 0 | append( sb, "", 0 ); |
431 | |
|
432 | 0 | append( sb, "projectsDirectory (Default: ${basedir}/src/it/)", 2 ); |
433 | 0 | append( sb, "Directory to search for integration tests.", 3 ); |
434 | 0 | append( sb, "", 0 ); |
435 | |
|
436 | 0 | append( sb, "properties", 2 ); |
437 | 0 | append( sb, "Common set of properties to pass in on each project\'s command line, via -D parameters.", 3 ); |
438 | 0 | append( sb, "", 0 ); |
439 | |
|
440 | 0 | append( sb, "reportsDirectory (Default: ${project.build.directory}/invoker-reports)", 2 ); |
441 | 0 | append( sb, "Base directory where all build reports are written to.", 3 ); |
442 | 0 | append( sb, "", 0 ); |
443 | |
|
444 | 0 | append( sb, "selectorScript (Default: selector)", 2 ); |
445 | 0 | append( sb, "Relative path of a selector script to run prior in order to decide if the build should be executed. This script may be written with either BeanShell or Groovy. If the file extension is omitted (e.g. selector), the plugin searches for the file by trying out the well-known extensions .bsh and .groovy. If this script exists for a particular project but returns any non-null value different from true, the corresponding build is flagged as skipped. In this case, none of the pre-build hook script, Maven nor the post-build hook script will be invoked. If this script throws an exception, the corresponding build is flagged as in error, and none of the pre-build hook script, Maven not the post-build hook script will be invoked.", 3 ); |
446 | 0 | append( sb, "", 0 ); |
447 | |
|
448 | 0 | append( sb, "settingsFile", 2 ); |
449 | 0 | append( sb, "Path to an alternate settings.xml to use for Maven invocation with all ITs. Note that the <localRepository> element of this settings file is always ignored, i.e. the path given by the parameter localRepositoryPath is dominant.", 3 ); |
450 | 0 | append( sb, "", 0 ); |
451 | |
|
452 | 0 | append( sb, "setupIncludes", 2 ); |
453 | 0 | append( sb, "Include patterns for searching the projects directory for projects that need to be run before the other projects. This parameter allows to declare projects that perform setup tasks like installing utility artifacts into the local repository. Projects matched by these patterns are implicitly excluded from the scan for ordinary projects. Also, the exclusions defined by the parameter pomExcludes apply to the setup projects, too. Default value is: setup*/pom.xml.", 3 ); |
454 | 0 | append( sb, "", 0 ); |
455 | |
|
456 | 0 | append( sb, "showErrors (Default: false)", 2 ); |
457 | 0 | append( sb, "Whether to show errors in the build output.", 3 ); |
458 | 0 | append( sb, "", 0 ); |
459 | |
|
460 | 0 | append( sb, "showVersion (Default: false)", 2 ); |
461 | 0 | append( sb, "flag to enable show mvn version used for running its (cli option : -V,--show-version )", 3 ); |
462 | 0 | append( sb, "", 0 ); |
463 | |
|
464 | 0 | append( sb, "skipInvocation (Default: false)", 2 ); |
465 | 0 | append( sb, "Flag used to suppress certain invocations. This is useful in tailoring the build using profiles.", 3 ); |
466 | 0 | append( sb, "", 0 ); |
467 | |
|
468 | 0 | append( sb, "streamLogs (Default: false)", 2 ); |
469 | 0 | append( sb, "Flag used to determine whether the build logs should be output to the normal mojo log.", 3 ); |
470 | 0 | append( sb, "", 0 ); |
471 | |
|
472 | 0 | append( sb, "suppressSummaries (Default: false)", 2 ); |
473 | 0 | append( sb, "Flag used to suppress the summary output notifying of successes and failures. If set to true, the only indication of the build\'s success or failure will be the effect it has on the main build (if it fails, the main build should fail as well). If streamLogs is enabled, the sub-build summary will also provide an indication.", 3 ); |
474 | 0 | append( sb, "", 0 ); |
475 | |
|
476 | 0 | append( sb, "testProperties", 2 ); |
477 | 0 | append( sb, "Deprecated. As of version 1.1, use the properties parameter instead.", 3 ); |
478 | 0 | append( sb, "", 0 ); |
479 | 0 | append( sb, "Common set of test properties to pass in on each IT\'s command line, via -D parameters.", 3 ); |
480 | 0 | append( sb, "", 0 ); |
481 | |
|
482 | 0 | append( sb, "testPropertiesFile (Default: test.properties)", 2 ); |
483 | 0 | append( sb, "Location of a properties file that defines CLI properties for the test.", 3 ); |
484 | 0 | append( sb, "", 0 ); |
485 | |
} |
486 | |
} |
487 | |
|
488 | 0 | if ( goal == null || goal.length() <= 0 || "verify".equals( goal ) ) |
489 | |
{ |
490 | 0 | append( sb, "invoker:verify", 0 ); |
491 | 0 | append( sb, "Checks the results of maven-invoker-plugin based integration tests and fails the build if any tests failed.", 1 ); |
492 | 0 | append( sb, "", 0 ); |
493 | 0 | if ( detail ) |
494 | |
{ |
495 | 0 | append( sb, "Available parameters:", 1 ); |
496 | 0 | append( sb, "", 0 ); |
497 | |
|
498 | 0 | append( sb, "ignoreFailures (Default: false)", 2 ); |
499 | 0 | append( sb, "A flag controlling whether failures of the sub builds should fail the main build, too. If set to true, the main build will proceed even if one or more sub builds failed.", 3 ); |
500 | 0 | append( sb, "", 0 ); |
501 | |
|
502 | 0 | append( sb, "reportsDirectory (Default: ${project.build.directory}/invoker-reports)", 2 ); |
503 | 0 | append( sb, "Base directory where all build reports are read from.", 3 ); |
504 | 0 | append( sb, "", 0 ); |
505 | |
|
506 | 0 | append( sb, "skipInvocation (Default: false)", 2 ); |
507 | 0 | append( sb, "Flag used to suppress certain invocations. This is useful in tailoring the build using profiles.", 3 ); |
508 | 0 | append( sb, "", 0 ); |
509 | |
|
510 | 0 | append( sb, "suppressSummaries (Default: false)", 2 ); |
511 | 0 | append( sb, "Flag used to suppress the summary output notifying of successes and failures. If set to true, the only indication of the build\'s success or failure will be the effect it has on the main build (if it fails, the main build should fail as well).", 3 ); |
512 | 0 | append( sb, "", 0 ); |
513 | |
} |
514 | |
} |
515 | |
|
516 | 0 | if ( getLog().isInfoEnabled() ) |
517 | |
{ |
518 | 0 | getLog().info( sb.toString() ); |
519 | |
} |
520 | 0 | } |
521 | |
|
522 | |
|
523 | |
|
524 | |
|
525 | |
|
526 | |
|
527 | |
|
528 | |
|
529 | |
|
530 | |
|
531 | |
private static String repeat( String str, int repeat ) |
532 | |
{ |
533 | 0 | StringBuffer buffer = new StringBuffer( repeat * str.length() ); |
534 | |
|
535 | 0 | for ( int i = 0; i < repeat; i++ ) |
536 | |
{ |
537 | 0 | buffer.append( str ); |
538 | |
} |
539 | |
|
540 | 0 | return buffer.toString(); |
541 | |
} |
542 | |
|
543 | |
|
544 | |
|
545 | |
|
546 | |
|
547 | |
|
548 | |
|
549 | |
|
550 | |
|
551 | |
private void append( StringBuffer sb, String description, int indent ) |
552 | |
{ |
553 | 0 | for ( Iterator it = toLines( description, indent, indentSize, lineLength ).iterator(); it.hasNext(); ) |
554 | |
{ |
555 | 0 | sb.append( it.next().toString() ).append( '\n' ); |
556 | |
} |
557 | 0 | } |
558 | |
|
559 | |
|
560 | |
|
561 | |
|
562 | |
|
563 | |
|
564 | |
|
565 | |
|
566 | |
|
567 | |
|
568 | |
|
569 | |
private static List toLines( String text, int indent, int indentSize, int lineLength ) |
570 | |
{ |
571 | 0 | List lines = new ArrayList(); |
572 | |
|
573 | 0 | String ind = repeat( "\t", indent ); |
574 | 0 | String[] plainLines = text.split( "(\r\n)|(\r)|(\n)" ); |
575 | 0 | for ( int i = 0; i < plainLines.length; i++ ) |
576 | |
{ |
577 | 0 | toLines( lines, ind + plainLines[i], indentSize, lineLength ); |
578 | |
} |
579 | |
|
580 | 0 | return lines; |
581 | |
} |
582 | |
|
583 | |
|
584 | |
|
585 | |
|
586 | |
|
587 | |
|
588 | |
|
589 | |
|
590 | |
|
591 | |
private static void toLines( List lines, String line, int indentSize, int lineLength ) |
592 | |
{ |
593 | 0 | int lineIndent = getIndentLevel( line ); |
594 | 0 | StringBuffer buf = new StringBuffer( 256 ); |
595 | 0 | String[] tokens = line.split( " +" ); |
596 | 0 | for ( int i = 0; i < tokens.length; i++ ) |
597 | |
{ |
598 | 0 | String token = tokens[i]; |
599 | 0 | if ( i > 0 ) |
600 | |
{ |
601 | 0 | if ( buf.length() + token.length() >= lineLength ) |
602 | |
{ |
603 | 0 | lines.add( buf.toString() ); |
604 | 0 | buf.setLength( 0 ); |
605 | 0 | buf.append( repeat( " ", lineIndent * indentSize ) ); |
606 | |
} |
607 | |
else |
608 | |
{ |
609 | 0 | buf.append( ' ' ); |
610 | |
} |
611 | |
} |
612 | 0 | for ( int j = 0; j < token.length(); j++ ) |
613 | |
{ |
614 | 0 | char c = token.charAt( j ); |
615 | 0 | if ( c == '\t' ) |
616 | |
{ |
617 | 0 | buf.append( repeat( " ", indentSize - buf.length() % indentSize ) ); |
618 | |
} |
619 | 0 | else if ( c == '\u00A0' ) |
620 | |
{ |
621 | 0 | buf.append( ' ' ); |
622 | |
} |
623 | |
else |
624 | |
{ |
625 | 0 | buf.append( c ); |
626 | |
} |
627 | |
} |
628 | |
} |
629 | 0 | lines.add( buf.toString() ); |
630 | 0 | } |
631 | |
|
632 | |
|
633 | |
|
634 | |
|
635 | |
|
636 | |
|
637 | |
|
638 | |
private static int getIndentLevel( String line ) |
639 | |
{ |
640 | 0 | int level = 0; |
641 | 0 | for ( int i = 0; i < line.length() && line.charAt( i ) == '\t'; i++ ) |
642 | |
{ |
643 | 0 | level++; |
644 | |
} |
645 | 0 | for ( int i = level + 1; i <= level + 4 && i < line.length(); i++ ) |
646 | |
{ |
647 | 0 | if ( line.charAt( i ) == '\t' ) |
648 | |
{ |
649 | 0 | level++; |
650 | 0 | break; |
651 | |
} |
652 | |
} |
653 | 0 | return level; |
654 | |
} |
655 | |
} |