Codebase list maven-invoker / 427c988
New upstream version 3.1.0 Emmanuel Bourg 1 year, 4 months ago
30 changed file(s) with 1271 addition(s) and 886 deletion(s). Raw diff Collapse all Expand all
0 #
1 # Licensed to the Apache Software Foundation (ASF) under one or more
2 # contributor license agreements. See the NOTICE file distributed with
3 # this work for additional information regarding copyright ownership.
4 # The ASF licenses this file to You under the Apache License, Version 2.0
5 # (the "License"); you may not use this file except in compliance with
6 # the License. You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 # see https://s.apache.org/asfyaml
17 github:
18 description: "Apache Maven Invoker"
19 homepage: https://maven.apache.org/shared/maven-invoker/
20 labels:
21 - java
22 - build-management
23 - maven-shared
24 - maven
0 target/
1 .project
2 .classpath
3 .settings/
4 .svn/
5 bin/
6 # Intellij
7 *.ipr
8 *.iml
9 .idea
10 out/
11 .DS_Store
12 /bootstrap
13 /dependencies.xml
14 .java-version
0 /**
1 * Licensed to the Apache Software Foundation (ASF) under one
2 * or more contributor license agreements. See the NOTICE file
3 * distributed with this work for additional information
4 * regarding copyright ownership. The ASF licenses this file
5 * to you under the Apache License, Version 2.0 (the
6 * "License"); you may not use this file except in compliance
7 * with the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
16 * under the License.
17 */
18
19 asfMavenTlpStdBuild()
0 <!---
1 Licensed to the Apache Software Foundation (ASF) under one or more
2 contributor license agreements. See the NOTICE file distributed with
3 this work for additional information regarding copyright ownership.
4 The ASF licenses this file to You under the Apache License, Version 2.0
5 (the "License"); you may not use this file except in compliance with
6 the License. You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 -->
16 Contributing to [Apache Maven Invoker](https://maven.apache.org/shared/maven-invoker/)
17 ======================
18
19 [![ASF Jira](https://img.shields.io/endpoint?url=https%3A%2F%2Fmaven.apache.org%2Fbadges%2Fasf_jira-MSHARED.json)][jira]
20 [![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/apache/maven.svg?label=License)][license]
21 [![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven.shared/maven-invoker.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.apache.maven.shared/maven-invoker)
22 [![Jenkins Status](https://img.shields.io/jenkins/s/https/ci-builds.apache.org/job/Maven/job/maven-box/job/maven-invoker/job/master.svg)][build]
23 [![Jenkins tests](https://img.shields.io/jenkins/t/https/ci-builds.apache.org/job/Maven/job/maven-box/job/maven-invoker/job/master.svg)][test-results]
24
25
26 You have found a bug or you have an idea for a cool new feature? Contributing
27 code is a great way to give something back to the open source community. Before
28 you dig right into the code, there are a few guidelines that we need
29 contributors to follow so that we can have a chance of keeping on top of
30 things.
31
32 Getting Started
33 ---------------
34
35 + Make sure you have a [JIRA account](https://issues.apache.org/jira/).
36 + Make sure you have a [GitHub account](https://github.com/signup/free).
37 + If you're planning to implement a new feature, it makes sense to discuss your changes
38 on the [dev list][ml-list] first.
39 This way you can make sure you're not wasting your time on something that isn't
40 considered to be in Apache Maven's scope.
41 + Submit a ticket for your issue, assuming one does not already exist.
42 + Clearly describe the issue, including steps to reproduce when it is a bug.
43 + Make sure you fill in the earliest version that you know has the issue.
44 + Fork the repository on GitHub.
45
46 Making and Submitting Changes
47 --------------
48
49 We accept Pull Requests via GitHub. The [developer mailing list][ml-list] is the
50 main channel of communication for contributors.
51 There are some guidelines which will make applying PRs easier for us:
52 + Create a topic branch from where you want to base your work (this is usually the master branch).
53 Push your changes to a topic branch in your fork of the repository.
54 + Make commits of logical units.
55 + Respect the original code style: by using the same [codestyle][code-style],
56 patches should only highlight the actual difference, not being disturbed by any formatting issues:
57 + Only use spaces for indentation.
58 + Create minimal diffs - disable on save actions like reformat source code or organize imports.
59 If you feel the source code should be reformatted, create a separate PR for this change.
60 + Check for unnecessary whitespace with `git diff --check` before committing.
61 + Make sure your commit messages are in the proper format. Your commit message should contain the key of the JIRA issue.
62 ```
63 [MSHARED-XXX] - Subject of the JIRA Ticket
64 Optional supplemental description.
65 ```
66 + Make sure you have added the necessary tests (JUnit/IT) for your changes.
67 + Run all the tests with `mvn -Prun-its verify` to assure nothing else was accidentally broken.
68 + Submit a pull request to the repository in the Apache organization.
69 + Update your JIRA ticket and include a link to the pull request in the ticket.
70
71 If you plan to contribute on a regular basis, please consider filing a [contributor license agreement][cla].
72
73 Making Trivial Changes
74 ----------------------
75
76 For changes of a trivial nature to comments and documentation, it is not always
77 necessary to create a new ticket in JIRA. In this case, it is appropriate to
78 start the first line of a commit with '(doc)' instead of a ticket number.
79
80 Additional Resources
81 --------------------
82
83 + [Contributing patches](https://maven.apache.org/guides/development/guide-maven-development.html#Creating_and_submitting_a_patch)
84 + [Apache Maven Shared Components project page][jira]
85 + [Contributor License Agreement][cla]
86 + [General GitHub documentation](https://help.github.com/)
87 + [GitHub pull request documentation](https://help.github.com/send-pull-requests/)
88 + [Apache Maven Twitter Account](https://twitter.com/ASFMavenProject)
89 + #Maven IRC channel on freenode.org
90
91 [jira]: https://issues.apache.org/jira/projects/MSHARED/
92 [license]: https://www.apache.org/licenses/LICENSE-2.0
93 [ml-list]: https://maven.apache.org/mailing-lists.html
94 [code-style]: https://maven.apache.org/developers/conventions/code.html
95 [cla]: https://www.apache.org/licenses/#clas
96 [maven-wiki]: https://cwiki.apache.org/confluence/display/MAVEN/Index
97 [test-results]: https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven-invoker/job/master/lastCompletedBuild/testReport/
98 [build]: https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven-invoker/job/master/
2424 <parent>
2525 <groupId>org.apache.maven.shared</groupId>
2626 <artifactId>maven-shared-components</artifactId>
27 <version>30</version>
28 <relativePath>../../pom/maven/maven-shared-components/pom.xml</relativePath>
27 <version>34</version>
28 <relativePath />
2929 </parent>
3030
31
3132 <artifactId>maven-invoker</artifactId>
32 <version>3.0.0</version>
33 <version>3.1.0</version>
3334
3435 <name>Apache Maven Invoker</name>
3536 <description>A component to programmatically invoke Maven.</description>
3637
3738 <scm>
38 <connection>scm:svn:http://svn.apache.org/repos/asf/maven/shared/tags/maven-invoker-3.0.0</connection>
39 <developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/shared/tags/maven-invoker-3.0.0</developerConnection>
40 <url>http://svn.apache.org/viewvc/maven/shared/tags/maven-invoker-3.0.0</url>
39 <connection>scm:git:https://gitbox.apache.org/repos/asf/maven-invoker.git</connection>
40 <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-invoker.git</developerConnection>
41 <url>https://github.com/apache/maven-invoker/tree/${project.scm.tag}</url>
42 <tag>maven-invoker-3.1.0</tag>
4143 </scm>
4244 <issueManagement>
4345 <system>jira</system>
44 <url>https://issues.apache.org/jira/browse/MSHARED/component/12326433</url>
46 <url>https://issues.apache.org/jira/issues/?jql=project%20%3D%20MSHARED%20AND%20component%20%3D%20maven-invoker</url>
4547 </issueManagement>
48 <ciManagement>
49 <system>Jenkins</system>
50 <url>https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven-invoker/</url>
51 </ciManagement>
4652 <distributionManagement>
4753 <site>
4854 <id>apache.website</id>
49 <url>scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/components/${maven.site.path}</url>
55 <url>scm:svn:https://svn.apache.org/repos/asf/maven/website/components/${maven.site.path}</url>
5056 </site>
5157 </distributionManagement>
5258
5965 </contributor>
6066 </contributors>
6167
68 <properties>
69 <javaVersion>7</javaVersion>
70 <mavenVersion>3.1.1</mavenVersion>
71 <surefire.version>2.22.2</surefire.version>
72 <project.build.outputTimestamp>2021-02-04T15:25:02Z</project.build.outputTimestamp>
73 </properties>
74
6275 <dependencies>
6376 <dependency>
64 <groupId>org.codehaus.plexus</groupId>
65 <artifactId>plexus-utils</artifactId>
66 <version>3.0.24</version>
77 <groupId>org.apache.maven.shared</groupId>
78 <artifactId>maven-shared-utils</artifactId>
79 <version>3.3.3</version>
6780 </dependency>
6881 <dependency>
69 <!--
70 ! Can be removed if update to maven-shared-components parent to version 31
71 -->
72 <groupId>org.codehaus.plexus</groupId>
73 <artifactId>plexus-component-annotations</artifactId>
74 <version>1.7</version>
82 <groupId>javax.inject</groupId>
83 <artifactId>javax.inject</artifactId>
84 <version>1</version>
7585 </dependency>
7686 <dependency>
7787 <groupId>junit</groupId>
7888 <artifactId>junit</artifactId>
79 <version>4.11</version>
89 <version>4.13.1</version>
8090 <scope>test</scope>
8191 </dependency>
8292 </dependencies>
8393
8494 <build>
95 <pluginManagement>
96 <plugins>
97 <!-- remove with next parent upgrade -->
98 <plugin>
99 <artifactId>maven-project-info-reports-plugin</artifactId>
100 <version>3.1.1</version>
101 </plugin>
102 <plugin>
103 <artifactId>maven-enforcer-plugin</artifactId>
104 <version>3.0.0-M3</version>
105 </plugin>
106 <plugin>
107 <artifactId>maven-javadoc-plugin</artifactId>
108 <version>3.2.0</version>
109 <configuration>
110 <detectLinks>false</detectLinks>
111 <additionalJOption>--no-module-directories</additionalJOption>
112 </configuration>
113 </plugin>
114 <plugin>
115 <artifactId>maven-site-plugin</artifactId>
116 <version>3.9.1</version>
117 </plugin>
118 <plugin>
119 <groupId>org.apache.maven.plugins</groupId>
120 <artifactId>maven-assembly-plugin</artifactId>
121 <version>3.3.0</version>
122 </plugin>
123 </plugins>
124 </pluginManagement>
85125 <plugins>
86126 <plugin>
87127 <groupId>org.apache.maven.plugins</groupId>
101141 </configuration>
102142 </plugin>
103143 <plugin>
104 <groupId>org.codehaus.plexus</groupId>
105 <artifactId>plexus-component-metadata</artifactId>
106 <!--
107 ! Can be removed if update to maven-shared-components parent to version 31
108 -->
109 <version>1.7.1</version>
144 <groupId>org.eclipse.sisu</groupId>
145 <artifactId>sisu-maven-plugin</artifactId>
146 <version>0.3.4</version>
110147 <executions>
111148 <execution>
112 <id>create-component-descriptor</id>
149 <id>generate-index</id>
113150 <goals>
114 <goal>generate-metadata</goal>
151 <goal>main-index</goal>
115152 </goals>
116153 </execution>
117154 </executions>
144181 </plugins>
145182 </build>
146183 </profile>
184 <profile>
185 <id>java7tlsCentral</id>
186 <activation>
187 <property>
188 <name>https.protocols</name>
189 </property>
190 </activation>
191 <build>
192 <plugins>
193 <plugin>
194 <groupId>org.apache.maven.plugins</groupId>
195 <artifactId>maven-surefire-plugin</artifactId>
196 <configuration>
197 <systemProperties combine.children="append">
198 <property>
199 <name>https.protocols</name>
200 <value>${https.protocols}</value>
201 </property>
202 </systemProperties>
203 </configuration>
204 </plugin>
205 </plugins>
206 </build>
207 </profile>
208
147209 </profiles>
148210 </project>
2020
2121 /**
2222 * Signals an error during the construction of the command line used to invoke Maven.
23 *
24 * @version $Id: CommandLineConfigurationException.java 662043 2008-05-31 16:27:02Z bentmann $
23 *
2524 */
2625 public class CommandLineConfigurationException
2726 extends Exception
3130
3231 /**
3332 * Creates a new exception using the specified detail message and cause.
34 *
33 *
3534 * @param message The detail message for this exception, may be <code>null</code>.
3635 * @param cause The nested exception, may be <code>null</code>.
3736 */
4241
4342 /**
4443 * Creates a new exception using the specified detail message.
45 *
44 *
4645 * @param message The detail message for this exception, may be <code>null</code>.
4746 */
4847 public CommandLineConfigurationException( String message )
2828
2929 /**
3030 * Specifies the parameters used to control a Maven invocation.
31 *
32 * @version $Id: DefaultInvocationRequest.java 1752078 2016-07-10 11:25:08Z khmarbaise $
31 *
3332 */
3433 public class DefaultInvocationRequest
3534 implements InvocationRequest
103102
104103 private String builderId;
105104
105 private int timeoutInSeconds = NO_TIMEOUT;
106
107 private boolean quiet;
108
109 /**
110 * <p>getBaseDirectory.</p>
111 *
112 * @return a {@link java.io.File} object.
113 */
106114 public File getBaseDirectory()
107115 {
108116 return basedir;
109117 }
110118
119 /** {@inheritDoc} */
111120 public File getBaseDirectory( File defaultDirectory )
112121 {
113122 return basedir == null ? defaultDirectory : basedir;
114123 }
115124
125 /** {@inheritDoc} */
116126 public InvocationOutputHandler getErrorHandler( InvocationOutputHandler defaultHandler )
117127 {
118128 return errorHandler == null ? defaultHandler : errorHandler;
119129 }
120130
131 /**
132 * <p>getReactorFailureBehavior.</p>
133 *
134 * @return a ReactorFailureBehavior object.
135 */
121136 public ReactorFailureBehavior getReactorFailureBehavior()
122137 {
123138 return failureBehavior;
124139 }
125140
141 /**
142 * <p>Getter for the field <code>goals</code>.</p>
143 *
144 * @return a {@link java.util.List} object.
145 */
126146 public List<String> getGoals()
127147 {
128148 return goals;
129149 }
130150
151 /** {@inheritDoc} */
131152 public InputStream getInputStream( InputStream defaultStream )
132153 {
133154 return inputStream == null ? defaultStream : inputStream;
134155 }
135156
157 /** {@inheritDoc} */
136158 public File getLocalRepositoryDirectory( File defaultDirectory )
137159 {
138160 return localRepository == null ? defaultDirectory : localRepository;
139161 }
140162
163 /** {@inheritDoc} */
141164 public InvocationOutputHandler getOutputHandler( InvocationOutputHandler defaultHandler )
142165 {
143166 return outputHandler == null ? defaultHandler : outputHandler;
144167 }
145168
169 /**
170 * <p>Getter for the field <code>pomFile</code>.</p>
171 *
172 * @return a {@link java.io.File} object.
173 */
146174 public File getPomFile()
147175 {
148176 return pomFile;
149177 }
150178
179 /**
180 * <p>Getter for the field <code>properties</code>.</p>
181 *
182 * @return a {@link java.util.Properties} object.
183 */
151184 public Properties getProperties()
152185 {
153186 return properties;
154187 }
155188
189 /**
190 * <p>isDebug.</p>
191 *
192 * @return a boolean.
193 */
156194 public boolean isDebug()
157195 {
158196 return debug;
159197 }
160198
199 /**
200 * <p>isBatchMode.</p>
201 *
202 * @return a boolean.
203 */
161204 public boolean isBatchMode()
162205 {
163206 return interactive;
164207 }
165208
209 /**
210 * <p>isOffline.</p>
211 *
212 * @return a boolean.
213 */
166214 public boolean isOffline()
167215 {
168216 return offline;
169217 }
170218
219 /**
220 * <p>isShowErrors.</p>
221 *
222 * @return a boolean.
223 */
171224 public boolean isShowErrors()
172225 {
173226 return showErrors;
174227 }
175228
229 /**
230 * <p>isUpdateSnapshots.</p>
231 *
232 * @return a boolean.
233 */
176234 public boolean isUpdateSnapshots()
177235 {
178236 return updateSnapshots;
179237 }
180238
239 /**
240 * <p>isRecursive.</p>
241 *
242 * @return a boolean.
243 */
181244 public boolean isRecursive()
182245 {
183246 return recursive;
184247 }
185248
249 /** {@inheritDoc} */
186250 public InvocationRequest setRecursive( boolean recursive )
187251 {
188252 this.recursive = recursive;
189253 return this;
190254 }
191255
256 /** {@inheritDoc} */
192257 public InvocationRequest setBaseDirectory( File basedir )
193258 {
194259 this.basedir = basedir;
195260 return this;
196261 }
197262
263 /** {@inheritDoc} */
198264 public InvocationRequest setDebug( boolean debug )
199265 {
200266 this.debug = debug;
201267 return this;
202268 }
203269
270 /** {@inheritDoc} */
204271 public InvocationRequest setErrorHandler( InvocationOutputHandler errorHandler )
205272 {
206273 this.errorHandler = errorHandler;
207274 return this;
208275 }
209276
277 /**
278 * <p>setReactorFailureBehavior.</p>
279 *
280 * @param failureBehavior a ReactorFailureBehavior object.
281 * @return a {@link org.apache.maven.shared.invoker.InvocationRequest} object.
282 */
210283 public InvocationRequest setReactorFailureBehavior( ReactorFailureBehavior failureBehavior )
211284 {
212285 this.failureBehavior = failureBehavior;
213286 return this;
214287 }
215288
289 /** {@inheritDoc} */
216290 public InvocationRequest setGoals( List<String> goals )
217291 {
218292 this.goals = goals;
219293 return this;
220294 }
221295
296 /** {@inheritDoc} */
222297 public InvocationRequest setInputStream( InputStream inputStream )
223298 {
224299 this.inputStream = inputStream;
225300 return this;
226301 }
227302
303 /** {@inheritDoc} */
228304 public InvocationRequest setBatchMode( boolean interactive )
229305 {
230306 this.interactive = interactive;
231307 return this;
232308 }
233309
310 /** {@inheritDoc} */
234311 public InvocationRequest setLocalRepositoryDirectory( File localRepository )
235312 {
236313 this.localRepository = localRepository;
237314 return this;
238315 }
239316
317 /** {@inheritDoc} */
240318 public InvocationRequest setOffline( boolean offline )
241319 {
242320 this.offline = offline;
243321 return this;
244322 }
245323
324 /** {@inheritDoc} */
246325 public InvocationRequest setOutputHandler( InvocationOutputHandler outputHandler )
247326 {
248327 this.outputHandler = outputHandler;
249328 return this;
250329 }
251330
331 /** {@inheritDoc} */
252332 public InvocationRequest setPomFile( File pomFile )
253333 {
254334 this.pomFile = pomFile;
255335 return this;
256336 }
257337
338 /** {@inheritDoc} */
258339 public InvocationRequest setProperties( Properties properties )
259340 {
260341 this.properties = properties;
261342 return this;
262343 }
263344
345 /** {@inheritDoc} */
264346 public InvocationRequest setShowErrors( boolean showErrors )
265347 {
266348 this.showErrors = showErrors;
267349 return this;
268350 }
269351
352 /** {@inheritDoc} */
270353 public InvocationRequest setUpdateSnapshots( boolean updateSnapshots )
271354 {
272355 this.updateSnapshots = updateSnapshots;
274357 }
275358
276359 /**
277 * @see MavenCommandLineBuilder#setShellEnvironment(InvocationRequest, org.codehaus.plexus.util.cli.Commandline)
360 * <p>isShellEnvironmentInherited.</p>
361 *
362 * @see MavenCommandLineBuilder#setShellEnvironment(InvocationRequest, Commandline)
363 * @return a boolean.
278364 */
279365 public boolean isShellEnvironmentInherited()
280366 {
281367 return shellEnvironmentInherited;
282368 }
283369
370 /** {@inheritDoc} */
284371 public InvocationRequest setShellEnvironmentInherited( boolean shellEnvironmentInherited )
285372 {
286373 this.shellEnvironmentInherited = shellEnvironmentInherited;
287374 return this;
288375 }
289376
377 /**
378 * <p>Getter for the field <code>javaHome</code>.</p>
379 *
380 * @return a {@link java.io.File} object.
381 */
290382 public File getJavaHome()
291383 {
292384 return javaHome;
293385 }
294386
295 /**
296 * {@inheritDoc}
297 */
387 /** {@inheritDoc} */
298388 public InvocationRequest setJavaHome( File javaHome )
299389 {
300390 this.javaHome = javaHome;
303393
304394 /**
305395 * {@inheritDoc}
396 *
397 * @return a {@link java.io.File} object.
306398 */
307399 public File getUserSettingsFile()
308400 {
309401 return userSettings;
310402 }
311403
312 /**
313 * {@inheritDoc}
314 */
404 /** {@inheritDoc} */
315405 public InvocationRequest setUserSettingsFile( File userSettings )
316406 {
317407 this.userSettings = userSettings;
320410
321411 /**
322412 * {@inheritDoc}
413 *
414 * @return a {@link java.io.File} object.
323415 */
324416 public File getGlobalSettingsFile()
325417 {
326418 return globalSettings;
327419 }
328420
329 /**
330 * {@inheritDoc}
331 */
421 /** {@inheritDoc} */
332422 public InvocationRequest setGlobalSettingsFile( File globalSettings )
333423 {
334424 this.globalSettings = globalSettings;
337427
338428 /**
339429 * {@inheritDoc}
430 *
431 * @return a {@link java.io.File} object.
340432 */
341433 public File getToolchainsFile()
342434 {
343435 return toolchains;
344436 }
345437
346 /**
347 * {@inheritDoc}
348 */
438 /** {@inheritDoc} */
349439 public InvocationRequest setToolchainsFile( File toolchains )
350440 {
351441 this.toolchains = toolchains;
354444
355445 /**
356446 * {@inheritDoc}
447 *
448 * @return a {@link java.io.File} object.
357449 */
358450 public File getGlobalToolchainsFile()
359451 {
360452 return globalToolchains;
361453 }
362454
363 /**
364 * {@inheritDoc}
365 */
455 /** {@inheritDoc} */
366456 public InvocationRequest setGlobalToolchainsFile( File toolchains )
367457 {
368458 this.globalToolchains = toolchains;
372462
373463 /**
374464 * {@inheritDoc}
465 *
466 * @return a CheckSumPolicy object.
375467 */
376468 public CheckSumPolicy getGlobalChecksumPolicy()
377469 {
380472
381473 /**
382474 * {@inheritDoc}
475 *
476 * @param globalChecksumPolicy a CheckSumPolicy object.
477 * @return a {@link org.apache.maven.shared.invoker.InvocationRequest} object.
383478 */
384479 public InvocationRequest setGlobalChecksumPolicy( CheckSumPolicy globalChecksumPolicy )
385480 {
389484
390485 /**
391486 * {@inheritDoc}
487 *
488 * @return a {@link java.lang.String} object.
392489 */
393490 public String getPomFileName()
394491 {
395492 return pomFilename;
396493 }
397494
398 /**
399 * {@inheritDoc}
400 */
495 /** {@inheritDoc} */
401496 public InvocationRequest setPomFileName( String pomFilename )
402497 {
403498 this.pomFilename = pomFilename;
406501
407502 /**
408503 * {@inheritDoc}
504 *
505 * @return a {@link java.util.List} object.
409506 */
410507 public List<String> getProfiles()
411508 {
412509 return profiles;
413510 }
414511
415 /**
416 * {@inheritDoc}
417 */
512 /** {@inheritDoc} */
418513 public InvocationRequest setProfiles( List<String> profiles )
419514 {
420515 this.profiles = profiles;
423518
424519 /**
425520 * {@inheritDoc}
521 *
522 * @return a boolean.
426523 */
427524 public boolean isNonPluginUpdates()
428525 {
429526 return nonPluginUpdates;
430527 }
431528
432 /**
433 * {@inheritDoc}
434 */
529 /** {@inheritDoc} */
435530 public InvocationRequest setNonPluginUpdates( boolean nonPluginUpdates )
436531 {
437532 this.nonPluginUpdates = nonPluginUpdates;
438533 return this;
439534 }
440535
536 /** {@inheritDoc} */
441537 public InvocationRequest addShellEnvironment( String name, String value )
442538 {
443539 if ( this.shellEnvironments == null )
444540 {
445 this.shellEnvironments = new HashMap<String, String>();
541 this.shellEnvironments = new HashMap<>();
446542 }
447543 this.shellEnvironments.put( name, value );
448544 return this;
449545 }
450546
547 /**
548 * <p>Getter for the field <code>shellEnvironments</code>.</p>
549 *
550 * @return a {@link java.util.Map} object.
551 */
451552 public Map<String, String> getShellEnvironments()
452553 {
453554 return shellEnvironments == null ? Collections.<String, String>emptyMap() : shellEnvironments;
454555 }
455556
557 /**
558 * <p>Getter for the field <code>mavenOpts</code>.</p>
559 *
560 * @return a {@link java.lang.String} object.
561 */
456562 public String getMavenOpts()
457563 {
458564 return mavenOpts;
459565 }
460566
567 /** {@inheritDoc} */
461568 public InvocationRequest setMavenOpts( String mavenOpts )
462569 {
463570 this.mavenOpts = mavenOpts;
465572 }
466573
467574 /**
575 * <p>isShowVersion.</p>
576 *
468577 * @see org.apache.maven.shared.invoker.InvocationRequest#isShowVersion()
578 * @return a boolean.
469579 */
470580 public boolean isShowVersion()
471581 {
472582 return this.showVersion;
473583 }
474584
475 /**
476 * @see org.apache.maven.shared.invoker.InvocationRequest#setShowVersion(boolean)
477 */
585 /** {@inheritDoc} */
478586 public InvocationRequest setShowVersion( boolean showVersion )
479587 {
480588 this.showVersion = showVersion;
483591
484592 /**
485593 * {@inheritDoc}
594 *
595 * @return a {@link java.lang.String} object.
486596 */
487597 public String getThreads()
488598 {
489599 return threads;
490600 }
491601
492 /**
493 * {@inheritDoc}
494 */
602 /** {@inheritDoc} */
495603 public InvocationRequest setThreads( String threads )
496604 {
497605 this.threads = threads;
500608
501609 /**
502610 * {@inheritDoc}
611 *
612 * @return a {@link java.util.List} object.
503613 */
504614 public List<String> getProjects()
505615 {
506616 return projects;
507617 }
508618
509 /**
510 * {@inheritDoc}
511 */
619 /** {@inheritDoc} */
512620 public InvocationRequest setProjects( List<String> projects )
513621 {
514622 this.projects = projects;
517625
518626 /**
519627 * {@inheritDoc}
628 *
629 * @return a boolean.
520630 */
521631 public boolean isAlsoMake()
522632 {
523633 return alsoMake;
524634 }
525635
526 /**
527 * {@inheritDoc}
528 */
636 /** {@inheritDoc} */
529637 public InvocationRequest setAlsoMake( boolean alsoMake )
530638 {
531639 this.alsoMake = alsoMake;
534642
535643 /**
536644 * {@inheritDoc}
645 *
646 * @return a boolean.
537647 */
538648 public boolean isAlsoMakeDependents()
539649 {
540650 return alsoMakeDependents;
541651 }
542652
543 /**
544 * {@inheritDoc}
545 */
653 /** {@inheritDoc} */
546654 public InvocationRequest setAlsoMakeDependents( boolean alsoMakeDependents )
547655 {
548656 this.alsoMakeDependents = alsoMakeDependents;
551659
552660 /**
553661 * {@inheritDoc}
662 *
663 * @return a {@link java.lang.String} object.
554664 */
555665 public String getResumeFrom()
556666 {
557667 return resumeFrom;
558668 }
559669
560 /**
561 * {@inheritDoc}
562 */
670 /** {@inheritDoc} */
563671 public InvocationRequest setResumeFrom( String resumeFrom )
564672 {
565673 this.resumeFrom = resumeFrom;
566674 return this;
567675 }
568676
569 /**
570 * {@inheritDoc}
571 */
677 /** {@inheritDoc} */
572678 public InvocationRequest setBuilder( String id )
573679 {
574680 this.builderId = id;
577683
578684 /**
579685 * {@inheritDoc}
686 *
687 * @return a {@link java.lang.String} object.
580688 */
581689 public String getBuilder()
582690 {
583691 return this.builderId;
584692 }
585693
694
695 /** {@inheritDoc} */
696 @Override
697 public int getTimeoutInSeconds()
698 {
699 return timeoutInSeconds;
700 }
701
702 /** {@inheritDoc} */
703 @Override
704 public void setTimeoutInSeconds( int timeoutInSeconds )
705 {
706 this.timeoutInSeconds = timeoutInSeconds;
707 }
708
709 /**
710 * {@inheritDoc}
711 *
712 * @return a boolean.
713 * @since 3.1.0
714 */
715 public boolean isQuiet()
716 {
717 return quiet;
718 }
719
720 /** {@inheritDoc} */
721 public InvocationRequest setQuiet( boolean quiet )
722 {
723 this.quiet = quiet;
724 return this;
725 }
586726 }
1818 * under the License.
1919 */
2020
21 import org.codehaus.plexus.util.cli.CommandLineException;
21 import org.apache.maven.shared.utils.cli.CommandLineException;
2222
2323 /**
2424 * Describes the result of a Maven invocation.
25 *
26 * @version $Id: DefaultInvocationResult.java 1401842 2012-10-24 19:49:47Z rfscholte $
25 *
2726 */
2827 public final class DefaultInvocationResult
2928 implements InvocationResult
4847 // hide constructor
4948 }
5049
50 /**
51 * <p>Getter for the field <code>exitCode</code>.</p>
52 *
53 * @return a int.
54 */
5155 public int getExitCode()
5256 {
5357 return exitCode;
5458 }
5559
60 /**
61 * <p>Getter for the field <code>executionException</code>.</p>
62 *
63 * @return a {@link org.apache.maven.shared.utils.cli.CommandLineException} object.
64 */
5665 public CommandLineException getExecutionException()
5766 {
5867 return executionException;
2121 import java.io.File;
2222 import java.io.InputStream;
2323
24 import org.codehaus.plexus.component.annotations.Component;
25 import org.codehaus.plexus.util.cli.CommandLineException;
26 import org.codehaus.plexus.util.cli.CommandLineUtils;
27 import org.codehaus.plexus.util.cli.Commandline;
24 import org.apache.maven.shared.utils.cli.CommandLineException;
25 import org.apache.maven.shared.utils.cli.CommandLineUtils;
26 import org.apache.maven.shared.utils.cli.Commandline;
27
28 import javax.inject.Named;
29 import javax.inject.Singleton;
2830
2931 /**
3032 * Class intended to be used by clients who wish to invoke a forked Maven process from their applications
31 *
33 *
3234 * @author jdcasey
3335 */
34 @Component( role = Invoker.class, hint = "default" )
36 @Named
37 @Singleton
3538 public class DefaultInvoker
3639 implements Invoker
3740 {
38
41 /** Constant <code>ROLE_HINT="default"</code> */
3942 public static final String ROLE_HINT = "default";
4043
4144 private static final InvokerLogger DEFAULT_LOGGER = new SystemOutLogger();
5861
5962 private InvocationOutputHandler errorHandler = DEFAULT_OUTPUT_HANDLER;
6063
64 /** {@inheritDoc} */
6165 public InvocationResult execute( InvocationRequest request )
6266 throws MavenInvocationException
6367 {
107111
108112 try
109113 {
110 int exitCode = executeCommandLine( cli, request );
114 int exitCode = executeCommandLine( cli, request, request.getTimeoutInSeconds() );
111115
112116 result.setExitCode( exitCode );
113117 }
119123 return result;
120124 }
121125
122 private int executeCommandLine( Commandline cli, InvocationRequest request )
126 private int executeCommandLine( Commandline cli, InvocationRequest request, int timeoutInSeconds )
123127 throws CommandLineException
124128 {
125 int result = Integer.MIN_VALUE;
129 int result;
126130
127131 InputStream inputStream = request.getInputStream( this.inputStream );
128132 InvocationOutputHandler outputHandler = request.getOutputHandler( this.outputHandler );
140144 getLogger().info( "Executing in batch mode. The configured input stream will be ignored." );
141145 }
142146
143 result = CommandLineUtils.executeCommandLine( cli, outputHandler, errorHandler );
147 result = CommandLineUtils.executeCommandLine( cli, outputHandler, errorHandler, timeoutInSeconds );
144148 }
145149 else
146150 {
149153 getLogger().warn( "Maven will be executed in interactive mode"
150154 + ", but no input stream has been configured for this MavenInvoker instance." );
151155
152 result = CommandLineUtils.executeCommandLine( cli, outputHandler, errorHandler );
156 result = CommandLineUtils.executeCommandLine( cli, outputHandler, errorHandler, timeoutInSeconds );
153157 }
154158 else
155159 {
156 result = CommandLineUtils.executeCommandLine( cli, inputStream, outputHandler, errorHandler );
160 result = CommandLineUtils.executeCommandLine( cli, inputStream, outputHandler, errorHandler,
161 timeoutInSeconds );
157162 }
158163 }
159164
160165 return result;
161166 }
162167
168 /**
169 * <p>Getter for the field <code>localRepositoryDirectory</code>.</p>
170 *
171 * @return a {@link java.io.File} object.
172 */
163173 public File getLocalRepositoryDirectory()
164174 {
165175 return localRepositoryDirectory;
166176 }
167177
178 /**
179 * <p>Getter for the field <code>logger</code>.</p>
180 *
181 * @return a {@link org.apache.maven.shared.invoker.InvokerLogger} object.
182 */
168183 public InvokerLogger getLogger()
169184 {
170185 return logger;
171186 }
172187
188 /** {@inheritDoc} */
173189 public Invoker setLocalRepositoryDirectory( File localRepositoryDirectory )
174190 {
175191 this.localRepositoryDirectory = localRepositoryDirectory;
176192 return this;
177193 }
178194
195 /** {@inheritDoc} */
179196 public Invoker setLogger( InvokerLogger logger )
180197 {
181198 this.logger = ( logger != null ) ? logger : DEFAULT_LOGGER;
182199 return this;
183200 }
184201
202 /**
203 * <p>Getter for the field <code>workingDirectory</code>.</p>
204 *
205 * @return a {@link java.io.File} object.
206 */
185207 public File getWorkingDirectory()
186208 {
187209 return workingDirectory;
188210 }
189211
212 /** {@inheritDoc} */
190213 public Invoker setWorkingDirectory( File workingDirectory )
191214 {
192215 this.workingDirectory = workingDirectory;
193216 return this;
194217 }
195218
219 /**
220 * <p>Getter for the field <code>mavenHome</code>.</p>
221 *
222 * @return a {@link java.io.File} object.
223 */
196224 public File getMavenHome()
197225 {
198226 return mavenHome;
199227 }
200228
229 /** {@inheritDoc} */
201230 public Invoker setMavenHome( File mavenHome )
202231 {
203232 this.mavenHome = mavenHome;
205234 return this;
206235 }
207236
237 /**
238 * <p>Getter for the field <code>mavenExecutable</code>.</p>
239 *
240 * @return a {@link java.io.File} object.
241 */
208242 public File getMavenExecutable()
209243 {
210244 return mavenExecutable;
211245 }
212246
247 /** {@inheritDoc} */
213248 public Invoker setMavenExecutable( File mavenExecutable )
214249 {
215250 this.mavenExecutable = mavenExecutable;
216251 return this;
217252 }
218253
254 /** {@inheritDoc} */
219255 public Invoker setErrorHandler( InvocationOutputHandler errorHandler )
220256 {
221257 this.errorHandler = errorHandler;
222258 return this;
223259 }
224260
261 /** {@inheritDoc} */
225262 public Invoker setInputStream( InputStream inputStream )
226263 {
227264 this.inputStream = inputStream;
228265 return this;
229266 }
230267
268 /** {@inheritDoc} */
231269 public Invoker setOutputHandler( InvocationOutputHandler outputHandler )
232270 {
233271 this.outputHandler = outputHandler;
1818 * under the License.
1919 */
2020
21 import org.codehaus.plexus.util.cli.StreamConsumer;
21 import org.apache.maven.shared.utils.cli.StreamConsumer;
2222
2323 /**
2424 * Receives the standard/error output from a Maven invocation.
25 *
26 * @version $Id: InvocationOutputHandler.java 1401842 2012-10-24 19:49:47Z rfscholte $
25 *
2726 */
2827 public interface InvocationOutputHandler
2928 extends StreamConsumer
2626
2727 /**
2828 * Specifies the parameters used to control a Maven invocation.
29 *
30 * @version $Id: InvocationRequest.java 1760179 2016-09-10 14:49:13Z khmarbaise $
29 *
3130 */
3231 public interface InvocationRequest
3332 {
3433
3534 /**
3635 * By default, Maven is executed in batch mode. This mean no interaction with the Maven process can be done.
37 *
36 *
3837 * @return <code>true</code> if Maven should be executed in batch mode, <code>false</code> if Maven is executed in
3938 * interactive mode.
4039 * @since 3.0.0
4342
4443 /**
4544 * Gets the network mode of the Maven invocation. By default, Maven is executed in online mode.
46 *
45 *
4746 * @return <code>true</code> if Maven should be executed in offline mode, <code>false</code> if the online mode is
4847 * used.
4948 */
5251 /**
5352 * Indicates whether Maven should enforce an update check for plugins and snapshots. By default, no update check is
5453 * performed.
55 *
54 *
5655 * @return <code>true</code> if plugins and snapshots should be updated, <code>false</code> otherwise.
5756 */
5857 boolean isUpdateSnapshots();
5958
6059 /**
6160 * Gets the recursion behavior of a reactor invocation. By default, Maven will recursive the build into sub modules.
62 *
61 *
6362 * @return <code>true</code> if sub modules should be build, <code>false</code> otherwise.
6463 */
6564 boolean isRecursive();
6766 /**
6867 * A list of specified reactor projects to build instead of all projects. A project can be specified by
6968 * [groupId]:artifactId or by its relative path.
70 *
69 *
7170 * @return the list of projects to add to reactor build, otherwise {@code null}
7271 * @since 2.1
7372 */
7574
7675 /**
7776 * Get the value of the {@code also-make} argument.
78 *
77 *
7978 * @return {@code true} if the argument {@code also-make} was specified, otherwise {@code false}
8079 * @since 2.1
8180 */
8382
8483 /**
8584 * Get the value of the {@code also-make-dependents}
86 *
85 *
8786 * @return {@code true} if the argument {@code also-make-dependents} was specified, otherwise {@code false}
8887 * @since 2.1
8988 */
9190
9291 /**
9392 * Get the value of {@code resume-from}
94 *
93 *
9594 * @return specified reactor project to resume from
9695 * @since 2.1
9796 */
9998
10099 /**
101100 * Gets the debug mode of the Maven invocation. By default, Maven is executed in normal mode.
102 *
101 *
103102 * @return <code>true</code> if Maven should be executed in debug mode, <code>false</code> if the normal mode should
104103 * be used.
105104 */
108107 /**
109108 * Gets the exception output mode of the Maven invocation. By default, Maven will not print stack traces of build
110109 * exceptions.
111 *
110 *
112111 * @return <code>true</code> if Maven should print stack traces, <code>false</code> otherwise.
113112 */
114113 boolean isShowErrors();
116115 /**
117116 * Indicates whether the environment variables of the current process should be propagated to the Maven invocation.
118117 * By default, the current environment variables are inherited by the new Maven invocation.
119 *
118 *
120119 * @return <code>true</code> if the environment variables should be propagated, <code>false</code> otherwise.
121120 */
122121 boolean isShellEnvironmentInherited();
123122
124123 /**
125124 * Indicates whether Maven should check for plugin updates. By default, plugin updates are not suppressed.
126 *
125 *
127126 * @return <code>true</code> if plugin updates should be suppressed, <code>false</code> otherwise.
128127 */
129128 boolean isNonPluginUpdates();
131130 /**
132131 * Gets the failure mode of the Maven invocation. By default, the mode {@link ReactorFailureBehavior#FailFast} is
133132 * used.
134 *
133 *
135134 * @return The failure mode, one of {@link ReactorFailureBehavior#FailFast},
136135 * {@link ReactorFailureBehavior#FailAtEnd} and {@link ReactorFailureBehavior#FailNever}.
137136 * @since 3.0.0
140139
141140 /**
142141 * Gets the path to the base directory of the local repository to use for the Maven invocation.
143 *
142 *
144143 * @param defaultDirectory The default location to use if no location is configured for this request, may be
145144 * <code>null</code>.
146145 * @return The path to the base directory of the local repository or <code>null</code> to use the location from the
151150 /**
152151 * Gets the input stream used to provide input for the invoked Maven build. This is in particular useful when
153152 * invoking Maven in interactive mode.
154 *
153 *
154 * @param defaultStream the default {@link java.io.InputStream} to use
155155 * @return The input stream used to provide input for the invoked Maven build or <code>null</code> if not set.
156156 */
157157 InputStream getInputStream( InputStream defaultStream );
158158
159159 /**
160160 * Gets the handler used to capture the standard output from the Maven build.
161 *
161 *
162 * @param defaultHandler the default {@link org.apache.maven.shared.invoker.InvocationOutputHandler} to use
162163 * @return The output handler or <code>null</code> if not set.
163164 */
164165 InvocationOutputHandler getOutputHandler( InvocationOutputHandler defaultHandler );
165166
166167 /**
167168 * Gets the handler used to capture the error output from the Maven build.
168 *
169 *
170 * @param defaultHandler the default {@link org.apache.maven.shared.invoker.InvocationOutputHandler} to use
169171 * @return The error handler or <code>null</code> if not set.
170172 */
171173 InvocationOutputHandler getErrorHandler( InvocationOutputHandler defaultHandler );
173175 /**
174176 * Gets the path to the POM for the Maven invocation. If no base directory is set, the parent directory of this POM
175177 * will be used as the working directory for the Maven invocation.
176 *
178 *
177179 * @return The path to the POM for the Maven invocation or <code>null</code> if not set.
178180 */
179181 File getPomFile();
182184 * Gets the (unqualified) filename of the POM for the Maven invocation. This setting is ignored if
183185 * {@link #getPomFile()} does not return <code>null</code>. Otherwise, the base directory is assumed to contain a
184186 * POM with this name. By default, a file named <code>pom.xml</code> is used.
185 *
187 *
186188 * @return The (unqualified) filename of the POM for the Maven invocation or <code>null</code> if not set.
187189 */
188190 String getPomFileName();
190192 /**
191193 * Gets the path to the base directory of the POM for the Maven invocation. If {@link #getPomFile()} does not return
192194 * <code>null</code>, this setting only affects the working directory for the Maven invocation.
193 *
195 *
194196 * @return The path to the base directory of the POM or <code>null</code> if not set.
195197 */
196198 File getBaseDirectory();
198200 /**
199201 * Gets the path to the base directory of the POM for the Maven invocation. If {@link #getPomFile()} does not return
200202 * <code>null</code>, this setting only affects the working directory for the Maven invocation.
201 *
203 *
202204 * @param defaultDirectory The default base directory to use if none is configured for this request, may be
203205 * <code>null</code>.
204206 * @return The path to the base directory of the POM or <code>null</code> if not set.
207209
208210 /**
209211 * Gets the path to the base directory of the Java installation used to run Maven.
210 *
212 *
211213 * @return The path to the base directory of the Java installation used to run Maven or <code>null</code> to use the
212214 * default Java home.
213215 */
215217
216218 /**
217219 * Gets the system properties for the Maven invocation.
218 *
220 *
219221 * @return The system properties for the Maven invocation or <code>null</code> if not set.
220222 */
221223 Properties getProperties();
222224
223225 /**
224226 * Gets the goals for the Maven invocation.
225 *
227 *
226228 * @return The goals for the Maven invocation or <code>null</code> if not set.
227229 */
228230 List<String> getGoals();
229231
230232 /**
231233 * Gets the path to the user settings for the Maven invocation.
232 *
234 *
233235 * @return The path to the user settings for the Maven invocation or <code>null</code> to load the user settings
234236 * from the default location.
235237 */
237239
238240 /**
239241 * Gets the path to the global settings for the Maven invocation.
240 *
242 *
241243 * @return The path to the global settings for the Maven invocation or <code>null</code> to load the global settings
242244 * from the default location.
243245 * @since 2.1
246248
247249 /**
248250 * Gets the path to the custom toolchains file
249 *
251 *
250252 * @return The path to the custom toolchains file or <code>null</code> to load the toolchains from the default
251253 * location
252254 * @since 2.1
255257
256258 /**
257259 * Alternate path for the global toolchains file <b>Note. This is available since Maven 3.3.1</b>
258 *
260 *
259261 * @return The path to the custom global toolchains file or <code>null</code> to load the global toolchains from the
260262 * default location.
261263 * @since 3.0.0
264266
265267 /**
266268 * Gets the checksum mode of the Maven invocation.
267 *
269 *
268270 * @return The checksum mode, one of {@link CheckSumPolicy#Warn} and {@link CheckSumPolicy#Fail}.
269271 * @since 3.0.0
270272 */
272274
273275 /**
274276 * Gets the profiles for the Maven invocation.
275 *
277 *
276278 * @return The profiles for the Maven invocation or <code>null</code> if not set.
277279 */
278280 List<String> getProfiles();
279281
280282 /**
281283 * Gets the environment variables for the Maven invocation.
282 *
284 *
283285 * @return The environment variables for the Maven invocation or <code>null</code> if not set.
284286 */
285287 Map<String, String> getShellEnvironments();
286288
287289 /**
288290 * Gets the value of the <code>MAVEN_OPTS</code> environment variable.
289 *
291 *
290292 * @return The value of the <code>MAVEN_OPTS</code> environment variable or <code>null</code> if not set.
291293 */
292294 String getMavenOpts();
293295
294296 /**
295297 * The show version behavior (-V option)
296 *
298 *
297299 * @return The show version behavior
298300 * @since 2.0.11
299301 */
301303
302304 /**
303305 * Get the value of the {@code threads} argument.
304 *
306 *
305307 * @return the value of the {@code threads} argument or {@code null} if not set
306308 * @since 2.1
307309 */
308310 String getThreads();
311
312 /**
313 * Gets the quiet mode of the Maven invocation. By default, Maven is executed in normal mode.
314 *
315 * @return <code>true</code> if Maven should be executed in quiet mode, <code>false</code> if normal mode should
316 * be used.
317 * @since 3.1.0
318 */
319 boolean isQuiet();
309320
310321 // ----------------------------------------------------------------------
311322 // Reactor Failure Mode
333344
334345 private String longOption;
335346
336 private ReactorFailureBehavior( String shortOption, String longOption )
347 ReactorFailureBehavior( String shortOption, String longOption )
337348 {
338349 this.shortOption = shortOption;
339350 this.longOption = longOption;
368379 throw new IllegalArgumentException( "The string '" + longOption
369380 + "' can not be converted to enumeration." );
370381 }
371 };
382 }
372383
373384 // ----------------------------------------------------------------------
374385 // Artifact repository policies
397408
398409 /**
399410 * Sets the interaction mode of the Maven invocation. Equivalent of {@code -B} and {@code --batch-mode}
400 *
411 *
401412 * @param batchMode <code>true</code> if Maven should be executed in non-interactive mode, <code>false</code> if the
402413 * interactive modes is used.
403414 * @return This invocation request.
407418
408419 /**
409420 * Sets the network mode of the Maven invocation. Equivalent of {@code -o} and {@code --offline}
410 *
421 *
411422 * @param offline <code>true</code> if Maven should be executed in offline mode, <code>false</code> if the online
412423 * mode is used.
413424 * @return This invocation request.
416427
417428 /**
418429 * Sets the debug mode of the Maven invocation. Equivalent of {@code -X} and {@code --debug}
419 *
430 *
420431 * @param debug <code>true</code> if Maven should be executed in debug mode, <code>false</code> if the normal mode
421432 * should be used.
422433 * @return This invocation request.
425436
426437 /**
427438 * Sets the exception output mode of the Maven invocation. Equivalent of {@code -e} and {@code --errors}
428 *
439 *
429440 * @param showErrors <code>true</code> if Maven should print stack traces, <code>false</code> otherwise.
430441 * @return This invocation request.
431442 */
434445 /**
435446 * Specifies whether Maven should enforce an update check for plugins and snapshots. Equivalent of {@code -U} and
436447 * {@code --update-snapshots}
437 *
448 *
438449 * @param updateSnapshots <code>true</code> if plugins and snapshots should be updated, <code>false</code>
439450 * otherwise.
440451 * @return This invocation request.
444455 /**
445456 * Sets the failure mode of the Maven invocation. Equivalent of {@code -ff} and {@code --fail-fast}, {@code -fae}
446457 * and {@code --fail-at-end}, {@code -fn} and {@code --fail-never}
447 *
458 *
448459 * @param failureBehavior The failure mode, must be one of {@link ReactorFailureBehavior#FailFast},
449460 * {@link ReactorFailureBehavior#FailAtEnd} and {@link ReactorFailureBehavior#FailNever}.
450461 * @return This invocation request.
454465
455466 /**
456467 * Sets the path to the base directory of the local repository to use for the Maven invocation.
457 *
468 *
458469 * @param localRepository The path to the base directory of the local repository, may be <code>null</code>.
459470 * @return This invocation request.
460471 */
463474 /**
464475 * Sets the input stream used to provide input for the invoked Maven build. This is in particular useful when
465476 * invoking Maven in interactive mode.
466 *
477 *
467478 * @param inputStream The input stream used to provide input for the invoked Maven build, may be <code>null</code>
468479 * if not required.
469480 * @return This invocation request.
472483
473484 /**
474485 * Sets the handler used to capture the standard output from the Maven build.
475 *
486 *
476487 * @param outputHandler The output handler, may be <code>null</code> if the output is not of interest.
477488 * @return This invocation request.
478489 */
480491
481492 /**
482493 * Sets the handler used to capture the error output from the Maven build.
483 *
494 *
484495 * @param errorHandler The error handler, may be <code>null</code> if the output is not of interest.
485496 * @return This invocation request.
486497 */
489500 /**
490501 * Sets the path to the POM for the Maven invocation. If no base directory is set, the parent directory of this POM
491502 * will be used as the working directory for the Maven invocation.
492 *
503 *
493504 * @param pomFile The path to the POM for the Maven invocation, may be <code>null</code> if not used.
494505 * @return This invocation request.
495506 */
499510 * Sets the (unqualified) filename of the POM for the Maven invocation. This setting is ignored if
500511 * {@link #getPomFile()} does not return <code>null</code>. Otherwise, the base directory is assumed to contain a
501512 * POM with this name.
502 *
513 *
503514 * @param pomFilename The (unqualified) filename of the POM for the Maven invocation, may be <code>null</code> if
504515 * not used.
505516 * @return This invocation request.
509520 /**
510521 * Sets the path to the base directory of the POM for the Maven invocation. If {@link #getPomFile()} does not return
511522 * <code>null</code>, this setting only affects the working directory for the Maven invocation.
512 *
523 *
513524 * @param basedir The path to the base directory of the POM, may be <code>null</code> if not used.
514525 * @return This invocation request.
515526 */
517528
518529 /**
519530 * Sets the path to the base directory of the Java installation used to run Maven.
520 *
531 *
521532 * @param javaHome The path to the base directory of the Java installation used to run Maven, may be
522533 * <code>null</code> to use the default Java home.
523534 * @return This invocation request.
526537
527538 /**
528539 * Sets the system properties for the Maven invocation.
529 *
540 *
530541 * @param properties The system properties for the Maven invocation, may be <code>null</code> if not set.
531542 * @return This invocation request.
532543 */
534545
535546 /**
536547 * Sets the goals for the Maven invocation.
537 *
548 *
538549 * @param goals The goals for the Maven invocation, may be <code>null</code> to execute the POMs default goal.
539550 * @return This invocation request.
540551 */
542553
543554 /**
544555 * Sets the profiles for the Maven invocation. Equivalent of {@code -P} and {@code --active-profiles}
545 *
556 *
546557 * @param profiles The profiles for the Maven invocation, may be <code>null</code> to use the default profiles.
547558 * @return This invocation request.
548559 */
550561
551562 /**
552563 * Specifies whether the environment variables of the current process should be propagated to the Maven invocation.
553 *
564 *
554565 * @param shellEnvironmentInherited <code>true</code> if the environment variables should be propagated,
555566 * <code>false</code> otherwise.
556567 * @return This invocation request.
559570
560571 /**
561572 * Sets the path to the user settings for the Maven invocation. Equivalent of {@code -s} and {@code --settings}
562 *
573 *
563574 * @param userSettings The path to the user settings for the Maven invocation, may be <code>null</code> to load the
564575 * user settings from the default location.
565576 * @return This invocation request.
569580 /**
570581 * Sets the path to the global settings for the Maven invocation. Equivalent of {@code -gs} and
571582 * {@code --global-settings}
572 *
583 *
573584 * @param globalSettings The path to the global settings for the Maven invocation, may be <code>null</code> to load
574585 * the global settings from the default location.
575586 * @return This invocation request.
579590
580591 /**
581592 * Sets the alternate path for the user toolchains file Equivalent of {@code -t} or {@code --toolchains}
582 *
593 *
583594 * @param toolchains the alternate path for the user toolchains file
584595 * @return This invocation request
585596 * @since 2.1
588599
589600 /**
590601 * Sets the alternate path for the global toolchains file Equivalent of {@code -gt} or {@code --global-toolchains}
591 *
602 *
592603 * @param toolchains the alternate path for the global toolchains file
593604 * @return This invocation request
594605 * @since 3.0.0
598609 /**
599610 * Sets the checksum mode of the Maven invocation. Equivalent of {@code -c} or {@code --lax-checksums}, {@code -C}
600611 * or {@code --strict-checksums}
601 *
612 *
602613 * @param globalChecksumPolicy The checksum mode, must be one of {@link CheckSumPolicy#Warn} and
603614 * {@link CheckSumPolicy#Fail}.
604615 * @return This invocation request.
609620 /**
610621 * Specifies whether Maven should check for plugin updates.
611622 * <p>
612 * Equivalent of {@code -npu} or {@code --no-plugin-updates}<br/>
623 * Equivalent of {@code -npu} or {@code --no-plugin-updates}
624 * </p>
625 * <p>
613626 * <strong>note: </strong>Ineffective with Maven3, only kept for backward compatibility
614627 * </p>
615 *
628 *
616629 * @param nonPluginUpdates <code>true</code> if plugin updates should be suppressed, <code>false</code> otherwise.
617630 * @return This invocation request.
618631 */
621634 /**
622635 * Sets the recursion behavior of a reactor invocation. <em>Inverse</em> equivalent of {@code -N} and
623636 * {@code --non-recursive}
624 *
637 *
625638 * @param recursive <code>true</code> if sub modules should be build, <code>false</code> otherwise.
626639 * @return This invocation request.
627640 */
629642
630643 /**
631644 * Adds the specified environment variable to the Maven invocation.
632 *
645 *
633646 * @param name The name of the environment variable, must not be <code>null</code>.
634647 * @param value The value of the environment variable, must not be <code>null</code>.
635648 * @return This invocation request.
638651
639652 /**
640653 * Sets the value of the <code>MAVEN_OPTS</code> environment variable.
641 *
654 *
642655 * @param mavenOpts The value of the <code>MAVEN_OPTS</code> environment variable, may be <code>null</code> to use
643656 * the default options.
644657 * @return This invocation request.
647660
648661 /**
649662 * enable displaying version without stopping the build Equivalent of {@code -V} or {@code --show-version}
650 *
663 *
651664 * @param showVersion enable displaying version
652665 * @return This invocation request.
653666 * @since 2.0.11
659672 * <p>
660673 * <strong>note: </strong>available since Maven3
661674 * </p>
662 *
675 *
663676 * @param threads the threadcount
664677 * @return This invocation request.
665678 * @since 2.1
668681
669682 /**
670683 * Sets the reactor project list. Equivalent of {@code -pl} or {@code --projects}
671 *
684 *
672685 * @param projects the reactor project list
673686 * @return This invocation request.
674687 * @since 2.1
677690
678691 /**
679692 * Enable the 'also make' mode. Equivalent of {@code -am} or {@code --also-make}
680 *
693 *
681694 * @param alsoMake enable 'also make' mode
682695 * @return This invocation request.
683696 * @since 2.1
686699
687700 /**
688701 * Enable the 'also make dependents' mode. Equivalent of {@code -amd} or {@code --also-make-dependents}
689 *
702 *
690703 * @param alsoMakeDependents enable 'also make' mode
691704 * @return This invocation request.
692705 * @since 2.1
695708
696709 /**
697710 * Resume reactor from specified project. Equivalent of {@code -rf} or {@code --resume-from}
698 *
711 *
699712 * @param resumeFrom set the project to resume from
700713 * @return This invocation request
701714 * @since 2.1
705718 /**
706719 * The id of the build strategy to use. equivalent of {@code --builder id}. <b>Note. This is available since Maven
707720 * 3.2.1</b>
708 *
721 *
709722 * @param id The builder id.
710723 * @return {@link InvocationRequest} FIXME: How to identify if this is a valid command line option?
711724 * @since 3.0.0
713726 InvocationRequest setBuilder( String id );
714727
715728 /**
729 * Sets the quiet mode of the Maven invocation. Equivalent of {@code -q} and {@code --quiet}
730 *
731 * @param quiet <code>true</code> if Maven should be executed in quiet mode, <code>false</code> if the normal mode
732 * should be used.
733 * @return This invocation request.
734 * @since 3.1.0
735 */
736 InvocationRequest setQuiet( boolean quiet );
737
738 /**
716739 * Get the current set builder strategy id equivalent of {@code --builder id}. <b>Note. This is available since
717740 * Maven 3.2.1</b>
718 *
741 *
719742 * @return The current set builder id.
720743 * @since 3.0.0
721744 */
722745 String getBuilder();
723746
747 /** Constant <code>NO_TIMEOUT=0</code> */
748 int NO_TIMEOUT = 0;
749 /**
750 * <p>getTimeoutInSeconds.</p>
751 *
752 * @since 3.0.1
753 * @return the timeout in seconds to execute the project
754 */
755 int getTimeoutInSeconds();
756
757 /**
758 * <p>setTimeoutInSeconds.</p>
759 *
760 * @since 3.0.1
761 * @param timeoutInSeconds the timeout in seconds to execute the project
762 */
763 void setTimeoutInSeconds( int timeoutInSeconds );
764
724765 }
1818 * under the License.
1919 */
2020
21 import org.codehaus.plexus.util.cli.CommandLineException;
21 import org.apache.maven.shared.utils.cli.CommandLineException;
2222
2323 /**
2424 * Describes the result of a Maven invocation.
25 *
25 *
2626 * @author jdcasey
27 * @version $Id: InvocationResult.java 1401842 2012-10-24 19:49:47Z rfscholte $
2827 */
2928 public interface InvocationResult
3029 {
3130
3231 /**
3332 * Gets the exception that possibly occurred during the execution of the command line.
34 *
33 *
3534 * @return The exception that prevented to invoke Maven or <code>null</code> if the command line was successfully
3635 * processed by the operating system.
3736 */
4039 /**
4140 * Gets the exit code from the Maven invocation. A non-zero value indicates a build failure. <strong>Note:</strong>
4241 * This value is undefined if {@link #getExecutionException()} reports an exception.
43 *
42 *
4443 * @return The exit code from the Maven invocation.
4544 */
4645 int getExitCode();
2323
2424 /**
2525 * Provides a facade to invoke Maven.
26 *
27 * @version $Id: Invoker.java 1712636 2015-11-04 20:35:22Z khmarbaise $
26 *
2827 */
2928 public interface Invoker
3029 {
3837 * Executes Maven using the parameters specified by the given invocation request. Parameters not specified by the
3938 * invocation request will be derived from the state of this invoker instance. In case both the invoker instance and
4039 * the invocation request provide a value for a particular option, the value from the invocation request dominates.
41 *
40 *
4241 * @param request The invocation request to execute, must not be <code>null</code>.
4342 * @return The result of the Maven invocation, never <code>null</code>.
44 * @throws MavenInvocationException
43 * @throws MavenInvocationException if cannot configure correctly execution parameters
4544 */
4645 InvocationResult execute( InvocationRequest request )
4746 throws MavenInvocationException;
4847
4948 /**
5049 * Gets the path to the base directory of the local repository to use for the Maven invocation.
51 *
50 *
5251 * @return The path to the base directory of the local repository or <code>null</code> to use the location from
5352 * the <code>settings.xml</code>.
5453 */
5655
5756 /**
5857 * Gets the working directory for the Maven invocation.
59 *
58 *
6059 * @return The working directory for the Maven invocation or <code>null</code> if the working directory is derived
6160 * from the base directory of the processed POM.
6261 */
6463
6564 /**
6665 * Gets the logger used by this invoker to output diagnostic messages.
67 *
66 *
6867 * @return The logger used by this invoker to output diagnostic messages, never <code>null</code>.
6968 */
7069 InvokerLogger getLogger();
7170
7271 /**
7372 * Gets the path to the base directory of the Maven installation used to invoke Maven.
74 *
73 *
7574 * @return The path to the base directory of the Maven installation or <code>null</code> if using the default
7675 * Maven installation.
7776 */
8180 * Sets the path to the base directory of the Maven installation used to invoke Maven. This parameter may be left
8281 * unspecified to use the default Maven installation which will be discovered by evaluating the system property
8382 * <code>maven.home</code> and the environment variable <code>M2_HOME</code>.
84 *
83 *
8584 * @param mavenHome The path to the base directory of the Maven installation, may be <code>null</code> to use the
8685 * default Maven installation.
8786 * @return This invoker instance.
9089
9190 /**
9291 * Get the customized File of the Maven executable.
93 *
94 * @return the custom Maven executable, otherwise {@code null}
92 *
93 * @return the custom Maven executable, otherwise {@code null}
9594 */
9695 File getMavenExecutable();
9796
9897 /**
9998 * {@code mavenExecutable} can either be a file relative to ${maven.home}/bin/ or an absolute file.
100 *
99 *
101100 * @param mavenExecutable the executable
102101 * @return This invoker instance
103102 */
105104
106105 /**
107106 * Sets the path to the base directory of the local repository to use for the Maven invocation.
108 *
107 *
109108 * @param localRepositoryDirectory The path to the base directory of the local repository or <code>null</code> to
110109 * use the location from the <code>settings.xml</code>.
111110 * @return This invoker instance.
114113
115114 /**
116115 * Sets the logger used by this invoker to output diagnostic messages.
117 *
116 *
118117 * @param logger The logger used by this invoker to output diagnostic messages, may be <code>null</code> to use a
119118 * default logger.
120119 * @return This invoker instance.
123122
124123 /**
125124 * Sets the working directory for the Maven invocation.
126 *
125 *
127126 * @param workingDirectory The working directory for the Maven invocation, may be <code>null</code> to derive the
128127 * working directory from the base directory of the processed POM.
129128 * @return This invoker instance.
133132 /**
134133 * Sets the input stream used to provide input for the invoked Maven build. This is in particular useful when
135134 * invoking Maven in interactive mode.
136 *
135 *
137136 * @param inputStream The input stream used to provide input for the invoked Maven build, may be <code>null</code>
138137 * if not required.
139138 * @return This invoker instance.
142141
143142 /**
144143 * Sets the handler used to capture the standard output from the Maven build.
145 *
144 *
146145 * @param outputHandler The output handler, may be <code>null</code> if the output is not of interest.
147146 * @return This invoker instance.
148147 */
150149
151150 /**
152151 * Sets the handler used to capture the error output from the Maven build.
153 *
152 *
154153 * @param errorHandler The error handler, may be <code>null</code> if the output is not of interest.
155154 * @return This invoker instance.
156155 */
1919 */
2020
2121 /**
22 * A logger used by {@link Invoker} instances to output diagnostic messages.
23 *
22 * A logger used by {@link org.apache.maven.shared.invoker.Invoker} instances to output diagnostic messages.
23 *
2424 * @see Invoker#setLogger(InvokerLogger)
2525 * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
26 * @version $Id: InvokerLogger.java 1635406 2014-10-30 06:51:13Z hboutemy $
2726 */
2827 public interface InvokerLogger
2928 {
5554
5655 /**
5756 * Logs the specified debug message.
58 *
57 *
5958 * @param message The message to log, may be <code>null</code>.
6059 */
6160 void debug( String message );
6261
6362 /**
6463 * Logs the specified debug message and the accompanying exception.
65 *
64 *
6665 * @param message The message to log, may be <code>null</code>.
6766 * @param throwable The exception to log, may be <code>null</code>.
6867 */
7069
7170 /**
7271 * Tests whether debug output is enabled for this logger.
73 *
72 *
7473 * @return <code>true</code> if messages with priority "debug" or above are logged, <code>false</code>
7574 * otherwise.
7675 */
7877
7978 /**
8079 * Logs the specified info message.
81 *
80 *
8281 * @param message The message to log, may be <code>null</code>.
8382 */
8483 void info( String message );
8584
8685 /**
8786 * Logs the specified info message and the accompanying exception.
88 *
87 *
8988 * @param message The message to log, may be <code>null</code>.
9089 * @param throwable The exception to log, may be <code>null</code>.
9190 */
9392
9493 /**
9594 * Tests whether info output is enabled for this logger.
96 *
95 *
9796 * @return <code>true</code> if messages with priority "info" or above are logged, <code>false</code> otherwise.
9897 */
9998 boolean isInfoEnabled();
10099
101100 /**
102101 * Logs the specified warning message.
103 *
102 *
104103 * @param message The message to log, may be <code>null</code>.
105104 */
106105 void warn( String message );
107106
108107 /**
109108 * Logs the specified warning message and the accompanying exception.
110 *
109 *
111110 * @param message The message to log, may be <code>null</code>.
112111 * @param throwable The exception to log, may be <code>null</code>.
113112 */
115114
116115 /**
117116 * Tests whether warn output is enabled for this logger.
118 *
117 *
119118 * @return <code>true</code> if messages with priority "warn" or above are logged, <code>false</code> otherwise.
120119 */
121120 boolean isWarnEnabled();
122121
123122 /**
124123 * Logs the specified error message.
125 *
124 *
126125 * @param message The message to log, may be <code>null</code>.
127126 */
128127 void error( String message );
129128
130129 /**
131130 * Logs the specified error message and the accompanying exception.
132 *
131 *
133132 * @param message The message to log, may be <code>null</code>.
134133 * @param throwable The exception to log, may be <code>null</code>.
135134 */
137136
138137 /**
139138 * Tests whether error output is enabled for this logger.
140 *
139 *
141140 * @return <code>true</code> if messages with priority "error" or above are logged, <code>false</code>
142141 * otherwise.
143142 */
145144
146145 /**
147146 * Logs the specified fatal error message.
148 *
147 *
149148 * @param message The message to log, may be <code>null</code>.
150149 */
151150 void fatalError( String message );
152151
153152 /**
154153 * Logs the specified fatal error message and the accompanying exception.
155 *
154 *
156155 * @param message The message to log, may be <code>null</code>.
157156 * @param throwable The exception to log, may be <code>null</code>.
158157 */
160159
161160 /**
162161 * Tests whether fatal error output is enabled for this logger.
163 *
162 *
164163 * @return <code>true</code> if messages with priority "fatal" or above are logged, <code>false</code>
165164 * otherwise.
166165 */
168167
169168 /**
170169 * Sets the logger's threshold.
171 *
170 *
172171 * @param threshold The logger's threshold, must be one of {@link #DEBUG}, {@link #INFO}, {@link #WARN},
173172 * {@link #ERROR} and {@link #FATAL}.
174173 */
176175
177176 /**
178177 * Gets the logger's threshold.
179 *
178 *
180179 * @return The logger's threshold, one of {@link #DEBUG}, {@link #INFO}, {@link #WARN}, {@link #ERROR} and
181180 * {@link #FATAL}.
182181 */
2020
2121 import java.io.File;
2222 import java.io.IOException;
23 import java.util.Iterator;
2423 import java.util.List;
2524 import java.util.Map;
2625 import java.util.Map.Entry;
2827
2928 import org.apache.maven.shared.invoker.InvocationRequest.CheckSumPolicy;
3029 import org.apache.maven.shared.invoker.InvocationRequest.ReactorFailureBehavior;
31 import org.codehaus.plexus.util.Os;
32 import org.codehaus.plexus.util.StringUtils;
33 import org.codehaus.plexus.util.cli.CommandLineUtils;
34 import org.codehaus.plexus.util.cli.Commandline;
30 import org.apache.maven.shared.utils.Os;
31 import org.apache.maven.shared.utils.StringUtils;
32 import org.apache.maven.shared.utils.cli.CommandLineException;
33 import org.apache.maven.shared.utils.cli.CommandLineUtils;
34 import org.apache.maven.shared.utils.cli.Commandline;
3535
3636 /**
37 * @version $Id: MavenCommandLineBuilder.java 1760179 2016-09-10 14:49:13Z khmarbaise $
37 * <p>MavenCommandLineBuilder class.</p>
3838 */
3939 public class MavenCommandLineBuilder
4040 {
5353
5454 private Properties systemEnvVars;
5555
56 /**
57 * <p>build.</p>
58 *
59 * @param request a {@link org.apache.maven.shared.invoker.InvocationRequest} object.
60 * @return a {@link org.apache.maven.shared.utils.cli.Commandline} object.
61 * @throws org.apache.maven.shared.invoker.CommandLineConfigurationException if any.
62 */
5663 public Commandline build( InvocationRequest request )
5764 throws CommandLineConfigurationException
5865 {
6471 {
6572 throw new CommandLineConfigurationException( e.getMessage(), e );
6673 }
67 File mvn = null;
74 File mvn;
6875 try
6976 {
7077 mvn = findMavenExecutable();
109116 return cli;
110117 }
111118
119 /**
120 * <p>checkRequiredState.</p>
121 *
122 * @throws java.io.IOException if any.
123 */
112124 protected void checkRequiredState()
113125 throws IOException
114126 {
125137 {
126138 throw new IllegalStateException( "Maven application directory was not "
127139 + "specified, and ${maven.home} is not provided in the system "
128 + "properties. Please specify at least on of these." );
129 }
130 }
131 }
132
140 + "properties. Specify at least one of these." );
141 }
142 }
143 }
144
145 /**
146 * <p>setSettingsLocation.</p>
147 *
148 * @param request a {@link org.apache.maven.shared.invoker.InvocationRequest} object.
149 * @param cli a {@link org.apache.maven.shared.utils.cli.Commandline} object.
150 */
133151 protected void setSettingsLocation( InvocationRequest request, Commandline cli )
134152 {
135153 File userSettingsFile = request.getUserSettingsFile();
138156 {
139157 try
140158 {
141 File canSet = userSettingsFile.getCanonicalFile();
142 userSettingsFile = canSet;
159 userSettingsFile = userSettingsFile.getCanonicalFile();
143160 }
144161 catch ( IOException e )
145162 {
157174 {
158175 try
159176 {
160 File canSet = globalSettingsFile.getCanonicalFile();
161 globalSettingsFile = canSet;
177 globalSettingsFile = globalSettingsFile.getCanonicalFile();
162178 }
163179 catch ( IOException e )
164180 {
172188
173189 }
174190
191 /**
192 * <p>setToolchainsLocation.</p>
193 *
194 * @param request a {@link org.apache.maven.shared.invoker.InvocationRequest} object.
195 * @param cli a {@link org.apache.maven.shared.utils.cli.Commandline} object.
196 */
175197 protected void setToolchainsLocation( InvocationRequest request, Commandline cli )
176198 {
177199 File toolchainsFile = request.getToolchainsFile();
180202 {
181203 try
182204 {
183 File canSet = toolchainsFile.getCanonicalFile();
184 toolchainsFile = canSet;
205 toolchainsFile = toolchainsFile.getCanonicalFile();
185206 }
186207 catch ( IOException e )
187208 {
194215 }
195216 }
196217
218 /**
219 * <p>setShellEnvironment.</p>
220 *
221 * @param request a {@link org.apache.maven.shared.invoker.InvocationRequest} object.
222 * @param cli a {@link org.apache.maven.shared.utils.cli.Commandline} object.
223 * @throws org.apache.maven.shared.invoker.CommandLineConfigurationException if any.
224 */
197225 protected void setShellEnvironment( InvocationRequest request, Commandline cli )
198226 throws CommandLineConfigurationException
199227 {
207235 // proper value
208236 cli.addEnvironment( "M2_HOME", getMavenHome().getAbsolutePath() );
209237 }
210 catch ( IOException e )
211 {
212 throw new CommandLineConfigurationException( "Error reading shell environment variables. Reason: "
213 + e.getMessage(), e );
238 catch ( RuntimeException e )
239 {
240 throw e;
214241 }
215242 catch ( Exception e )
216243 {
217 if ( e instanceof RuntimeException )
218 {
219 throw (RuntimeException) e;
220 }
221 else
222 {
223 IllegalStateException error =
224 new IllegalStateException( "Unknown error retrieving shell environment variables. Reason: "
225 + e.getMessage() );
226 error.initCause( e );
227
228 throw error;
229 }
244 throw new IllegalStateException(
245 "Unknown error retrieving shell environment variables. Reason: " + e.getMessage(), e );
230246 }
231247 }
232248
246262 }
247263 }
248264
265 /**
266 * <p>setProfiles.</p>
267 *
268 * @param request a {@link org.apache.maven.shared.invoker.InvocationRequest} object.
269 * @param cli a {@link org.apache.maven.shared.utils.cli.Commandline} object.
270 */
249271 protected void setProfiles( InvocationRequest request, Commandline cli )
250272 {
251273 List<String> profiles = request.getProfiles();
258280
259281 }
260282
261 protected void setGoals( InvocationRequest request, Commandline cli )
283 /**
284 * <p>setGoals.</p>
285 *
286 * @param request a {@link org.apache.maven.shared.invoker.InvocationRequest} object.
287 * @param cli a {@link org.apache.maven.shared.utils.cli.Commandline} object.
288 * @throws org.apache.maven.shared.invoker.CommandLineConfigurationException if any.
289 */
290 protected void setGoals( InvocationRequest request, Commandline cli ) throws CommandLineConfigurationException
262291 {
263292 List<String> goals = request.getGoals();
264293
265294 if ( ( goals != null ) && !goals.isEmpty() )
266295 {
267 cli.createArg().setLine( StringUtils.join( goals.iterator(), " " ) );
268 }
269 }
270
296 try
297 {
298 cli.createArg().setLine( StringUtils.join( goals.iterator(), " " ) );
299 }
300 catch ( CommandLineException e )
301 {
302 throw new CommandLineConfigurationException( "Problem to set goals: " + e.getMessage(), e );
303 }
304 }
305 }
306
307 /**
308 * <p>setProperties.</p>
309 *
310 * @param request a {@link org.apache.maven.shared.invoker.InvocationRequest} object.
311 * @param cli a {@link org.apache.maven.shared.utils.cli.Commandline} object.
312 */
271313 protected void setProperties( InvocationRequest request, Commandline cli )
272314 {
273315 Properties properties = request.getProperties();
274316
275317 if ( properties != null )
276318 {
277 for ( Iterator<Entry<Object, Object>> it = properties.entrySet().iterator(); it.hasNext(); )
278 {
279 Entry<Object, Object> entry = it.next();
280
319 for ( Entry<Object, Object> entry : properties.entrySet() )
320 {
281321 String key = (String) entry.getKey();
282322 String value = (String) entry.getValue();
283323
287327 }
288328 }
289329
330 /**
331 * <p>setPomLocation.</p>
332 *
333 * @param request a {@link org.apache.maven.shared.invoker.InvocationRequest} object.
334 * @param cli a {@link org.apache.maven.shared.utils.cli.Commandline} object.
335 */
290336 protected void setPomLocation( InvocationRequest request, Commandline cli )
291337 {
292338 boolean pomSpecified = false;
328374 {
329375 try
330376 {
331 File canPom = pom.getCanonicalFile();
332 pom = canPom;
377 pom = pom.getCanonicalFile();
333378 }
334379 catch ( IOException e )
335380 {
338383
339384 if ( !"pom.xml".equals( pom.getName() ) )
340385 {
341 logger.debug( "Specified POM file is not named \'pom.xml\'. "
342 + "Using the \'-f\' command-line option to accommodate non-standard filename..." );
386 logger.debug( "Specified POM file is not named 'pom.xml'. "
387 + "Using the '-f' command-line option to accommodate non-standard filename..." );
343388
344389 cli.createArg().setValue( "-f" );
345390 cli.createArg().setValue( pom.getName() );
347392 }
348393 }
349394
395 /**
396 * <p>setEnvironmentPaths.</p>
397 *
398 * @param request a {@link org.apache.maven.shared.invoker.InvocationRequest} object.
399 * @param cli a {@link org.apache.maven.shared.utils.cli.Commandline} object.
400 */
350401 protected void setEnvironmentPaths( InvocationRequest request, Commandline cli )
351402 {
352403 File workingDirectory = request.getBaseDirectory();
394445 {
395446 try
396447 {
397 File canLRD = localRepositoryDirectory.getCanonicalFile();
398 localRepositoryDirectory = canLRD;
448 localRepositoryDirectory = localRepositoryDirectory.getCanonicalFile();
399449 }
400450 catch ( IOException e )
401451 {
405455
406456 if ( !localRepositoryDirectory.isDirectory() )
407457 {
408 throw new IllegalArgumentException( "Local repository location: \'" + localRepositoryDirectory
409 + "\' is NOT a directory." );
458 throw new IllegalArgumentException( "Local repository location: '" + localRepositoryDirectory
459 + "' is NOT a directory." );
410460 }
411461
412462 cli.createArg().setValue( "-D" );
414464 }
415465 }
416466
467 /**
468 * <p>setReactorBehavior.</p>
469 *
470 * @param request a {@link org.apache.maven.shared.invoker.InvocationRequest} object.
471 * @param cli a {@link org.apache.maven.shared.utils.cli.Commandline} object.
472 */
417473 protected void setReactorBehavior( InvocationRequest request, Commandline cli )
418474 {
419475 // NOTE: The default is "fail-fast"
456512 }
457513 }
458514
515 /**
516 * <p>setFlags.</p>
517 *
518 * @param request a {@link org.apache.maven.shared.invoker.InvocationRequest} object.
519 * @param cli a {@link org.apache.maven.shared.utils.cli.Commandline} object.
520 */
459521 protected void setFlags( InvocationRequest request, Commandline cli )
460522 {
461523 if ( request.isBatchMode() )
512574 {
513575 cli.createArg().setValue( request.getBuilder() );
514576 }
515 }
516
577
578 if ( request.isQuiet() )
579 {
580 cli.createArg().setValue( "-q" );
581 }
582 }
583
584 /**
585 * <p>setThreads.</p>
586 *
587 * @param request a {@link org.apache.maven.shared.invoker.InvocationRequest} object.
588 * @param cli a {@link org.apache.maven.shared.utils.cli.Commandline} object.
589 */
517590 protected void setThreads( InvocationRequest request, Commandline cli )
518591 {
519592 String threads = request.getThreads();
525598
526599 }
527600
601 /**
602 * <p>findMavenExecutable.</p>
603 *
604 * @return a {@link java.io.File} object.
605 * @throws org.apache.maven.shared.invoker.CommandLineConfigurationException if any.
606 * @throws java.io.IOException if any.
607 */
528608 protected File findMavenExecutable()
529609 throws CommandLineConfigurationException, IOException
530610 {
545625 }
546626 else
547627 {
548 throw new IllegalStateException( "${maven.home} is not specified as a directory: \'"
549 + mavenHomeProperty + "\'." );
628 throw new IllegalStateException( "${maven.home} is not specified as a directory: '"
629 + mavenHomeProperty + "'." );
550630 }
551631 }
552632 }
557637 }
558638 }
559639
560 logger.debug( "Using ${maven.home} of: \'" + mavenHome + "\'." );
640 logger.debug( "Using ${maven.home} of: '" + mavenHome + "'." );
561641
562642 if ( mavenExecutable == null || !mavenExecutable.isAbsolute() )
563643 {
586666
587667 try
588668 {
589 File canonicalMvn = mavenExecutable.getCanonicalFile();
590 mavenExecutable = canonicalMvn;
669 mavenExecutable = mavenExecutable.getCanonicalFile();
591670 }
592671 catch ( IOException e )
593672 {
604683 }
605684
606685 private Properties getSystemEnvVars()
607 throws IOException
608686 {
609687 if ( this.systemEnvVars == null )
610688 {
614692 return this.systemEnvVars;
615693 }
616694
695 /**
696 * <p>Getter for the field <code>localRepositoryDirectory</code>.</p>
697 *
698 * @return a {@link java.io.File} object.
699 */
617700 public File getLocalRepositoryDirectory()
618701 {
619702 return localRepositoryDirectory;
620703 }
621704
705 /**
706 * <p>Setter for the field <code>localRepositoryDirectory</code>.</p>
707 *
708 * @param localRepositoryDirectory a {@link java.io.File} object.
709 */
622710 public void setLocalRepositoryDirectory( File localRepositoryDirectory )
623711 {
624712 this.localRepositoryDirectory = localRepositoryDirectory;
625713 }
626714
715 /**
716 * <p>Getter for the field <code>logger</code>.</p>
717 *
718 * @return a {@link org.apache.maven.shared.invoker.InvokerLogger} object.
719 */
627720 public InvokerLogger getLogger()
628721 {
629722 return logger;
630723 }
631724
725 /**
726 * <p>Setter for the field <code>logger</code>.</p>
727 *
728 * @param logger a {@link org.apache.maven.shared.invoker.InvokerLogger} object.
729 */
632730 public void setLogger( InvokerLogger logger )
633731 {
634732 this.logger = logger;
635733 }
636734
735 /**
736 * <p>Getter for the field <code>mavenHome</code>.</p>
737 *
738 * @return a {@link java.io.File} object.
739 */
637740 public File getMavenHome()
638741 {
639742 return mavenHome;
640743 }
641744
745 /**
746 * <p>Setter for the field <code>mavenHome</code>.</p>
747 *
748 * @param mavenHome a {@link java.io.File} object.
749 */
642750 public void setMavenHome( File mavenHome )
643751 {
644752 this.mavenHome = mavenHome;
645753 }
646754
755 /**
756 * <p>Getter for the field <code>workingDirectory</code>.</p>
757 *
758 * @return a {@link java.io.File} object.
759 */
647760 public File getWorkingDirectory()
648761 {
649762 return workingDirectory;
650763 }
651764
765 /**
766 * <p>Setter for the field <code>workingDirectory</code>.</p>
767 *
768 * @param workingDirectory a {@link java.io.File} object.
769 */
652770 public void setWorkingDirectory( File workingDirectory )
653771 {
654772 this.workingDirectory = workingDirectory;
656774
657775 /**
658776 * {@code mavenExecutable} can either be relative to ${maven.home}/bin/ or absolute
659 *
777 *
660778 * @param mavenExecutable the executable
661779 */
662780 public void setMavenExecutable( File mavenExecutable )
664782 this.mavenExecutable = mavenExecutable;
665783 }
666784
785 /**
786 * <p>Getter for the field <code>mavenExecutable</code>.</p>
787 *
788 * @return a {@link java.io.File} object.
789 */
667790 public File getMavenExecutable()
668791 {
669792 return mavenExecutable;
2222 * Signals an error during the construction of the command line used to invoke Maven, e.g. illegal invocation arguments.
2323 * This should not be confused with a failure of the invoked Maven build itself which will be reported by means of a
2424 * non-zero exit code.
25 *
25 *
2626 * @see InvocationResult#getExitCode()
27 * @version $Id: MavenInvocationException.java 662043 2008-05-31 16:27:02Z bentmann $
2827 */
2928 public class MavenInvocationException
3029 extends Exception
3433
3534 /**
3635 * Creates a new exception using the specified detail message and cause.
37 *
36 *
3837 * @param message The detail message for this exception, may be <code>null</code>.
3938 * @param cause The nested exception, may be <code>null</code>.
4039 */
4544
4645 /**
4746 * Creates a new exception using the specified detail message.
48 *
47 *
4948 * @param message The detail message for this exception, may be <code>null</code>.
5049 */
5150 public MavenInvocationException( String message )
2121 import java.io.PrintStream;
2222
2323 /**
24 * Offers an output handler that writes to a print stream like {@link System#out}.
25 *
26 * @version $Id: PrintStreamHandler.java 681956 2008-08-02 11:43:44Z dennisl $
24 * Offers an output handler that writes to a print stream like {@link java.lang.System#out}.
25 *
2726 * @since 2.0.9
2827 */
2928 public class PrintStreamHandler
4140 private boolean alwaysFlush;
4241
4342 /**
44 * Creates a new output handler that writes to {@link System#out}.
43 * Creates a new output handler that writes to {@link java.lang.System#out}.
4544 */
4645 public PrintStreamHandler()
4746 {
5049
5150 /**
5251 * Creates a new output handler that writes to the specified print stream.
53 *
52 *
5453 * @param out The print stream to write to, must not be <code>null</code>.
5554 * @param alwaysFlush A flag whether the print stream should be flushed after each line.
5655 */
6463 this.alwaysFlush = alwaysFlush;
6564 }
6665
66 /** {@inheritDoc} */
6767 public void consumeLine( String line )
6868 {
6969 if ( line == null )
2323 import java.io.StringWriter;
2424
2525 /**
26 * Offers a logger that writes to a print stream like {@link System#out}.
27 *
28 * @version $Id: PrintStreamLogger.java 1635406 2014-10-30 06:51:13Z hboutemy $
26 * Offers a logger that writes to a print stream like {@link java.lang.System#out}.
27 *
2928 * @since 2.0.9
3029 */
3130 public class PrintStreamLogger
4342 private int threshold;
4443
4544 /**
46 * Creates a new logger that writes to {@link System#out} and has a threshold of {@link #INFO}.
45 * Creates a new logger that writes to {@link java.lang.System#out} and has a threshold of {@link #INFO}.
4746 */
4847 public PrintStreamLogger()
4948 {
5251
5352 /**
5453 * Creates a new logger that writes to the specified print stream.
55 *
54 *
5655 * @param out The print stream to write to, must not be <code>null</code>.
5756 * @param threshold The threshold for the logger.
5857 */
8786 return;
8887 }
8988
90 StringBuffer buffer = new StringBuffer();
89 StringBuilder buffer = new StringBuilder();
9190
9291 switch ( level )
9392 {
140139 out.println( buffer.toString() );
141140 }
142141
142 /** {@inheritDoc} */
143143 public void debug( String message )
144144 {
145145 log( DEBUG, message, null );
146146 }
147147
148 /** {@inheritDoc} */
148149 public void debug( String message, Throwable throwable )
149150 {
150151 log( DEBUG, message, throwable );
151152 }
152153
154 /** {@inheritDoc} */
153155 public void info( String message )
154156 {
155157 log( INFO, message, null );
156158 }
157159
160 /** {@inheritDoc} */
158161 public void info( String message, Throwable throwable )
159162 {
160163 log( INFO, message, throwable );
161164 }
162165
166 /** {@inheritDoc} */
163167 public void warn( String message )
164168 {
165169 log( WARN, message, null );
166170 }
167171
172 /** {@inheritDoc} */
168173 public void warn( String message, Throwable throwable )
169174 {
170175 log( WARN, message, throwable );
171176 }
172177
178 /** {@inheritDoc} */
173179 public void error( String message )
174180 {
175181 log( ERROR, message, null );
176182 }
177183
184 /** {@inheritDoc} */
178185 public void error( String message, Throwable throwable )
179186 {
180187 log( ERROR, message, throwable );
181188 }
182189
190 /** {@inheritDoc} */
183191 public void fatalError( String message )
184192 {
185193 log( FATAL, message, null );
186194 }
187195
196 /** {@inheritDoc} */
188197 public void fatalError( String message, Throwable throwable )
189198 {
190199 log( FATAL, message, throwable );
191200 }
192201
202 /**
203 * <p>isDebugEnabled.</p>
204 *
205 * @return a boolean.
206 */
193207 public boolean isDebugEnabled()
194208 {
195209 return threshold >= DEBUG;
196210 }
197211
212 /**
213 * <p>isErrorEnabled.</p>
214 *
215 * @return a boolean.
216 */
198217 public boolean isErrorEnabled()
199218 {
200219 return threshold >= ERROR;
201220 }
202221
222 /**
223 * <p>isFatalErrorEnabled.</p>
224 *
225 * @return a boolean.
226 */
203227 public boolean isFatalErrorEnabled()
204228 {
205229 return threshold >= FATAL;
206230 }
207231
232 /**
233 * <p>isInfoEnabled.</p>
234 *
235 * @return a boolean.
236 */
208237 public boolean isInfoEnabled()
209238 {
210239 return threshold >= INFO;
211240 }
212241
242 /**
243 * <p>isWarnEnabled.</p>
244 *
245 * @return a boolean.
246 */
213247 public boolean isWarnEnabled()
214248 {
215249 return threshold >= WARN;
216250 }
217251
252 /**
253 * <p>Getter for the field <code>threshold</code>.</p>
254 *
255 * @return a int.
256 */
218257 public int getThreshold()
219258 {
220259 return threshold;
221260 }
222261
262 /** {@inheritDoc} */
223263 public void setThreshold( int threshold )
224264 {
225265 this.threshold = threshold;
1919 */
2020
2121 /**
22 * Offers an output handler that writes to {@link System#out}.
23 *
24 * @version $Id: SystemOutHandler.java 661996 2008-05-31 10:50:38Z bentmann $
22 * Offers an output handler that writes to {@link java.lang.System#out}.
23 *
2524 */
2625 public class SystemOutHandler
2726 extends PrintStreamHandler
3736
3837 /**
3938 * Creates a new output handler.
40 *
39 *
4140 * @param alwaysFlush A flag whether the print stream should be flushed after each line.
4241 */
4342 public SystemOutHandler( boolean alwaysFlush )
1919 */
2020
2121 /**
22 * Offers a logger that writes to {@link System#out}.
23 *
24 * @version $Id: SystemOutLogger.java 661996 2008-05-31 10:50:38Z bentmann $
22 * Offers a logger that writes to {@link java.lang.System#out}.
23 *
2524 */
2625 public class SystemOutLogger
2726 extends PrintStreamLogger
140140 <plugin>
141141 <groupId>org.apache.maven.plugins</groupId>
142142 <artifactId>maven-surefire-plugin</artifactId>
143 <version>2.12.4</version> <!-- see surefire-page for available versions -->
143 <version>2.22.2</version> <!-- see surefire-page for available versions -->
144144 <configuration>
145145 <systemPropertyVariables>
146146 <maven.home>${maven.home}</maven.home>
1818 under the License.
1919 -->
2020
21 <project xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd">
22
21 <project xmlns="http://maven.apache.org/DECORATION/1.8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22 xsi:schemaLocation="http://maven.apache.org/DECORATION/1.8.0 https://maven.apache.org/xsd/decoration-1.8.0.xsd">
23 <skin>
24 <groupId>org.apache.maven.skins</groupId>
25 <artifactId>maven-fluido-skin</artifactId>
26 <version>1.9</version>
27 </skin>
2328 <body>
2429 <menu name="Overview">
2530 <item name="Introduction" href="index.html"/>
2833 <item name="Source Xref" href="xref/index.html"/>
2934 <!--item name="FAQ" href="faq.html"/-->
3035 <!-- According to https://issues.apache.org/jira/browse/MNGSITE-152 -->
31 <item name="License" href="http://www.apache.org/licenses/"/>
36 <item name="License" href="https://www.apache.org/licenses/"/>
3237 <item name="Download" href="download.html"/>
3338 </menu>
3439 </body>
3333
3434 <p>In order to guard against corrupted downloads/installations, it is highly recommended to
3535 <a href="http://www.apache.org/dev/release-signing#verifying-signature">verify the signature</a>
36 of the release bundles against the public <a href="http://www.apache.org/dist/maven/KEYS">KEYS</a> used by the Apache Maven
36 of the release bundles against the public <a href="https://www.apache.org/dist/maven/KEYS">KEYS</a> used by the Apache Maven
3737 developers.</p>
3838
3939 <p>${project.name} is distributed under the <a href="http://www.apache.org/licenses/">Apache License, version 2.0</a>.</p>
107107 <tr>
108108 <td>${project.name} ${project.version} (Source zip)</td>
109109 <td><a href="[preferred]maven/shared/${project.artifactId}-${project.version}-source-release.zip">maven/shared/${project.artifactId}-${project.version}-source-release.zip</a></td>
110 <td><a href="http://www.apache.org/dist/maven/shared/${project.artifactId}-${project.version}-source-release.zip.md5">maven/shared/${project.artifactId}-${project.version}-source-release.zip.md5</a></td>
111 <td><a href="http://www.apache.org/dist/maven/shared/${project.artifactId}-${project.version}-source-release.zip.asc">maven/shared/${project.artifactId}-${project.version}-source-release.zip.asc</a></td>
110 <td><a href="https://www.apache.org/dist/maven/shared/${project.artifactId}-${project.version}-source-release.zip.sha512">maven/shared/${project.artifactId}-${project.version}-source-release.zip.sha512</a></td>
111 <td><a href="https://www.apache.org/dist/maven/shared/${project.artifactId}-${project.version}-source-release.zip.asc">maven/shared/${project.artifactId}-${project.version}-source-release.zip.asc</a></td>
112112 </tr>
113113 </tbody>
114114 </table>
1818 * under the License.
1919 */
2020
21 import static org.junit.Assert.assertEquals;
22
2321 import java.io.File;
2422 import java.io.IOException;
2523 import java.net.URI;
2624 import java.net.URISyntaxException;
2725 import java.net.URL;
28 import java.util.ArrayList;
29 import java.util.List;
26 import java.util.Arrays;
27 import java.util.Collections;
3028 import java.util.Properties;
3129
32 import org.codehaus.plexus.util.StringUtils;
33 import org.codehaus.plexus.util.cli.CommandLineUtils;
30 import org.apache.maven.shared.utils.StringUtils;
31 import org.apache.maven.shared.utils.cli.CommandLineUtils;
3432 import org.junit.Test;
33
34 import static org.junit.Assert.assertEquals;
3535
3636 public class DefaultInvokerTest
3737 {
4646
4747 InvocationRequest request = new DefaultInvocationRequest();
4848 request.setBaseDirectory( basedir );
49
50 request.setDebug( true );
51
52 List<String> goals = new ArrayList<String>();
53 goals.add( "clean" );
54 goals.add( "package" );
55
56 request.setGoals( goals );
49 request.setDebug( true );
50 request.setGoals( Arrays.asList( "clean", "package" ) );
51 request.setProperties( getProperties() );
5752
5853 InvocationResult result = invoker.execute( request );
5954
7065
7166 InvocationRequest request = new DefaultInvocationRequest();
7267 request.setBaseDirectory( basedir );
73
74 request.setDebug( true );
75
76 List<String> goals = new ArrayList<String>();
77 goals.add( "clean" );
78 goals.add( "package" );
79
80 request.setGoals( goals );
68 request.setDebug( true );
69 request.setGoals( Arrays.asList( "clean", "package" ) );
70 request.setProperties( getProperties() );
8171
8272 InvocationResult result = invoker.execute( request );
8373
8575 }
8676
8777 @Test
78 public void testBuildShouldTimeout()
79 throws IOException, MavenInvocationException, URISyntaxException
80 {
81 File basedir = getBasedirForBuild();
82
83 Invoker invoker = newInvoker();
84
85 InvocationRequest request = new DefaultInvocationRequest();
86 request.setBaseDirectory( basedir );
87 request.setDebug( true );
88 request.setGoals( Arrays.asList( "clean", "package" ) );
89 request.setTimeoutInSeconds( 4 );
90 request.setProperties( getProperties() );
91
92 InvocationResult result = invoker.execute( request );
93
94 // We check the exception to be sure the failure is based on timeout.
95 assertEquals( "Error while executing external command, process killed.",
96 result.getExecutionException().getMessage() );
97
98 // WARN - Windows issue MSHARED-867 - Maven and child surefire test process stays alive on Windows
99 // workaround implemented in this test to timeout test after 15 sec
100 // please also check timeout logic in maven-shared-utils
101
102 // exitCode can't be used cause in case of an timeout it's not correctly
103 // set in DefaultInvoker. Need to think about this.
104 // assertEquals( 1, result.getExitCode() );
105 }
106
107 @Test
88108 public void testSpacePom()
89109 throws Exception
90110 {
96116
97117 InvocationRequest request = new DefaultInvocationRequest();
98118 request.setBaseDirectory( basedir );
99
100119 request.setPomFileName( "pom with spaces.xml" );
101
102 request.setDebug( true );
103
104 List<String> goals = new ArrayList<String>();
105 goals.add( "clean" );
106
107 request.setGoals( goals );
108
120 request.setDebug( true );
121 request.setGoals( Collections.singletonList( "clean" ) );
122 request.setProperties( getProperties() );
123
109124 InvocationResult result = invoker.execute( request );
110125
111126 assertEquals( 0, result.getExitCode() );
123138
124139 InvocationRequest request = new DefaultInvocationRequest();
125140 request.setBaseDirectory( basedir );
126
127141 request.setPomFileName( "pom with spaces & special char.xml" );
128
129 request.setDebug( true );
130
131 List<String> goals = new ArrayList<String>();
132 goals.add( "clean" );
133
134 request.setGoals( goals );
142 request.setDebug( true );
143 request.setGoals( Collections.singletonList( "clean" ) );
144 request.setProperties( getProperties() );
135145
136146 InvocationResult result = invoker.execute( request );
137147
150160
151161 InvocationRequest request = new DefaultInvocationRequest();
152162 request.setBaseDirectory( basedir );
153
154163 request.setUserSettingsFile( new File( basedir, "settings with spaces.xml" ) );
155
156 request.setDebug( true );
157
158 List<String> goals = new ArrayList<String>();
159 goals.add( "validate" );
160
161 request.setGoals( goals );
164 request.setDebug( true );
165 request.setGoals( Collections.singletonList( "validate" ) );
166 request.setProperties( getProperties() );
162167
163168 InvocationResult result = invoker.execute( request );
164169
177182
178183 InvocationRequest request = new DefaultInvocationRequest();
179184 request.setBaseDirectory( basedir );
180
181185 request.setLocalRepositoryDirectory( new File( basedir, "repo with spaces" ) );
182
183 request.setDebug( true );
184
185 List<String> goals = new ArrayList<String>();
186 goals.add( "validate" );
187
188 request.setGoals( goals );
186 request.setDebug( true );
187 request.setGoals( Collections.singletonList( "validate" ) );
188 request.setProperties( getProperties() );
189189
190190 InvocationResult result = invoker.execute( request );
191191
205205 InvocationRequest request = new DefaultInvocationRequest();
206206 request.setBaseDirectory( basedir );
207207
208 Properties props = new Properties();
208 Properties props = getProperties();
209209 props.setProperty( "key", "value with spaces" );
210210 props.setProperty( "key with spaces", "value" );
211211 request.setProperties( props );
212
213 request.setDebug( true );
214
215 List<String> goals = new ArrayList<String>();
216 goals.add( "validate" );
217
218 request.setGoals( goals );
212 request.setDebug( true );
213 request.setGoals( Collections.singletonList( "validate" ) );
219214
220215 InvocationResult result = invoker.execute( request );
221216
223218 }
224219
225220 private Invoker newInvoker()
226 throws IOException
227221 {
228222 Invoker invoker = new DefaultInvoker();
229223
239233 }
240234
241235 private File findMavenHome()
242 throws IOException
243236 {
244237 String mavenHome = System.getProperty( "maven.home" );
245238
251244 if ( mavenHome == null )
252245 {
253246 throw new IllegalStateException( "Cannot find Maven application "
254 + "directory. Either specify \'maven.home\' system property, or M2_HOME environment variable." );
247 + "directory. Either specify 'maven.home' system property, or M2_HOME environment variable." );
255248 }
256249
257250 return new File( mavenHome );
282275
283276 if ( dirResource == null )
284277 {
285 throw new IllegalStateException( "Project: " + dirName + " for test method: " + methodName + " is missing." );
278 throw new IllegalStateException( "Project: " + dirName + " for test method: " + methodName
279 + " is missing." );
286280 }
287281
288282 return new File( new URI( dirResource.toString() ).getPath() );
296290
297291 System.out.println( "Starting: " + element.getMethodName() );
298292 }
299
293
294 private Properties getProperties()
295 {
296 Properties properties = new Properties();
297 if ( !System.getProperty( "java.version" ).startsWith( "1." ) )
298 {
299 properties.put( "maven.compiler.source", "1.7" );
300 properties.put( "maven.compiler.target", "1.7" );
301 }
302
303 String httpProtocols = System.getProperty( "https.protocols" );
304 if ( httpProtocols != null )
305 {
306 properties.put( "https.protocols", httpProtocols );
307 }
308 return properties;
309 }
300310 }
1818 * under the License.
1919 */
2020
21 import static org.junit.Assert.assertEquals;
22 import static org.junit.Assert.assertFalse;
23 import static org.junit.Assert.assertTrue;
24 import static org.junit.Assert.fail;
25
2621 import java.io.File;
2722 import java.io.FileWriter;
2823 import java.io.IOException;
3429 import java.util.Properties;
3530 import java.util.Set;
3631
37 import org.codehaus.plexus.util.FileUtils;
38 import org.codehaus.plexus.util.IOUtil;
39 import org.codehaus.plexus.util.Os;
40 import org.codehaus.plexus.util.cli.CommandLineException;
41 import org.codehaus.plexus.util.cli.Commandline;
32 import org.apache.maven.shared.utils.Os;
33 import org.apache.maven.shared.utils.cli.Commandline;
4234 import org.junit.After;
4335 import org.junit.Assume;
4436 import org.junit.Before;
37 import org.junit.Rule;
4538 import org.junit.Test;
39 import org.junit.rules.TemporaryFolder;
40
41 import static org.hamcrest.CoreMatchers.is;
42 import static org.hamcrest.CoreMatchers.notNullValue;
43 import static org.junit.Assert.assertEquals;
44 import static org.junit.Assert.assertFalse;
45 import static org.junit.Assert.assertTrue;
46 import static org.junit.Assert.fail;
47 import static org.junit.Assume.assumeThat;
4648
4749 public class MavenCommandLineBuilderTest
4850 {
49
50 private List<File> toDelete = new ArrayList<File>();
51 @Rule
52 public TemporaryFolder temporaryFolder = new TemporaryFolder();
5153
5254 private Properties sysProps;
53
55 private File lrd;
56 private TestCommandLineBuilder tcb = new TestCommandLineBuilder();
57 private Commandline cli = new Commandline();
58
59 @Before
60 public void setUp() throws IOException
61 {
62 sysProps = System.getProperties();
63 Properties p = new Properties( sysProps );
64
65 System.setProperties( p );
66
67 lrd = temporaryFolder.newFile();
68
69 }
70
71 @After
72 public void tearDown()
73 {
74 System.setProperties( sysProps );
75 }
76
77
5478 @Test
5579 public void testShouldFailToSetLocalRepoLocationGloballyWhenItIsAFile()
56 throws IOException
57 {
58 logTestStart();
59
60 File lrd = File.createTempFile( "workdir-test", "file" ).getCanonicalFile();
61
62 toDelete.add( lrd );
63
64 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
80 {
81
6582 tcb.setLocalRepositoryDirectory( lrd );
66
67 Commandline cli = new Commandline();
6883
6984 try
7085 {
7186 tcb.setEnvironmentPaths( newRequest(), cli );
7287 fail( "Should not set local repo location to point to a file." );
7388 }
74 catch ( IllegalArgumentException e )
75 {
76 assertTrue( true );
89 catch ( IllegalArgumentException expected )
90 {
7791 }
7892 }
7993
8094 @Test
8195 public void testShouldFailToSetLocalRepoLocationFromRequestWhenItIsAFile()
82 throws IOException
83 {
84 logTestStart();
85
86 File lrd = File.createTempFile( "workdir-test", "file" ).getCanonicalFile();
87
88 toDelete.add( lrd );
89
90 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
91
92 Commandline cli = new Commandline();
93
96 {
9497 try
9598 {
9699 tcb.setEnvironmentPaths( newRequest().setLocalRepositoryDirectory( lrd ), cli );
97100 fail( "Should not set local repo location to point to a file." );
98101 }
99 catch ( IllegalArgumentException e )
100 {
101 assertTrue( true );
102 }
103 }
104
105 @Test
106 public void testShouldSetLocalRepoLocationGlobally()
107 throws Exception
108 {
109 logTestStart();
110
111 File tmpDir = getTempDir();
112
113 File lrd = new File( tmpDir, "workdir" ).getCanonicalFile();
114
115 lrd.mkdirs();
116 toDelete.add( lrd );
117
118 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
102 catch ( IllegalArgumentException expected )
103 {
104 }
105 }
106
107 @Test
108 public void testShouldSetLocalRepoLocationGlobally() throws IOException
109 {
110 File lrd = temporaryFolder.newFolder( "workdir" ).getCanonicalFile();
119111 tcb.setLocalRepositoryDirectory( lrd );
120
121 Commandline cli = new Commandline();
122
123112 tcb.setEnvironmentPaths( newRequest(), cli );
124113
125114 assertArgumentsPresentInOrder( cli, "-D", "maven.repo.local=" + lrd.getPath() );
129118 public void testShouldSetLocalRepoLocationFromRequest()
130119 throws Exception
131120 {
132 logTestStart();
133
134 File tmpDir = getTempDir();
135
136 File lrd = new File( tmpDir, "workdir" ).getCanonicalFile();
137
138 lrd.mkdirs();
139 toDelete.add( lrd );
140
141 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
142
143 Commandline cli = new Commandline();
144
121 File lrd = temporaryFolder.newFolder( "workdir" ).getCanonicalFile();
145122 tcb.setEnvironmentPaths( newRequest().setLocalRepositoryDirectory( lrd ), cli );
146123
147124 assertArgumentsPresentInOrder( cli, "-D", "maven.repo.local=" + lrd.getPath() );
151128 public void testRequestProvidedLocalRepoLocationShouldOverrideGlobal()
152129 throws Exception
153130 {
154 logTestStart();
155
156 File tmpDir = getTempDir();
157
158 File lrd = new File( tmpDir, "workdir" ).getCanonicalFile();
159 File glrd = new File( tmpDir, "global-workdir" ).getCanonicalFile();
160
161 lrd.mkdirs();
162 glrd.mkdirs();
163
164 toDelete.add( lrd );
165 toDelete.add( glrd );
166
167 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
131 File lrd = temporaryFolder.newFolder( "workdir" ).getCanonicalFile();
132 File glrd = temporaryFolder.newFolder( "global-workdir" ).getCanonicalFile();
133
168134 tcb.setLocalRepositoryDirectory( glrd );
169
170 Commandline cli = new Commandline();
171
172135 tcb.setEnvironmentPaths( newRequest().setLocalRepositoryDirectory( lrd ), cli );
173136
174137 assertArgumentsPresentInOrder( cli, "-D", "maven.repo.local=" + lrd.getPath() );
178141 public void testShouldSetWorkingDirectoryGlobally()
179142 throws Exception
180143 {
181 logTestStart();
182
183 File tmpDir = getTempDir();
184
185 File wd = new File( tmpDir, "workdir" );
186
187 wd.mkdirs();
188
189 toDelete.add( wd );
190
191 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
144 File wd = temporaryFolder.newFolder( "workdir" );
192145 tcb.setWorkingDirectory( wd );
193
194 Commandline cli = new Commandline();
195
196146 tcb.setEnvironmentPaths( newRequest(), cli );
197147
198 assertEquals( cli.getWorkingDirectory(), wd );
148 assertEquals( cli.getWorkingDirectory(), wd.getCanonicalFile() );
199149 }
200150
201151 @Test
202152 public void testShouldSetWorkingDirectoryFromRequest()
203153 throws Exception
204154 {
205 logTestStart();
206
207 File tmpDir = getTempDir();
208
209 File wd = new File( tmpDir, "workdir" );
210
211 wd.mkdirs();
212
213 toDelete.add( wd );
214
215 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
155 File wd = temporaryFolder.newFolder( "workdir" );
156
216157 InvocationRequest req = newRequest();
217158 req.setBaseDirectory( wd );
218159
219 Commandline cli = new Commandline();
220160
221161 tcb.setEnvironmentPaths( req, cli );
222162
223 assertEquals( cli.getWorkingDirectory(), wd );
163 assertEquals( cli.getWorkingDirectory(), wd.getCanonicalFile() );
224164 }
225165
226166 @Test
227167 public void testRequestProvidedWorkingDirectoryShouldOverrideGlobal()
228168 throws Exception
229169 {
230 logTestStart();
231
232 File tmpDir = getTempDir();
233
234 File wd = new File( tmpDir, "workdir" );
235 File gwd = new File( tmpDir, "global-workdir" );
236
237 wd.mkdirs();
238 gwd.mkdirs();
239
240 toDelete.add( wd );
241 toDelete.add( gwd );
242
243 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
170 File wd = temporaryFolder.newFolder( "workdir" );
171 File gwd = temporaryFolder.newFolder( "global-workdir" );
172
244173 tcb.setWorkingDirectory( gwd );
245174
246175 InvocationRequest req = newRequest();
247176 req.setBaseDirectory( wd );
248177
249 Commandline cli = new Commandline();
250178
251179 tcb.setEnvironmentPaths( req, cli );
252180
253 assertEquals( cli.getWorkingDirectory(), wd );
181 assertEquals( cli.getWorkingDirectory(), wd.getCanonicalFile() );
254182 }
255183
256184 @Test
257185 public void testShouldUseSystemOutLoggerWhenNoneSpecified()
258186 throws Exception
259187 {
260 logTestStart();
261188 setupTempMavenHomeIfMissing( false );
262189
263190 TestCommandLineBuilder tclb = new TestCommandLineBuilder();
269196 {
270197 String mavenHome = System.getProperty( "maven.home" );
271198
272 File appDir = null;
199 File appDir;
273200
274201 if ( forceDummy || ( mavenHome == null ) || !new File( mavenHome ).exists() )
275202 {
276 File tmpDir = getTempDir();
277 appDir = new File( tmpDir, "invoker-tests/maven-home" );
203 appDir = temporaryFolder.newFolder( "invoker-tests", "maven-home" );
278204
279205 File binDir = new File( appDir, "bin" );
280
281206 binDir.mkdirs();
282 toDelete.add( appDir );
283207
284208 if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
285209 {
304228 }
305229
306230 @Test
307 public void testShouldFailIfLoggerSetToNull()
308 {
309 logTestStart();
310
231 public void testShouldFailIfLoggerSetToNull() throws Exception
232 {
311233 TestCommandLineBuilder tclb = new TestCommandLineBuilder();
312234 tclb.setLogger( null );
313235
316238 tclb.checkRequiredState();
317239 fail( "Should not allow execution to proceed when logger is missing." );
318240 }
319 catch ( IllegalStateException e )
320 {
321 assertTrue( true );
322 }
323 catch ( IOException e )
324 {
325 fail( e.getMessage() );
241 catch ( IllegalStateException expected )
242 {
326243 }
327244 }
328245
330247 public void testShouldFindDummyMavenExecutable()
331248 throws Exception
332249 {
333 logTestStart();
334
335 File tmpDir = getTempDir();
336
337 File base = new File( tmpDir, "invoker-tests" );
338
339 File dummyMavenHomeBin = new File( base, "dummy-maven-home/bin" );
340
341 dummyMavenHomeBin.mkdirs();
342
343 toDelete.add( base );
250 File dummyMavenHomeBin = temporaryFolder.newFolder( "invoker-tests", "dummy-maven-home", "bin" );
344251
345252 File check;
346253 if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
352259 check = createDummyFile( dummyMavenHomeBin, "mvn" );
353260 }
354261
355 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
356262 tcb.setMavenHome( dummyMavenHomeBin.getParentFile() );
357263
358264 File mavenExe = tcb.findMavenExecutable();
363269 @Test
364270 public void testShouldSetBatchModeFlagFromRequest()
365271 {
366 logTestStart();
367
368 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
369 Commandline cli = new Commandline();
370272
371273 tcb.setFlags( newRequest().setBatchMode( true ), cli );
372274
376278 @Test
377279 public void testShouldSetOfflineFlagFromRequest()
378280 {
379 logTestStart();
380
381 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
382 Commandline cli = new Commandline();
383281
384282 tcb.setFlags( newRequest().setOffline( true ), cli );
385283
389287 @Test
390288 public void testShouldSetUpdateSnapshotsFlagFromRequest()
391289 {
392 logTestStart();
393
394 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
395 Commandline cli = new Commandline();
396290
397291 tcb.setFlags( newRequest().setUpdateSnapshots( true ), cli );
398292
402296 @Test
403297 public void testShouldSetDebugFlagFromRequest()
404298 {
405 logTestStart();
406
407 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
408 Commandline cli = new Commandline();
409299
410300 tcb.setFlags( newRequest().setDebug( true ), cli );
411301
415305 @Test
416306 public void testShouldSetErrorFlagFromRequest()
417307 {
418 logTestStart();
419
420 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
421 Commandline cli = new Commandline();
422308
423309 tcb.setFlags( newRequest().setShowErrors( true ), cli );
424310
426312 }
427313
428314 @Test
315 public void testShouldSetQuietFlagFromRequest()
316 {
317
318 tcb.setFlags( newRequest().setQuiet( true ), cli );
319
320 assertArgumentsPresent( cli, Collections.singleton( "-q" ));
321 }
322
323 @Test
429324 public void testDebugOptionShouldMaskShowErrorsOption()
430325 {
431 logTestStart();
432
433 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
434 Commandline cli = new Commandline();
435326
436327 tcb.setFlags( newRequest().setDebug( true ).setShowErrors( true ), cli );
437328
442333 @Test
443334 public void testAlsoMake()
444335 {
445 logTestStart();
446
447 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
448 Commandline cli = new Commandline();
449336
450337 tcb.setReactorBehavior( newRequest().setAlsoMake( true ), cli );
451338
456343 @Test
457344 public void testProjectsAndAlsoMake()
458345 {
459 logTestStart();
460
461 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
462 Commandline cli = new Commandline();
463346
464347 tcb.setReactorBehavior( newRequest().setProjects( Collections.singletonList( "proj1" ) ).setAlsoMake( true ),
465348 cli );
470353 @Test
471354 public void testAlsoMakeDependents()
472355 {
473 logTestStart();
474
475 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
476 Commandline cli = new Commandline();
477356
478357 tcb.setReactorBehavior( newRequest().setAlsoMakeDependents( true ), cli );
479358
484363 @Test
485364 public void testProjectsAndAlsoMakeDependents()
486365 {
487 logTestStart();
488
489 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
490 Commandline cli = new Commandline();
491366
492367 tcb.setReactorBehavior( newRequest().setProjects( Collections.singletonList( "proj1" ) ).setAlsoMakeDependents( true ),
493368 cli );
498373 @Test
499374 public void testProjectsAndAlsoMakeAndAlsoMakeDependents()
500375 {
501 logTestStart();
502
503 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
504 Commandline cli = new Commandline();
505376
506377 tcb.setReactorBehavior( newRequest().setProjects( Collections.singletonList( "proj1" ) ).setAlsoMake( true ).setAlsoMakeDependents( true ),
507378 cli );
512383 @Test
513384 public void testShouldSetResumeFrom()
514385 {
515 logTestStart();
516
517 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
518 Commandline cli = new Commandline();
519386
520387 tcb.setReactorBehavior( newRequest().setResumeFrom( ":module3" ), cli );
521388
525392 @Test
526393 public void testShouldSetStrictChecksumPolityFlagFromRequest()
527394 {
528 logTestStart();
529
530 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
531 Commandline cli = new Commandline();
532395
533396 tcb.setFlags( newRequest().setGlobalChecksumPolicy( InvocationRequest.CheckSumPolicy.Fail ), cli );
534397
538401 @Test
539402 public void testShouldSetLaxChecksumPolicyFlagFromRequest()
540403 {
541 logTestStart();
542
543 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
544 Commandline cli = new Commandline();
545404
546405 tcb.setFlags( newRequest().setGlobalChecksumPolicy( InvocationRequest.CheckSumPolicy.Warn ), cli );
547406
551410 @Test
552411 public void testShouldSetFailAtEndFlagFromRequest()
553412 {
554 logTestStart();
555
556 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
557 Commandline cli = new Commandline();
558413
559414 tcb.setReactorBehavior( newRequest().setReactorFailureBehavior( InvocationRequest.ReactorFailureBehavior.FailAtEnd ),
560415 cli );
565420 @Test
566421 public void testShouldSetFailNeverFlagFromRequest()
567422 {
568 logTestStart();
569
570 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
571 Commandline cli = new Commandline();
572423
573424 tcb.setReactorBehavior( newRequest().setReactorFailureBehavior( InvocationRequest.ReactorFailureBehavior.FailNever ),
574425 cli );
579430 @Test
580431 public void testShouldUseDefaultOfFailFastWhenSpecifiedInRequest()
581432 {
582 logTestStart();
583
584 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
585 Commandline cli = new Commandline();
586433
587434 tcb.setReactorBehavior( newRequest().setReactorFailureBehavior( InvocationRequest.ReactorFailureBehavior.FailFast ),
588435 cli );
589436
590 Set<String> banned = new HashSet<String>();
437 Set<String> banned = new HashSet<>();
591438 banned.add( "-fae" );
592439 banned.add( "-fn" );
593440
598445 public void testShouldSpecifyFileOptionUsingNonStandardPomFileLocation()
599446 throws Exception
600447 {
601 logTestStart();
602
603 File tmpDir = getTempDir();
604 File base = new File( tmpDir, "invoker-tests" );
605
606 toDelete.add( base );
607
608 File projectDir = new File( base, "file-option-nonstd-pom-file-location" ).getCanonicalFile();
609
610 projectDir.mkdirs();
448 File projectDir = temporaryFolder.newFolder( "invoker-tests", "file-option-nonstd-pom-file-location" );
611449
612450 File pomFile = createDummyFile( projectDir, "non-standard-pom.xml" ).getCanonicalFile();
613451
614 Commandline cli = new Commandline();
615452
616453 InvocationRequest req = newRequest().setPomFile( pomFile );
617454
618 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
619455 tcb.setEnvironmentPaths( req, cli );
620456 tcb.setPomLocation( req, cli );
621457
622 assertEquals( projectDir, cli.getWorkingDirectory() );
623
624 Set<String> args = new HashSet<String>();
458 assertEquals( projectDir.getCanonicalFile(), cli.getWorkingDirectory() );
459
460 Set<String> args = new HashSet<>();
625461 args.add( "-f" );
626462 args.add( "non-standard-pom.xml" );
627463
632468 public void testShouldSpecifyFileOptionUsingNonStandardPomInBasedir()
633469 throws Exception
634470 {
635 logTestStart();
636
637 File tmpDir = getTempDir();
638 File base = new File( tmpDir, "invoker-tests" );
639
640 toDelete.add( base );
641
642 File projectDir = new File( base, "file-option-nonstd-basedir" ).getCanonicalFile();
643
644 projectDir.mkdirs();
471 File projectDir = temporaryFolder.newFolder( "invoker-tests", "file-option-nonstd-basedir" );
645472
646473 File basedir = createDummyFile( projectDir, "non-standard-pom.xml" ).getCanonicalFile();
647474
648 Commandline cli = new Commandline();
649475
650476 InvocationRequest req = newRequest().setBaseDirectory( basedir );
651477
652 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
653478 tcb.setEnvironmentPaths( req, cli );
654479 tcb.setPomLocation( req, cli );
655480
656 assertEquals( projectDir, cli.getWorkingDirectory() );
657
658 Set<String> args = new HashSet<String>();
481 assertEquals( projectDir.getCanonicalFile(), cli.getWorkingDirectory() );
482
483 Set<String> args = new HashSet<>();
659484 args.add( "-f" );
660485 args.add( "non-standard-pom.xml" );
661486
666491 public void testShouldNotSpecifyFileOptionUsingStandardPomFileLocation()
667492 throws Exception
668493 {
669 logTestStart();
670
671 File tmpDir = getTempDir();
672 File base = new File( tmpDir, "invoker-tests" );
673
674 toDelete.add( base );
675
676 File projectDir = new File( base, "std-pom-file-location" ).getCanonicalFile();
677
678 projectDir.mkdirs();
494 File projectDir = temporaryFolder.newFolder( "invoker-tests", "std-pom-file-location" );
679495
680496 File pomFile = createDummyFile( projectDir, "pom.xml" ).getCanonicalFile();
681497
682 Commandline cli = new Commandline();
683498
684499 InvocationRequest req = newRequest().setPomFile( pomFile );
685500
686 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
687501 tcb.setEnvironmentPaths( req, cli );
688502 tcb.setPomLocation( req, cli );
689503
690 assertEquals( projectDir, cli.getWorkingDirectory() );
691
692 Set<String> args = new HashSet<String>();
504 assertEquals( projectDir.getCanonicalFile(), cli.getWorkingDirectory() );
505
506 Set<String> args = new HashSet<>();
693507 args.add( "-f" );
694508 args.add( "pom.xml" );
695509
700514 public void testShouldNotSpecifyFileOptionUsingStandardPomInBasedir()
701515 throws Exception
702516 {
703 logTestStart();
704
705 File tmpDir = getTempDir();
706 File base = new File( tmpDir, "invoker-tests" );
707
708 toDelete.add( base );
709
710 File projectDir = new File( base, "std-basedir-is-pom-file" ).getCanonicalFile();
711
712 projectDir.mkdirs();
517 File projectDir = temporaryFolder.newFolder( "invoker-tests", "std-basedir-is-pom-file" );
713518
714519 File basedir = createDummyFile( projectDir, "pom.xml" ).getCanonicalFile();
715520
716 Commandline cli = new Commandline();
717521
718522 InvocationRequest req = newRequest().setBaseDirectory( basedir );
719523
720 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
721524 tcb.setEnvironmentPaths( req, cli );
722525 tcb.setPomLocation( req, cli );
723526
724 assertEquals( projectDir, cli.getWorkingDirectory() );
725
726 Set<String> args = new HashSet<String>();
527 assertEquals( projectDir.getCanonicalFile(), cli.getWorkingDirectory() );
528
529 Set<String> args = new HashSet<>();
727530 args.add( "-f" );
728531 args.add( "pom.xml" );
729532
734537 public void testShouldUseDefaultPomFileWhenBasedirSpecifiedWithoutPomFileName()
735538 throws Exception
736539 {
737 logTestStart();
738
739 File tmpDir = getTempDir();
740 File base = new File( tmpDir, "invoker-tests" );
741
742 toDelete.add( base );
743
744 File projectDir = new File( base, "std-basedir-no-pom-filename" ).getCanonicalFile();
745
746 projectDir.mkdirs();
747
748 Commandline cli = new Commandline();
540 File projectDir = temporaryFolder.newFolder( "invoker-tests", "std-basedir-no-pom-filename" );
541
749542
750543 InvocationRequest req = newRequest().setBaseDirectory( projectDir );
751544
752 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
753545 tcb.setEnvironmentPaths( req, cli );
754546 tcb.setPomLocation( req, cli );
755547
756 assertEquals( projectDir, cli.getWorkingDirectory() );
757
758 Set<String> args = new HashSet<String>();
548 assertEquals( projectDir.getCanonicalFile(), cli.getWorkingDirectory() );
549
550 Set<String> args = new HashSet<>();
759551 args.add( "-f" );
760552 args.add( "pom.xml" );
761553
766558 public void testShouldSpecifyPomFileWhenBasedirSpecifiedWithPomFileName()
767559 throws Exception
768560 {
769 logTestStart();
770
771 File tmpDir = getTempDir();
772 File base = new File( tmpDir, "invoker-tests" );
773
774 toDelete.add( base );
775
776 File projectDir = new File( base, "std-basedir-with-pom-filename" ).getCanonicalFile();
777
778 projectDir.mkdirs();
779
780 Commandline cli = new Commandline();
561 File projectDir = temporaryFolder.newFolder( "invoker-tests", "std-basedir-with-pom-filename" );
562
781563
782564 InvocationRequest req = newRequest().setBaseDirectory( projectDir ).setPomFileName( "non-standard-pom.xml" );
783565
784 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
785566 tcb.setEnvironmentPaths( req, cli );
786567 tcb.setPomLocation( req, cli );
787568
788 assertEquals( projectDir, cli.getWorkingDirectory() );
789
790 Set<String> args = new HashSet<String>();
569 assertEquals( projectDir.getCanonicalFile(), cli.getWorkingDirectory() );
570
571 Set<String> args = new HashSet<>();
791572 args.add( "-f" );
792573 args.add( "non-standard-pom.xml" );
793574
798579 public void testShouldSpecifyCustomUserSettingsLocationFromRequest()
799580 throws Exception
800581 {
801 logTestStart();
802
803 File tmpDir = getTempDir();
804 File base = new File( tmpDir, "invoker-tests" );
805
806 toDelete.add( base );
807
808 File projectDir = new File( base, "custom-settings" ).getCanonicalFile();
809
810 projectDir.mkdirs();
582 File projectDir = temporaryFolder.newFolder( "invoker-tests", "custom-settings" );
811583
812584 File settingsFile = createDummyFile( projectDir, "settings.xml" );
813585
814 Commandline cli = new Commandline();
815
816 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
586
817587 tcb.setSettingsLocation( newRequest().setUserSettingsFile( settingsFile ), cli );
818588
819 Set<String> args = new HashSet<String>();
589 Set<String> args = new HashSet<>();
820590 args.add( "-s" );
821591 args.add( settingsFile.getCanonicalPath() );
822592
827597 public void testShouldSpecifyCustomGlobalSettingsLocationFromRequest()
828598 throws Exception
829599 {
830 logTestStart();
831
832 File tmpDir = getTempDir();
833 File base = new File( tmpDir, "invoker-tests" );
834
835 toDelete.add( base );
836
837 File projectDir = new File( base, "custom-settings" ).getCanonicalFile();
838
839 projectDir.mkdirs();
600 File projectDir = temporaryFolder.newFolder( "invoker-tests", "custom-settings" ).getCanonicalFile();
840601
841602 File settingsFile = createDummyFile( projectDir, "settings.xml" );
842603
843 Commandline cli = new Commandline();
844
845 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
604
846605 tcb.setSettingsLocation( newRequest().setGlobalSettingsFile( settingsFile ), cli );
847606
848 Set<String> args = new HashSet<String>();
607 Set<String> args = new HashSet<>();
849608 args.add( "-gs" );
850609 args.add( settingsFile.getCanonicalPath() );
851610
856615 public void testShouldSpecifyCustomToolchainsLocationFromRequest()
857616 throws Exception
858617 {
859 logTestStart();
860
861 File tmpDir = getTempDir();
862 File base = new File( tmpDir, "invoker-tests" );
863
864 toDelete.add( base );
865
866 File projectDir = new File( base, "custom-toolchains" ).getCanonicalFile();
867
868 projectDir.mkdirs();
618 File projectDir = temporaryFolder.newFolder( "invoker-tests", "custom-toolchains" );
869619
870620 File toolchainsFile = createDummyFile( projectDir, "toolchains.xml" );
871621
872 Commandline cli = new Commandline();
873
874 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
622
875623 tcb.setToolchainsLocation( newRequest().setToolchainsFile( toolchainsFile ), cli );
876624
877 Set<String> args = new HashSet<String>();
625 Set<String> args = new HashSet<>();
878626 args.add( "-t" );
879627 args.add( toolchainsFile.getCanonicalPath() );
880628
883631
884632 @Test
885633 public void testShouldSpecifyCustomPropertyFromRequest()
886 throws IOException
887 {
888 logTestStart();
889
890 Commandline cli = new Commandline();
634 {
891635
892636 Properties properties = new Properties();
893637 properties.setProperty( "key", "value" );
894638
895 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
896639 tcb.setProperties( newRequest().setProperties( properties ), cli );
897640
898641 assertArgumentsPresentInOrder( cli, "-D", "key=value" );
900643
901644 @Test
902645 public void testShouldSpecifyCustomPropertyWithSpacesInValueFromRequest()
903 throws IOException
904 {
905 logTestStart();
906
907 Commandline cli = new Commandline();
646 {
908647
909648 Properties properties = new Properties();
910649 properties.setProperty( "key", "value with spaces" );
911650
912 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
913651 tcb.setProperties( newRequest().setProperties( properties ), cli );
914652
915653 assertArgumentsPresentInOrder( cli, "-D", "key=value with spaces" );
917655
918656 @Test
919657 public void testShouldSpecifyCustomPropertyWithSpacesInKeyFromRequest()
920 throws IOException
921 {
922 logTestStart();
923
924 Commandline cli = new Commandline();
658 {
925659
926660 Properties properties = new Properties();
927661 properties.setProperty( "key with spaces", "value with spaces" );
928662
929 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
930663 tcb.setProperties( newRequest().setProperties( properties ), cli );
931664
932665 assertArgumentsPresentInOrder( cli, "-D", "key with spaces=value with spaces" );
933666 }
934667
935668 @Test
936 public void testShouldSpecifySingleGoalFromRequest()
937 throws IOException
938 {
939 logTestStart();
940
941 Commandline cli = new Commandline();
942
943 List<String> goals = new ArrayList<String>();
669 public void testShouldSpecifySingleGoalFromRequest() throws CommandLineConfigurationException
670 {
671
672 List<String> goals = new ArrayList<>();
944673 goals.add( "test" );
945674
946 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
947675 tcb.setGoals( newRequest().setGoals( goals ), cli );
948676
949677 assertArgumentsPresent( cli, Collections.singleton( "test" ) );
950678 }
951679
952680 @Test
953 public void testShouldSpecifyTwoGoalsFromRequest()
954 throws IOException
955 {
956 logTestStart();
957
958 Commandline cli = new Commandline();
959
960 List<String> goals = new ArrayList<String>();
681 public void testShouldSpecifyTwoGoalsFromRequest() throws CommandLineConfigurationException
682 {
683 List<String> goals = new ArrayList<>();
961684 goals.add( "test" );
962685 goals.add( "clean" );
963686
964 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
965687 tcb.setGoals( newRequest().setGoals( goals ), cli );
966688
967 assertArgumentsPresent( cli, new HashSet<String>( goals ) );
689 assertArgumentsPresent( cli, new HashSet<>( goals ) );
968690 assertArgumentsPresentInOrder( cli, goals );
969691 }
970692
971693 @Test
972694 public void testShouldSpecifyThreadsFromRequest()
973 throws IOException
974 {
975 logTestStart();
976
977 Commandline cli = new Commandline();
978
979 TestCommandLineBuilder tcb = new TestCommandLineBuilder();
695 {
980696 tcb.setThreads( newRequest().setThreads( "2.0C" ), cli );
981697
982698 assertArgumentsPresentInOrder( cli, "-T", "2.0C" );
986702 public void testBuildTypicalMavenInvocationEndToEnd()
987703 throws Exception
988704 {
989 logTestStart();
990705 File mavenDir = setupTempMavenHomeIfMissing( false );
991706
992707 InvocationRequest request = newRequest();
993708
994 File tmpDir = getTempDir();
995 File projectDir = new File( tmpDir, "invoker-tests/typical-end-to-end-cli-build" );
996
997 projectDir.mkdirs();
998 toDelete.add( projectDir.getParentFile() );
709 File projectDir = temporaryFolder.newFolder( "invoker-tests", "typical-end-to-end-cli-build" );
999710
1000711 request.setBaseDirectory( projectDir );
1001712
1002 Set<String> expectedArgs = new HashSet<String>();
1003 Set<String> bannedArgs = new HashSet<String>();
713 Set<String> expectedArgs = new HashSet<>();
714 Set<String> bannedArgs = new HashSet<>();
1004715
1005716 createDummyFile( projectDir, "pom.xml" );
1006717
1019730
1020731 expectedArgs.add( "-o" );
1021732
1022 List<String> goals = new ArrayList<String>();
733 List<String> goals = new ArrayList<>();
1023734
1024735 goals.add( "post-clean" );
1025736 goals.add( "deploy" );
1037748
1038749 String executable = commandline.getExecutable();
1039750
1040 assertTrue( executable.indexOf( new File( mavenDir, "bin/mvn" ).getCanonicalPath() ) > -1 );
751 assertTrue( executable.contains( new File( mavenDir, "bin/mvn" ).getCanonicalPath() ) );
1041752 assertEquals( projectDir.getCanonicalPath(), commandline.getWorkingDirectory().getCanonicalPath() );
1042753 }
1043754
1045756 public void testShouldSetEnvVar_MAVEN_TERMINATE_CMD()
1046757 throws Exception
1047758 {
1048 logTestStart();
1049759 setupTempMavenHomeIfMissing( false );
1050760
1051761 InvocationRequest request = newRequest();
1052762
1053 File tmpDir = getTempDir();
1054 File projectDir = new File( tmpDir, "invoker-tests/maven-terminate-cmd-options-set" );
1055
1056 projectDir.mkdirs();
1057 toDelete.add( projectDir.getParentFile() );
763 File projectDir = temporaryFolder.newFolder( "invoker-tests", "maven-terminate-cmd-options-set" );
1058764
1059765 request.setBaseDirectory( projectDir );
1060766
1061767 createDummyFile( projectDir, "pom.xml" );
1062768
1063 List<String> goals = new ArrayList<String>();
769 List<String> goals = new ArrayList<>();
1064770
1065771 goals.add( "clean" );
1066772 request.setGoals( goals );
1071777
1072778 String[] environmentVariables = commandline.getEnvironmentVariables();
1073779 String envVarMavenTerminateCmd = null;
1074 for ( int i = 0; i < environmentVariables.length; i++ )
1075 {
1076 String envVar = environmentVariables[i];
780 for ( String envVar : environmentVariables )
781 {
1077782 if ( envVar.startsWith( "MAVEN_TERMINATE_CMD=" ) )
1078783 {
1079784 envVarMavenTerminateCmd = envVar;
1095800
1096801 InvocationRequest request = newRequest();
1097802
1098 List<String> profiles = new ArrayList<String>();
803 List<String> profiles = new ArrayList<>();
1099804 profiles.add( profile1 );
1100805 profiles.add( profile2 );
1101806
1114819 {
1115820 Assume.assumeNotNull( System.getenv( "M2_HOME" ) );
1116821
1117 logTestStart();
1118822 setupTempMavenHomeIfMissing( true );
1119823
1120824 InvocationRequest request = newRequest();
1121825
1122 File tmpDir = getTempDir();
1123 File projectDir = new File( tmpDir, "invoker-tests/maven-terminate-cmd-options-set" );
1124
1125 projectDir.mkdirs();
1126 toDelete.add( projectDir.getParentFile() );
826 File projectDir = temporaryFolder.newFolder( "invoker-tests/maven-terminate-cmd-options-set" );
1127827
1128828 request.setBaseDirectory( projectDir );
1129829
1130830 createDummyFile( projectDir, "pom.xml" );
1131831
1132 List<String> goals = new ArrayList<String>();
832 List<String> goals = new ArrayList<>();
1133833
1134834 goals.add( "clean" );
1135835 request.setGoals( goals );
1142842
1143843 String[] environmentVariables = commandline.getEnvironmentVariables();
1144844 String m2Home = null;
1145 for ( int i = 0; i < environmentVariables.length; i++ )
1146 {
1147 String envVar = environmentVariables[i];
845 for ( String envVar : environmentVariables )
846 {
1148847 if ( envVar.startsWith( "M2_HOME=" ) )
1149848 {
1150849 m2Home = envVar;
1157856 public void testMvnCommand()
1158857 throws Exception
1159858 {
859 assumeThat( "Test only works when called with surefire", System.getProperty( "maven.home" ),
860 is( notNullValue() ) );
1160861 MavenCommandLineBuilder commandLineBuilder = new MavenCommandLineBuilder();
1161862 File mavenExecutable = new File( "mvnDebug" );
1162863 commandLineBuilder.setMavenExecutable( mavenExecutable );
1190891 assertEnvironmentVariablePresent( commandline, envVar2Name, envVar2Value );
1191892 }
1192893
1193 @Before
1194 public void setUp()
1195 {
1196 sysProps = System.getProperties();
1197
1198 Properties p = new Properties( sysProps );
1199
1200 System.setProperties( p );
1201 }
1202
1203 @After
1204 public void tearDown()
1205 throws IOException
1206 {
1207 System.setProperties( sysProps );
1208
1209 for ( File file : toDelete )
1210 {
1211 if ( file.exists() )
1212 {
1213 if ( file.isDirectory() )
1214 {
1215 FileUtils.deleteDirectory( file );
1216 }
1217 else
1218 {
1219 file.delete();
1220 }
1221 }
1222 }
1223 }
1224
1225 // this is just a debugging helper for separating unit test output...
1226 private void logTestStart()
1227 {
1228 NullPointerException npe = new NullPointerException();
1229 StackTraceElement element = npe.getStackTrace()[1];
1230
1231 System.out.println( "Starting: " + element.getMethodName() );
1232 }
1233
1234894 private void assertEnvironmentVariablePresent( Commandline cli, String varName, String varValue )
1235 throws CommandLineException
1236895 {
1237896 List<String> environmentVariables = Arrays.asList( cli.getEnvironmentVariables() );
1238897
1239898 String expectedDeclaration = varName + "=" + varValue;
1240899
1241 assertTrue( "Environment variable setting: \'" + expectedDeclaration + "\' is mssing in "
900 assertTrue( "Environment variable setting: '" + expectedDeclaration + "' is mssing in "
1242901 + environmentVariables, environmentVariables.contains( expectedDeclaration ) );
1243902 }
1244903
1253912
1254913 int expectedCounter = 0;
1255914
1256 for ( int i = 0; i < arguments.length; i++ )
1257 {
1258 if ( arguments[i].equals( expected.get( expectedCounter ) ) )
915 for ( String argument : arguments )
916 {
917 if ( argument.equals( expected.get( expectedCounter ) ) )
1259918 {
1260919 expectedCounter++;
1261920 }
1272931
1273932 for ( String arg : requiredArgs )
1274933 {
1275 assertTrue( "Command-line argument: \'" + arg + "\' is missing in " + args, args.contains( arg ) );
934 assertTrue( "Command-line argument: '" + arg + "' is missing in " + args, args.contains( arg ) );
1276935 }
1277936 }
1278937
1283942
1284943 for ( String arg : bannedArgs )
1285944 {
1286 assertFalse( "Command-line argument: \'" + arg + "\' should not be present.", args.contains( arg ) );
945 assertFalse( "Command-line argument: '" + arg + "' should not be present.", args.contains( arg ) );
1287946 }
1288947 }
1289948
1291950 throws IOException
1292951 {
1293952 File dummyFile = new File( directory, filename );
1294
1295 FileWriter writer = null;
1296 try
1297 {
1298 writer = new FileWriter( dummyFile );
953
954 try ( FileWriter writer = new FileWriter( dummyFile ) )
955 {
1299956 writer.write( "This is a dummy file." );
1300957 }
1301 finally
1302 {
1303 IOUtil.close( writer );
1304 }
1305
1306 toDelete.add( dummyFile );
1307958
1308959 return dummyFile;
1309960 }
1333984 super.setFlags( request, cli );
1334985 }
1335986
1336 public void setGoals( InvocationRequest request, Commandline cli )
987 public void setGoals( InvocationRequest request, Commandline cli ) throws CommandLineConfigurationException
1337988 {
1338989 super.setGoals( request, cli );
1339990 }
13661017
13671018 }
13681019
1369 private File getTempDir()
1370 throws Exception
1371 {
1372 return new File( System.getProperty( "java.io.tmpdir" ) ).getCanonicalFile();
1373 }
1374
13751020 private InvocationRequest newRequest()
13761021 {
13771022 return new DefaultInvocationRequest();
2626 <dependency>
2727 <groupId>junit</groupId>
2828 <artifactId>junit</artifactId>
29 <version>3.8.2</version>
29 <version>4.13.1</version>
3030 <scope>test</scope>
3131 </dependency>
3232 </dependencies>
0 <!--
1 Licensed to the Apache Software Foundation (ASF) under one
2 or more contributor license agreements. See the NOTICE file
3 distributed with this work for additional information
4 regarding copyright ownership. The ASF licenses this file
5 to you under the Apache License, Version 2.0 (the
6 "License"); you may not use this file except in compliance
7 with the License. You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing,
12 software distributed under the License is distributed on an
13 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 KIND, either express or implied. See the License for the
15 specific language governing permissions and limitations
16 under the License.
17 -->
18 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20 <modelVersion>4.0.0</modelVersion>
21 <groupId>org.apache.maven.shared.invoker</groupId>
22 <artifactId>test-build-should-timeout</artifactId>
23 <packaging>jar</packaging>
24 <version>1</version>
25 <dependencies>
26 <dependency>
27 <groupId>junit</groupId>
28 <artifactId>junit</artifactId>
29 <version>4.13.1</version>
30 <scope>test</scope>
31 </dependency>
32 </dependencies>
33 <build>
34 <pluginManagement>
35 <plugins>
36 <plugin>
37 <groupId>org.apache.maven.plugins</groupId>
38 <artifactId>maven-surefire-plugin</artifactId>
39 <version>2.22.2</version>
40 </plugin>
41 </plugins>
42 </pluginManagement>
43 </build>
44 </project>
0 package org.apache.maven.shared.invoker;
1
2 /*
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 */
20
21 /**
22 * Hello world!
23 *
24 */
25 public class App
26 {
27 public static void main( String[] args )
28 {
29 System.out.println( "Hello World!" );
30 }
31 }
0 package org.apache.maven.shared.invoker;
1
2 import org.junit.Test;
3
4 /*
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 */
22
23 /**
24 * Unit test for simple App.
25 */
26 public class AppTest
27 {
28
29 /**
30 * Not ending test
31 * @throws InterruptedException
32 */
33 @Test( timeout = 7000 ) // should be killed in 4 sec by Invoker - Workaround for Windows MSHARED-867
34 public void testApp() throws InterruptedException
35 {
36 while ( true )
37 {
38 Thread.sleep( 1000L );
39 }
40
41 // assertTrue( true );
42 }
43 }
2727 <plugin>
2828 <groupId>org.apache.maven.plugins</groupId>
2929 <artifactId>maven-antrun-plugin</artifactId>
30 <version>1.1</version>
30 <version>3.0.0</version>
3131 <configuration>
32 <tasks>
32 <target>
3333 <property name="prop0" value="${key}"/>
3434 <echo>${prop0}</echo>
3535 <property name="prop1" value="${key with spaces}"/>
4848 </not>
4949 </condition>
5050 </fail>
51 </tasks>
51 </target>
5252 </configuration>
5353 <executions>
5454 <execution>