New upstream version 3.1.0
Emmanuel Bourg
1 year, 4 months ago
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/ |
24 | 24 | <parent> |
25 | 25 | <groupId>org.apache.maven.shared</groupId> |
26 | 26 | <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 /> | |
29 | 29 | </parent> |
30 | 30 | |
31 | ||
31 | 32 | <artifactId>maven-invoker</artifactId> |
32 | <version>3.0.0</version> | |
33 | <version>3.1.0</version> | |
33 | 34 | |
34 | 35 | <name>Apache Maven Invoker</name> |
35 | 36 | <description>A component to programmatically invoke Maven.</description> |
36 | 37 | |
37 | 38 | <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> | |
41 | 43 | </scm> |
42 | 44 | <issueManagement> |
43 | 45 | <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> | |
45 | 47 | </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> | |
46 | 52 | <distributionManagement> |
47 | 53 | <site> |
48 | 54 | <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> | |
50 | 56 | </site> |
51 | 57 | </distributionManagement> |
52 | 58 | |
59 | 65 | </contributor> |
60 | 66 | </contributors> |
61 | 67 | |
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 | ||
62 | 75 | <dependencies> |
63 | 76 | <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> | |
67 | 80 | </dependency> |
68 | 81 | <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> | |
75 | 85 | </dependency> |
76 | 86 | <dependency> |
77 | 87 | <groupId>junit</groupId> |
78 | 88 | <artifactId>junit</artifactId> |
79 | <version>4.11</version> | |
89 | <version>4.13.1</version> | |
80 | 90 | <scope>test</scope> |
81 | 91 | </dependency> |
82 | 92 | </dependencies> |
83 | 93 | |
84 | 94 | <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> | |
85 | 125 | <plugins> |
86 | 126 | <plugin> |
87 | 127 | <groupId>org.apache.maven.plugins</groupId> |
101 | 141 | </configuration> |
102 | 142 | </plugin> |
103 | 143 | <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> | |
110 | 147 | <executions> |
111 | 148 | <execution> |
112 | <id>create-component-descriptor</id> | |
149 | <id>generate-index</id> | |
113 | 150 | <goals> |
114 | <goal>generate-metadata</goal> | |
151 | <goal>main-index</goal> | |
115 | 152 | </goals> |
116 | 153 | </execution> |
117 | 154 | </executions> |
144 | 181 | </plugins> |
145 | 182 | </build> |
146 | 183 | </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 | ||
147 | 209 | </profiles> |
148 | 210 | </project> |
+3
-4
20 | 20 | |
21 | 21 | /** |
22 | 22 | * 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 | * | |
25 | 24 | */ |
26 | 25 | public class CommandLineConfigurationException |
27 | 26 | extends Exception |
31 | 30 | |
32 | 31 | /** |
33 | 32 | * Creates a new exception using the specified detail message and cause. |
34 | * | |
33 | * | |
35 | 34 | * @param message The detail message for this exception, may be <code>null</code>. |
36 | 35 | * @param cause The nested exception, may be <code>null</code>. |
37 | 36 | */ |
42 | 41 | |
43 | 42 | /** |
44 | 43 | * Creates a new exception using the specified detail message. |
45 | * | |
44 | * | |
46 | 45 | * @param message The detail message for this exception, may be <code>null</code>. |
47 | 46 | */ |
48 | 47 | public CommandLineConfigurationException( String message ) |
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Specifies the parameters used to control a Maven invocation. |
31 | * | |
32 | * @version $Id: DefaultInvocationRequest.java 1752078 2016-07-10 11:25:08Z khmarbaise $ | |
31 | * | |
33 | 32 | */ |
34 | 33 | public class DefaultInvocationRequest |
35 | 34 | implements InvocationRequest |
103 | 102 | |
104 | 103 | private String builderId; |
105 | 104 | |
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 | */ | |
106 | 114 | public File getBaseDirectory() |
107 | 115 | { |
108 | 116 | return basedir; |
109 | 117 | } |
110 | 118 | |
119 | /** {@inheritDoc} */ | |
111 | 120 | public File getBaseDirectory( File defaultDirectory ) |
112 | 121 | { |
113 | 122 | return basedir == null ? defaultDirectory : basedir; |
114 | 123 | } |
115 | 124 | |
125 | /** {@inheritDoc} */ | |
116 | 126 | public InvocationOutputHandler getErrorHandler( InvocationOutputHandler defaultHandler ) |
117 | 127 | { |
118 | 128 | return errorHandler == null ? defaultHandler : errorHandler; |
119 | 129 | } |
120 | 130 | |
131 | /** | |
132 | * <p>getReactorFailureBehavior.</p> | |
133 | * | |
134 | * @return a ReactorFailureBehavior object. | |
135 | */ | |
121 | 136 | public ReactorFailureBehavior getReactorFailureBehavior() |
122 | 137 | { |
123 | 138 | return failureBehavior; |
124 | 139 | } |
125 | 140 | |
141 | /** | |
142 | * <p>Getter for the field <code>goals</code>.</p> | |
143 | * | |
144 | * @return a {@link java.util.List} object. | |
145 | */ | |
126 | 146 | public List<String> getGoals() |
127 | 147 | { |
128 | 148 | return goals; |
129 | 149 | } |
130 | 150 | |
151 | /** {@inheritDoc} */ | |
131 | 152 | public InputStream getInputStream( InputStream defaultStream ) |
132 | 153 | { |
133 | 154 | return inputStream == null ? defaultStream : inputStream; |
134 | 155 | } |
135 | 156 | |
157 | /** {@inheritDoc} */ | |
136 | 158 | public File getLocalRepositoryDirectory( File defaultDirectory ) |
137 | 159 | { |
138 | 160 | return localRepository == null ? defaultDirectory : localRepository; |
139 | 161 | } |
140 | 162 | |
163 | /** {@inheritDoc} */ | |
141 | 164 | public InvocationOutputHandler getOutputHandler( InvocationOutputHandler defaultHandler ) |
142 | 165 | { |
143 | 166 | return outputHandler == null ? defaultHandler : outputHandler; |
144 | 167 | } |
145 | 168 | |
169 | /** | |
170 | * <p>Getter for the field <code>pomFile</code>.</p> | |
171 | * | |
172 | * @return a {@link java.io.File} object. | |
173 | */ | |
146 | 174 | public File getPomFile() |
147 | 175 | { |
148 | 176 | return pomFile; |
149 | 177 | } |
150 | 178 | |
179 | /** | |
180 | * <p>Getter for the field <code>properties</code>.</p> | |
181 | * | |
182 | * @return a {@link java.util.Properties} object. | |
183 | */ | |
151 | 184 | public Properties getProperties() |
152 | 185 | { |
153 | 186 | return properties; |
154 | 187 | } |
155 | 188 | |
189 | /** | |
190 | * <p>isDebug.</p> | |
191 | * | |
192 | * @return a boolean. | |
193 | */ | |
156 | 194 | public boolean isDebug() |
157 | 195 | { |
158 | 196 | return debug; |
159 | 197 | } |
160 | 198 | |
199 | /** | |
200 | * <p>isBatchMode.</p> | |
201 | * | |
202 | * @return a boolean. | |
203 | */ | |
161 | 204 | public boolean isBatchMode() |
162 | 205 | { |
163 | 206 | return interactive; |
164 | 207 | } |
165 | 208 | |
209 | /** | |
210 | * <p>isOffline.</p> | |
211 | * | |
212 | * @return a boolean. | |
213 | */ | |
166 | 214 | public boolean isOffline() |
167 | 215 | { |
168 | 216 | return offline; |
169 | 217 | } |
170 | 218 | |
219 | /** | |
220 | * <p>isShowErrors.</p> | |
221 | * | |
222 | * @return a boolean. | |
223 | */ | |
171 | 224 | public boolean isShowErrors() |
172 | 225 | { |
173 | 226 | return showErrors; |
174 | 227 | } |
175 | 228 | |
229 | /** | |
230 | * <p>isUpdateSnapshots.</p> | |
231 | * | |
232 | * @return a boolean. | |
233 | */ | |
176 | 234 | public boolean isUpdateSnapshots() |
177 | 235 | { |
178 | 236 | return updateSnapshots; |
179 | 237 | } |
180 | 238 | |
239 | /** | |
240 | * <p>isRecursive.</p> | |
241 | * | |
242 | * @return a boolean. | |
243 | */ | |
181 | 244 | public boolean isRecursive() |
182 | 245 | { |
183 | 246 | return recursive; |
184 | 247 | } |
185 | 248 | |
249 | /** {@inheritDoc} */ | |
186 | 250 | public InvocationRequest setRecursive( boolean recursive ) |
187 | 251 | { |
188 | 252 | this.recursive = recursive; |
189 | 253 | return this; |
190 | 254 | } |
191 | 255 | |
256 | /** {@inheritDoc} */ | |
192 | 257 | public InvocationRequest setBaseDirectory( File basedir ) |
193 | 258 | { |
194 | 259 | this.basedir = basedir; |
195 | 260 | return this; |
196 | 261 | } |
197 | 262 | |
263 | /** {@inheritDoc} */ | |
198 | 264 | public InvocationRequest setDebug( boolean debug ) |
199 | 265 | { |
200 | 266 | this.debug = debug; |
201 | 267 | return this; |
202 | 268 | } |
203 | 269 | |
270 | /** {@inheritDoc} */ | |
204 | 271 | public InvocationRequest setErrorHandler( InvocationOutputHandler errorHandler ) |
205 | 272 | { |
206 | 273 | this.errorHandler = errorHandler; |
207 | 274 | return this; |
208 | 275 | } |
209 | 276 | |
277 | /** | |
278 | * <p>setReactorFailureBehavior.</p> | |
279 | * | |
280 | * @param failureBehavior a ReactorFailureBehavior object. | |
281 | * @return a {@link org.apache.maven.shared.invoker.InvocationRequest} object. | |
282 | */ | |
210 | 283 | public InvocationRequest setReactorFailureBehavior( ReactorFailureBehavior failureBehavior ) |
211 | 284 | { |
212 | 285 | this.failureBehavior = failureBehavior; |
213 | 286 | return this; |
214 | 287 | } |
215 | 288 | |
289 | /** {@inheritDoc} */ | |
216 | 290 | public InvocationRequest setGoals( List<String> goals ) |
217 | 291 | { |
218 | 292 | this.goals = goals; |
219 | 293 | return this; |
220 | 294 | } |
221 | 295 | |
296 | /** {@inheritDoc} */ | |
222 | 297 | public InvocationRequest setInputStream( InputStream inputStream ) |
223 | 298 | { |
224 | 299 | this.inputStream = inputStream; |
225 | 300 | return this; |
226 | 301 | } |
227 | 302 | |
303 | /** {@inheritDoc} */ | |
228 | 304 | public InvocationRequest setBatchMode( boolean interactive ) |
229 | 305 | { |
230 | 306 | this.interactive = interactive; |
231 | 307 | return this; |
232 | 308 | } |
233 | 309 | |
310 | /** {@inheritDoc} */ | |
234 | 311 | public InvocationRequest setLocalRepositoryDirectory( File localRepository ) |
235 | 312 | { |
236 | 313 | this.localRepository = localRepository; |
237 | 314 | return this; |
238 | 315 | } |
239 | 316 | |
317 | /** {@inheritDoc} */ | |
240 | 318 | public InvocationRequest setOffline( boolean offline ) |
241 | 319 | { |
242 | 320 | this.offline = offline; |
243 | 321 | return this; |
244 | 322 | } |
245 | 323 | |
324 | /** {@inheritDoc} */ | |
246 | 325 | public InvocationRequest setOutputHandler( InvocationOutputHandler outputHandler ) |
247 | 326 | { |
248 | 327 | this.outputHandler = outputHandler; |
249 | 328 | return this; |
250 | 329 | } |
251 | 330 | |
331 | /** {@inheritDoc} */ | |
252 | 332 | public InvocationRequest setPomFile( File pomFile ) |
253 | 333 | { |
254 | 334 | this.pomFile = pomFile; |
255 | 335 | return this; |
256 | 336 | } |
257 | 337 | |
338 | /** {@inheritDoc} */ | |
258 | 339 | public InvocationRequest setProperties( Properties properties ) |
259 | 340 | { |
260 | 341 | this.properties = properties; |
261 | 342 | return this; |
262 | 343 | } |
263 | 344 | |
345 | /** {@inheritDoc} */ | |
264 | 346 | public InvocationRequest setShowErrors( boolean showErrors ) |
265 | 347 | { |
266 | 348 | this.showErrors = showErrors; |
267 | 349 | return this; |
268 | 350 | } |
269 | 351 | |
352 | /** {@inheritDoc} */ | |
270 | 353 | public InvocationRequest setUpdateSnapshots( boolean updateSnapshots ) |
271 | 354 | { |
272 | 355 | this.updateSnapshots = updateSnapshots; |
274 | 357 | } |
275 | 358 | |
276 | 359 | /** |
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. | |
278 | 364 | */ |
279 | 365 | public boolean isShellEnvironmentInherited() |
280 | 366 | { |
281 | 367 | return shellEnvironmentInherited; |
282 | 368 | } |
283 | 369 | |
370 | /** {@inheritDoc} */ | |
284 | 371 | public InvocationRequest setShellEnvironmentInherited( boolean shellEnvironmentInherited ) |
285 | 372 | { |
286 | 373 | this.shellEnvironmentInherited = shellEnvironmentInherited; |
287 | 374 | return this; |
288 | 375 | } |
289 | 376 | |
377 | /** | |
378 | * <p>Getter for the field <code>javaHome</code>.</p> | |
379 | * | |
380 | * @return a {@link java.io.File} object. | |
381 | */ | |
290 | 382 | public File getJavaHome() |
291 | 383 | { |
292 | 384 | return javaHome; |
293 | 385 | } |
294 | 386 | |
295 | /** | |
296 | * {@inheritDoc} | |
297 | */ | |
387 | /** {@inheritDoc} */ | |
298 | 388 | public InvocationRequest setJavaHome( File javaHome ) |
299 | 389 | { |
300 | 390 | this.javaHome = javaHome; |
303 | 393 | |
304 | 394 | /** |
305 | 395 | * {@inheritDoc} |
396 | * | |
397 | * @return a {@link java.io.File} object. | |
306 | 398 | */ |
307 | 399 | public File getUserSettingsFile() |
308 | 400 | { |
309 | 401 | return userSettings; |
310 | 402 | } |
311 | 403 | |
312 | /** | |
313 | * {@inheritDoc} | |
314 | */ | |
404 | /** {@inheritDoc} */ | |
315 | 405 | public InvocationRequest setUserSettingsFile( File userSettings ) |
316 | 406 | { |
317 | 407 | this.userSettings = userSettings; |
320 | 410 | |
321 | 411 | /** |
322 | 412 | * {@inheritDoc} |
413 | * | |
414 | * @return a {@link java.io.File} object. | |
323 | 415 | */ |
324 | 416 | public File getGlobalSettingsFile() |
325 | 417 | { |
326 | 418 | return globalSettings; |
327 | 419 | } |
328 | 420 | |
329 | /** | |
330 | * {@inheritDoc} | |
331 | */ | |
421 | /** {@inheritDoc} */ | |
332 | 422 | public InvocationRequest setGlobalSettingsFile( File globalSettings ) |
333 | 423 | { |
334 | 424 | this.globalSettings = globalSettings; |
337 | 427 | |
338 | 428 | /** |
339 | 429 | * {@inheritDoc} |
430 | * | |
431 | * @return a {@link java.io.File} object. | |
340 | 432 | */ |
341 | 433 | public File getToolchainsFile() |
342 | 434 | { |
343 | 435 | return toolchains; |
344 | 436 | } |
345 | 437 | |
346 | /** | |
347 | * {@inheritDoc} | |
348 | */ | |
438 | /** {@inheritDoc} */ | |
349 | 439 | public InvocationRequest setToolchainsFile( File toolchains ) |
350 | 440 | { |
351 | 441 | this.toolchains = toolchains; |
354 | 444 | |
355 | 445 | /** |
356 | 446 | * {@inheritDoc} |
447 | * | |
448 | * @return a {@link java.io.File} object. | |
357 | 449 | */ |
358 | 450 | public File getGlobalToolchainsFile() |
359 | 451 | { |
360 | 452 | return globalToolchains; |
361 | 453 | } |
362 | 454 | |
363 | /** | |
364 | * {@inheritDoc} | |
365 | */ | |
455 | /** {@inheritDoc} */ | |
366 | 456 | public InvocationRequest setGlobalToolchainsFile( File toolchains ) |
367 | 457 | { |
368 | 458 | this.globalToolchains = toolchains; |
372 | 462 | |
373 | 463 | /** |
374 | 464 | * {@inheritDoc} |
465 | * | |
466 | * @return a CheckSumPolicy object. | |
375 | 467 | */ |
376 | 468 | public CheckSumPolicy getGlobalChecksumPolicy() |
377 | 469 | { |
380 | 472 | |
381 | 473 | /** |
382 | 474 | * {@inheritDoc} |
475 | * | |
476 | * @param globalChecksumPolicy a CheckSumPolicy object. | |
477 | * @return a {@link org.apache.maven.shared.invoker.InvocationRequest} object. | |
383 | 478 | */ |
384 | 479 | public InvocationRequest setGlobalChecksumPolicy( CheckSumPolicy globalChecksumPolicy ) |
385 | 480 | { |
389 | 484 | |
390 | 485 | /** |
391 | 486 | * {@inheritDoc} |
487 | * | |
488 | * @return a {@link java.lang.String} object. | |
392 | 489 | */ |
393 | 490 | public String getPomFileName() |
394 | 491 | { |
395 | 492 | return pomFilename; |
396 | 493 | } |
397 | 494 | |
398 | /** | |
399 | * {@inheritDoc} | |
400 | */ | |
495 | /** {@inheritDoc} */ | |
401 | 496 | public InvocationRequest setPomFileName( String pomFilename ) |
402 | 497 | { |
403 | 498 | this.pomFilename = pomFilename; |
406 | 501 | |
407 | 502 | /** |
408 | 503 | * {@inheritDoc} |
504 | * | |
505 | * @return a {@link java.util.List} object. | |
409 | 506 | */ |
410 | 507 | public List<String> getProfiles() |
411 | 508 | { |
412 | 509 | return profiles; |
413 | 510 | } |
414 | 511 | |
415 | /** | |
416 | * {@inheritDoc} | |
417 | */ | |
512 | /** {@inheritDoc} */ | |
418 | 513 | public InvocationRequest setProfiles( List<String> profiles ) |
419 | 514 | { |
420 | 515 | this.profiles = profiles; |
423 | 518 | |
424 | 519 | /** |
425 | 520 | * {@inheritDoc} |
521 | * | |
522 | * @return a boolean. | |
426 | 523 | */ |
427 | 524 | public boolean isNonPluginUpdates() |
428 | 525 | { |
429 | 526 | return nonPluginUpdates; |
430 | 527 | } |
431 | 528 | |
432 | /** | |
433 | * {@inheritDoc} | |
434 | */ | |
529 | /** {@inheritDoc} */ | |
435 | 530 | public InvocationRequest setNonPluginUpdates( boolean nonPluginUpdates ) |
436 | 531 | { |
437 | 532 | this.nonPluginUpdates = nonPluginUpdates; |
438 | 533 | return this; |
439 | 534 | } |
440 | 535 | |
536 | /** {@inheritDoc} */ | |
441 | 537 | public InvocationRequest addShellEnvironment( String name, String value ) |
442 | 538 | { |
443 | 539 | if ( this.shellEnvironments == null ) |
444 | 540 | { |
445 | this.shellEnvironments = new HashMap<String, String>(); | |
541 | this.shellEnvironments = new HashMap<>(); | |
446 | 542 | } |
447 | 543 | this.shellEnvironments.put( name, value ); |
448 | 544 | return this; |
449 | 545 | } |
450 | 546 | |
547 | /** | |
548 | * <p>Getter for the field <code>shellEnvironments</code>.</p> | |
549 | * | |
550 | * @return a {@link java.util.Map} object. | |
551 | */ | |
451 | 552 | public Map<String, String> getShellEnvironments() |
452 | 553 | { |
453 | 554 | return shellEnvironments == null ? Collections.<String, String>emptyMap() : shellEnvironments; |
454 | 555 | } |
455 | 556 | |
557 | /** | |
558 | * <p>Getter for the field <code>mavenOpts</code>.</p> | |
559 | * | |
560 | * @return a {@link java.lang.String} object. | |
561 | */ | |
456 | 562 | public String getMavenOpts() |
457 | 563 | { |
458 | 564 | return mavenOpts; |
459 | 565 | } |
460 | 566 | |
567 | /** {@inheritDoc} */ | |
461 | 568 | public InvocationRequest setMavenOpts( String mavenOpts ) |
462 | 569 | { |
463 | 570 | this.mavenOpts = mavenOpts; |
465 | 572 | } |
466 | 573 | |
467 | 574 | /** |
575 | * <p>isShowVersion.</p> | |
576 | * | |
468 | 577 | * @see org.apache.maven.shared.invoker.InvocationRequest#isShowVersion() |
578 | * @return a boolean. | |
469 | 579 | */ |
470 | 580 | public boolean isShowVersion() |
471 | 581 | { |
472 | 582 | return this.showVersion; |
473 | 583 | } |
474 | 584 | |
475 | /** | |
476 | * @see org.apache.maven.shared.invoker.InvocationRequest#setShowVersion(boolean) | |
477 | */ | |
585 | /** {@inheritDoc} */ | |
478 | 586 | public InvocationRequest setShowVersion( boolean showVersion ) |
479 | 587 | { |
480 | 588 | this.showVersion = showVersion; |
483 | 591 | |
484 | 592 | /** |
485 | 593 | * {@inheritDoc} |
594 | * | |
595 | * @return a {@link java.lang.String} object. | |
486 | 596 | */ |
487 | 597 | public String getThreads() |
488 | 598 | { |
489 | 599 | return threads; |
490 | 600 | } |
491 | 601 | |
492 | /** | |
493 | * {@inheritDoc} | |
494 | */ | |
602 | /** {@inheritDoc} */ | |
495 | 603 | public InvocationRequest setThreads( String threads ) |
496 | 604 | { |
497 | 605 | this.threads = threads; |
500 | 608 | |
501 | 609 | /** |
502 | 610 | * {@inheritDoc} |
611 | * | |
612 | * @return a {@link java.util.List} object. | |
503 | 613 | */ |
504 | 614 | public List<String> getProjects() |
505 | 615 | { |
506 | 616 | return projects; |
507 | 617 | } |
508 | 618 | |
509 | /** | |
510 | * {@inheritDoc} | |
511 | */ | |
619 | /** {@inheritDoc} */ | |
512 | 620 | public InvocationRequest setProjects( List<String> projects ) |
513 | 621 | { |
514 | 622 | this.projects = projects; |
517 | 625 | |
518 | 626 | /** |
519 | 627 | * {@inheritDoc} |
628 | * | |
629 | * @return a boolean. | |
520 | 630 | */ |
521 | 631 | public boolean isAlsoMake() |
522 | 632 | { |
523 | 633 | return alsoMake; |
524 | 634 | } |
525 | 635 | |
526 | /** | |
527 | * {@inheritDoc} | |
528 | */ | |
636 | /** {@inheritDoc} */ | |
529 | 637 | public InvocationRequest setAlsoMake( boolean alsoMake ) |
530 | 638 | { |
531 | 639 | this.alsoMake = alsoMake; |
534 | 642 | |
535 | 643 | /** |
536 | 644 | * {@inheritDoc} |
645 | * | |
646 | * @return a boolean. | |
537 | 647 | */ |
538 | 648 | public boolean isAlsoMakeDependents() |
539 | 649 | { |
540 | 650 | return alsoMakeDependents; |
541 | 651 | } |
542 | 652 | |
543 | /** | |
544 | * {@inheritDoc} | |
545 | */ | |
653 | /** {@inheritDoc} */ | |
546 | 654 | public InvocationRequest setAlsoMakeDependents( boolean alsoMakeDependents ) |
547 | 655 | { |
548 | 656 | this.alsoMakeDependents = alsoMakeDependents; |
551 | 659 | |
552 | 660 | /** |
553 | 661 | * {@inheritDoc} |
662 | * | |
663 | * @return a {@link java.lang.String} object. | |
554 | 664 | */ |
555 | 665 | public String getResumeFrom() |
556 | 666 | { |
557 | 667 | return resumeFrom; |
558 | 668 | } |
559 | 669 | |
560 | /** | |
561 | * {@inheritDoc} | |
562 | */ | |
670 | /** {@inheritDoc} */ | |
563 | 671 | public InvocationRequest setResumeFrom( String resumeFrom ) |
564 | 672 | { |
565 | 673 | this.resumeFrom = resumeFrom; |
566 | 674 | return this; |
567 | 675 | } |
568 | 676 | |
569 | /** | |
570 | * {@inheritDoc} | |
571 | */ | |
677 | /** {@inheritDoc} */ | |
572 | 678 | public InvocationRequest setBuilder( String id ) |
573 | 679 | { |
574 | 680 | this.builderId = id; |
577 | 683 | |
578 | 684 | /** |
579 | 685 | * {@inheritDoc} |
686 | * | |
687 | * @return a {@link java.lang.String} object. | |
580 | 688 | */ |
581 | 689 | public String getBuilder() |
582 | 690 | { |
583 | 691 | return this.builderId; |
584 | 692 | } |
585 | 693 | |
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 | } | |
586 | 726 | } |
18 | 18 | * under the License. |
19 | 19 | */ |
20 | 20 | |
21 | import org.codehaus.plexus.util.cli.CommandLineException; | |
21 | import org.apache.maven.shared.utils.cli.CommandLineException; | |
22 | 22 | |
23 | 23 | /** |
24 | 24 | * Describes the result of a Maven invocation. |
25 | * | |
26 | * @version $Id: DefaultInvocationResult.java 1401842 2012-10-24 19:49:47Z rfscholte $ | |
25 | * | |
27 | 26 | */ |
28 | 27 | public final class DefaultInvocationResult |
29 | 28 | implements InvocationResult |
48 | 47 | // hide constructor |
49 | 48 | } |
50 | 49 | |
50 | /** | |
51 | * <p>Getter for the field <code>exitCode</code>.</p> | |
52 | * | |
53 | * @return a int. | |
54 | */ | |
51 | 55 | public int getExitCode() |
52 | 56 | { |
53 | 57 | return exitCode; |
54 | 58 | } |
55 | 59 | |
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 | */ | |
56 | 65 | public CommandLineException getExecutionException() |
57 | 66 | { |
58 | 67 | return executionException; |
21 | 21 | import java.io.File; |
22 | 22 | import java.io.InputStream; |
23 | 23 | |
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; | |
28 | 30 | |
29 | 31 | /** |
30 | 32 | * Class intended to be used by clients who wish to invoke a forked Maven process from their applications |
31 | * | |
33 | * | |
32 | 34 | * @author jdcasey |
33 | 35 | */ |
34 | @Component( role = Invoker.class, hint = "default" ) | |
36 | @Named | |
37 | @Singleton | |
35 | 38 | public class DefaultInvoker |
36 | 39 | implements Invoker |
37 | 40 | { |
38 | ||
41 | /** Constant <code>ROLE_HINT="default"</code> */ | |
39 | 42 | public static final String ROLE_HINT = "default"; |
40 | 43 | |
41 | 44 | private static final InvokerLogger DEFAULT_LOGGER = new SystemOutLogger(); |
58 | 61 | |
59 | 62 | private InvocationOutputHandler errorHandler = DEFAULT_OUTPUT_HANDLER; |
60 | 63 | |
64 | /** {@inheritDoc} */ | |
61 | 65 | public InvocationResult execute( InvocationRequest request ) |
62 | 66 | throws MavenInvocationException |
63 | 67 | { |
107 | 111 | |
108 | 112 | try |
109 | 113 | { |
110 | int exitCode = executeCommandLine( cli, request ); | |
114 | int exitCode = executeCommandLine( cli, request, request.getTimeoutInSeconds() ); | |
111 | 115 | |
112 | 116 | result.setExitCode( exitCode ); |
113 | 117 | } |
119 | 123 | return result; |
120 | 124 | } |
121 | 125 | |
122 | private int executeCommandLine( Commandline cli, InvocationRequest request ) | |
126 | private int executeCommandLine( Commandline cli, InvocationRequest request, int timeoutInSeconds ) | |
123 | 127 | throws CommandLineException |
124 | 128 | { |
125 | int result = Integer.MIN_VALUE; | |
129 | int result; | |
126 | 130 | |
127 | 131 | InputStream inputStream = request.getInputStream( this.inputStream ); |
128 | 132 | InvocationOutputHandler outputHandler = request.getOutputHandler( this.outputHandler ); |
140 | 144 | getLogger().info( "Executing in batch mode. The configured input stream will be ignored." ); |
141 | 145 | } |
142 | 146 | |
143 | result = CommandLineUtils.executeCommandLine( cli, outputHandler, errorHandler ); | |
147 | result = CommandLineUtils.executeCommandLine( cli, outputHandler, errorHandler, timeoutInSeconds ); | |
144 | 148 | } |
145 | 149 | else |
146 | 150 | { |
149 | 153 | getLogger().warn( "Maven will be executed in interactive mode" |
150 | 154 | + ", but no input stream has been configured for this MavenInvoker instance." ); |
151 | 155 | |
152 | result = CommandLineUtils.executeCommandLine( cli, outputHandler, errorHandler ); | |
156 | result = CommandLineUtils.executeCommandLine( cli, outputHandler, errorHandler, timeoutInSeconds ); | |
153 | 157 | } |
154 | 158 | else |
155 | 159 | { |
156 | result = CommandLineUtils.executeCommandLine( cli, inputStream, outputHandler, errorHandler ); | |
160 | result = CommandLineUtils.executeCommandLine( cli, inputStream, outputHandler, errorHandler, | |
161 | timeoutInSeconds ); | |
157 | 162 | } |
158 | 163 | } |
159 | 164 | |
160 | 165 | return result; |
161 | 166 | } |
162 | 167 | |
168 | /** | |
169 | * <p>Getter for the field <code>localRepositoryDirectory</code>.</p> | |
170 | * | |
171 | * @return a {@link java.io.File} object. | |
172 | */ | |
163 | 173 | public File getLocalRepositoryDirectory() |
164 | 174 | { |
165 | 175 | return localRepositoryDirectory; |
166 | 176 | } |
167 | 177 | |
178 | /** | |
179 | * <p>Getter for the field <code>logger</code>.</p> | |
180 | * | |
181 | * @return a {@link org.apache.maven.shared.invoker.InvokerLogger} object. | |
182 | */ | |
168 | 183 | public InvokerLogger getLogger() |
169 | 184 | { |
170 | 185 | return logger; |
171 | 186 | } |
172 | 187 | |
188 | /** {@inheritDoc} */ | |
173 | 189 | public Invoker setLocalRepositoryDirectory( File localRepositoryDirectory ) |
174 | 190 | { |
175 | 191 | this.localRepositoryDirectory = localRepositoryDirectory; |
176 | 192 | return this; |
177 | 193 | } |
178 | 194 | |
195 | /** {@inheritDoc} */ | |
179 | 196 | public Invoker setLogger( InvokerLogger logger ) |
180 | 197 | { |
181 | 198 | this.logger = ( logger != null ) ? logger : DEFAULT_LOGGER; |
182 | 199 | return this; |
183 | 200 | } |
184 | 201 | |
202 | /** | |
203 | * <p>Getter for the field <code>workingDirectory</code>.</p> | |
204 | * | |
205 | * @return a {@link java.io.File} object. | |
206 | */ | |
185 | 207 | public File getWorkingDirectory() |
186 | 208 | { |
187 | 209 | return workingDirectory; |
188 | 210 | } |
189 | 211 | |
212 | /** {@inheritDoc} */ | |
190 | 213 | public Invoker setWorkingDirectory( File workingDirectory ) |
191 | 214 | { |
192 | 215 | this.workingDirectory = workingDirectory; |
193 | 216 | return this; |
194 | 217 | } |
195 | 218 | |
219 | /** | |
220 | * <p>Getter for the field <code>mavenHome</code>.</p> | |
221 | * | |
222 | * @return a {@link java.io.File} object. | |
223 | */ | |
196 | 224 | public File getMavenHome() |
197 | 225 | { |
198 | 226 | return mavenHome; |
199 | 227 | } |
200 | 228 | |
229 | /** {@inheritDoc} */ | |
201 | 230 | public Invoker setMavenHome( File mavenHome ) |
202 | 231 | { |
203 | 232 | this.mavenHome = mavenHome; |
205 | 234 | return this; |
206 | 235 | } |
207 | 236 | |
237 | /** | |
238 | * <p>Getter for the field <code>mavenExecutable</code>.</p> | |
239 | * | |
240 | * @return a {@link java.io.File} object. | |
241 | */ | |
208 | 242 | public File getMavenExecutable() |
209 | 243 | { |
210 | 244 | return mavenExecutable; |
211 | 245 | } |
212 | 246 | |
247 | /** {@inheritDoc} */ | |
213 | 248 | public Invoker setMavenExecutable( File mavenExecutable ) |
214 | 249 | { |
215 | 250 | this.mavenExecutable = mavenExecutable; |
216 | 251 | return this; |
217 | 252 | } |
218 | 253 | |
254 | /** {@inheritDoc} */ | |
219 | 255 | public Invoker setErrorHandler( InvocationOutputHandler errorHandler ) |
220 | 256 | { |
221 | 257 | this.errorHandler = errorHandler; |
222 | 258 | return this; |
223 | 259 | } |
224 | 260 | |
261 | /** {@inheritDoc} */ | |
225 | 262 | public Invoker setInputStream( InputStream inputStream ) |
226 | 263 | { |
227 | 264 | this.inputStream = inputStream; |
228 | 265 | return this; |
229 | 266 | } |
230 | 267 | |
268 | /** {@inheritDoc} */ | |
231 | 269 | public Invoker setOutputHandler( InvocationOutputHandler outputHandler ) |
232 | 270 | { |
233 | 271 | this.outputHandler = outputHandler; |
18 | 18 | * under the License. |
19 | 19 | */ |
20 | 20 | |
21 | import org.codehaus.plexus.util.cli.StreamConsumer; | |
21 | import org.apache.maven.shared.utils.cli.StreamConsumer; | |
22 | 22 | |
23 | 23 | /** |
24 | 24 | * Receives the standard/error output from a Maven invocation. |
25 | * | |
26 | * @version $Id: InvocationOutputHandler.java 1401842 2012-10-24 19:49:47Z rfscholte $ | |
25 | * | |
27 | 26 | */ |
28 | 27 | public interface InvocationOutputHandler |
29 | 28 | extends StreamConsumer |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Specifies the parameters used to control a Maven invocation. |
29 | * | |
30 | * @version $Id: InvocationRequest.java 1760179 2016-09-10 14:49:13Z khmarbaise $ | |
29 | * | |
31 | 30 | */ |
32 | 31 | public interface InvocationRequest |
33 | 32 | { |
34 | 33 | |
35 | 34 | /** |
36 | 35 | * By default, Maven is executed in batch mode. This mean no interaction with the Maven process can be done. |
37 | * | |
36 | * | |
38 | 37 | * @return <code>true</code> if Maven should be executed in batch mode, <code>false</code> if Maven is executed in |
39 | 38 | * interactive mode. |
40 | 39 | * @since 3.0.0 |
43 | 42 | |
44 | 43 | /** |
45 | 44 | * Gets the network mode of the Maven invocation. By default, Maven is executed in online mode. |
46 | * | |
45 | * | |
47 | 46 | * @return <code>true</code> if Maven should be executed in offline mode, <code>false</code> if the online mode is |
48 | 47 | * used. |
49 | 48 | */ |
52 | 51 | /** |
53 | 52 | * Indicates whether Maven should enforce an update check for plugins and snapshots. By default, no update check is |
54 | 53 | * performed. |
55 | * | |
54 | * | |
56 | 55 | * @return <code>true</code> if plugins and snapshots should be updated, <code>false</code> otherwise. |
57 | 56 | */ |
58 | 57 | boolean isUpdateSnapshots(); |
59 | 58 | |
60 | 59 | /** |
61 | 60 | * Gets the recursion behavior of a reactor invocation. By default, Maven will recursive the build into sub modules. |
62 | * | |
61 | * | |
63 | 62 | * @return <code>true</code> if sub modules should be build, <code>false</code> otherwise. |
64 | 63 | */ |
65 | 64 | boolean isRecursive(); |
67 | 66 | /** |
68 | 67 | * A list of specified reactor projects to build instead of all projects. A project can be specified by |
69 | 68 | * [groupId]:artifactId or by its relative path. |
70 | * | |
69 | * | |
71 | 70 | * @return the list of projects to add to reactor build, otherwise {@code null} |
72 | 71 | * @since 2.1 |
73 | 72 | */ |
75 | 74 | |
76 | 75 | /** |
77 | 76 | * Get the value of the {@code also-make} argument. |
78 | * | |
77 | * | |
79 | 78 | * @return {@code true} if the argument {@code also-make} was specified, otherwise {@code false} |
80 | 79 | * @since 2.1 |
81 | 80 | */ |
83 | 82 | |
84 | 83 | /** |
85 | 84 | * Get the value of the {@code also-make-dependents} |
86 | * | |
85 | * | |
87 | 86 | * @return {@code true} if the argument {@code also-make-dependents} was specified, otherwise {@code false} |
88 | 87 | * @since 2.1 |
89 | 88 | */ |
91 | 90 | |
92 | 91 | /** |
93 | 92 | * Get the value of {@code resume-from} |
94 | * | |
93 | * | |
95 | 94 | * @return specified reactor project to resume from |
96 | 95 | * @since 2.1 |
97 | 96 | */ |
99 | 98 | |
100 | 99 | /** |
101 | 100 | * Gets the debug mode of the Maven invocation. By default, Maven is executed in normal mode. |
102 | * | |
101 | * | |
103 | 102 | * @return <code>true</code> if Maven should be executed in debug mode, <code>false</code> if the normal mode should |
104 | 103 | * be used. |
105 | 104 | */ |
108 | 107 | /** |
109 | 108 | * Gets the exception output mode of the Maven invocation. By default, Maven will not print stack traces of build |
110 | 109 | * exceptions. |
111 | * | |
110 | * | |
112 | 111 | * @return <code>true</code> if Maven should print stack traces, <code>false</code> otherwise. |
113 | 112 | */ |
114 | 113 | boolean isShowErrors(); |
116 | 115 | /** |
117 | 116 | * Indicates whether the environment variables of the current process should be propagated to the Maven invocation. |
118 | 117 | * By default, the current environment variables are inherited by the new Maven invocation. |
119 | * | |
118 | * | |
120 | 119 | * @return <code>true</code> if the environment variables should be propagated, <code>false</code> otherwise. |
121 | 120 | */ |
122 | 121 | boolean isShellEnvironmentInherited(); |
123 | 122 | |
124 | 123 | /** |
125 | 124 | * Indicates whether Maven should check for plugin updates. By default, plugin updates are not suppressed. |
126 | * | |
125 | * | |
127 | 126 | * @return <code>true</code> if plugin updates should be suppressed, <code>false</code> otherwise. |
128 | 127 | */ |
129 | 128 | boolean isNonPluginUpdates(); |
131 | 130 | /** |
132 | 131 | * Gets the failure mode of the Maven invocation. By default, the mode {@link ReactorFailureBehavior#FailFast} is |
133 | 132 | * used. |
134 | * | |
133 | * | |
135 | 134 | * @return The failure mode, one of {@link ReactorFailureBehavior#FailFast}, |
136 | 135 | * {@link ReactorFailureBehavior#FailAtEnd} and {@link ReactorFailureBehavior#FailNever}. |
137 | 136 | * @since 3.0.0 |
140 | 139 | |
141 | 140 | /** |
142 | 141 | * Gets the path to the base directory of the local repository to use for the Maven invocation. |
143 | * | |
142 | * | |
144 | 143 | * @param defaultDirectory The default location to use if no location is configured for this request, may be |
145 | 144 | * <code>null</code>. |
146 | 145 | * @return The path to the base directory of the local repository or <code>null</code> to use the location from the |
151 | 150 | /** |
152 | 151 | * Gets the input stream used to provide input for the invoked Maven build. This is in particular useful when |
153 | 152 | * invoking Maven in interactive mode. |
154 | * | |
153 | * | |
154 | * @param defaultStream the default {@link java.io.InputStream} to use | |
155 | 155 | * @return The input stream used to provide input for the invoked Maven build or <code>null</code> if not set. |
156 | 156 | */ |
157 | 157 | InputStream getInputStream( InputStream defaultStream ); |
158 | 158 | |
159 | 159 | /** |
160 | 160 | * 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 | |
162 | 163 | * @return The output handler or <code>null</code> if not set. |
163 | 164 | */ |
164 | 165 | InvocationOutputHandler getOutputHandler( InvocationOutputHandler defaultHandler ); |
165 | 166 | |
166 | 167 | /** |
167 | 168 | * 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 | |
169 | 171 | * @return The error handler or <code>null</code> if not set. |
170 | 172 | */ |
171 | 173 | InvocationOutputHandler getErrorHandler( InvocationOutputHandler defaultHandler ); |
173 | 175 | /** |
174 | 176 | * Gets the path to the POM for the Maven invocation. If no base directory is set, the parent directory of this POM |
175 | 177 | * will be used as the working directory for the Maven invocation. |
176 | * | |
178 | * | |
177 | 179 | * @return The path to the POM for the Maven invocation or <code>null</code> if not set. |
178 | 180 | */ |
179 | 181 | File getPomFile(); |
182 | 184 | * Gets the (unqualified) filename of the POM for the Maven invocation. This setting is ignored if |
183 | 185 | * {@link #getPomFile()} does not return <code>null</code>. Otherwise, the base directory is assumed to contain a |
184 | 186 | * POM with this name. By default, a file named <code>pom.xml</code> is used. |
185 | * | |
187 | * | |
186 | 188 | * @return The (unqualified) filename of the POM for the Maven invocation or <code>null</code> if not set. |
187 | 189 | */ |
188 | 190 | String getPomFileName(); |
190 | 192 | /** |
191 | 193 | * Gets the path to the base directory of the POM for the Maven invocation. If {@link #getPomFile()} does not return |
192 | 194 | * <code>null</code>, this setting only affects the working directory for the Maven invocation. |
193 | * | |
195 | * | |
194 | 196 | * @return The path to the base directory of the POM or <code>null</code> if not set. |
195 | 197 | */ |
196 | 198 | File getBaseDirectory(); |
198 | 200 | /** |
199 | 201 | * Gets the path to the base directory of the POM for the Maven invocation. If {@link #getPomFile()} does not return |
200 | 202 | * <code>null</code>, this setting only affects the working directory for the Maven invocation. |
201 | * | |
203 | * | |
202 | 204 | * @param defaultDirectory The default base directory to use if none is configured for this request, may be |
203 | 205 | * <code>null</code>. |
204 | 206 | * @return The path to the base directory of the POM or <code>null</code> if not set. |
207 | 209 | |
208 | 210 | /** |
209 | 211 | * Gets the path to the base directory of the Java installation used to run Maven. |
210 | * | |
212 | * | |
211 | 213 | * @return The path to the base directory of the Java installation used to run Maven or <code>null</code> to use the |
212 | 214 | * default Java home. |
213 | 215 | */ |
215 | 217 | |
216 | 218 | /** |
217 | 219 | * Gets the system properties for the Maven invocation. |
218 | * | |
220 | * | |
219 | 221 | * @return The system properties for the Maven invocation or <code>null</code> if not set. |
220 | 222 | */ |
221 | 223 | Properties getProperties(); |
222 | 224 | |
223 | 225 | /** |
224 | 226 | * Gets the goals for the Maven invocation. |
225 | * | |
227 | * | |
226 | 228 | * @return The goals for the Maven invocation or <code>null</code> if not set. |
227 | 229 | */ |
228 | 230 | List<String> getGoals(); |
229 | 231 | |
230 | 232 | /** |
231 | 233 | * Gets the path to the user settings for the Maven invocation. |
232 | * | |
234 | * | |
233 | 235 | * @return The path to the user settings for the Maven invocation or <code>null</code> to load the user settings |
234 | 236 | * from the default location. |
235 | 237 | */ |
237 | 239 | |
238 | 240 | /** |
239 | 241 | * Gets the path to the global settings for the Maven invocation. |
240 | * | |
242 | * | |
241 | 243 | * @return The path to the global settings for the Maven invocation or <code>null</code> to load the global settings |
242 | 244 | * from the default location. |
243 | 245 | * @since 2.1 |
246 | 248 | |
247 | 249 | /** |
248 | 250 | * Gets the path to the custom toolchains file |
249 | * | |
251 | * | |
250 | 252 | * @return The path to the custom toolchains file or <code>null</code> to load the toolchains from the default |
251 | 253 | * location |
252 | 254 | * @since 2.1 |
255 | 257 | |
256 | 258 | /** |
257 | 259 | * Alternate path for the global toolchains file <b>Note. This is available since Maven 3.3.1</b> |
258 | * | |
260 | * | |
259 | 261 | * @return The path to the custom global toolchains file or <code>null</code> to load the global toolchains from the |
260 | 262 | * default location. |
261 | 263 | * @since 3.0.0 |
264 | 266 | |
265 | 267 | /** |
266 | 268 | * Gets the checksum mode of the Maven invocation. |
267 | * | |
269 | * | |
268 | 270 | * @return The checksum mode, one of {@link CheckSumPolicy#Warn} and {@link CheckSumPolicy#Fail}. |
269 | 271 | * @since 3.0.0 |
270 | 272 | */ |
272 | 274 | |
273 | 275 | /** |
274 | 276 | * Gets the profiles for the Maven invocation. |
275 | * | |
277 | * | |
276 | 278 | * @return The profiles for the Maven invocation or <code>null</code> if not set. |
277 | 279 | */ |
278 | 280 | List<String> getProfiles(); |
279 | 281 | |
280 | 282 | /** |
281 | 283 | * Gets the environment variables for the Maven invocation. |
282 | * | |
284 | * | |
283 | 285 | * @return The environment variables for the Maven invocation or <code>null</code> if not set. |
284 | 286 | */ |
285 | 287 | Map<String, String> getShellEnvironments(); |
286 | 288 | |
287 | 289 | /** |
288 | 290 | * Gets the value of the <code>MAVEN_OPTS</code> environment variable. |
289 | * | |
291 | * | |
290 | 292 | * @return The value of the <code>MAVEN_OPTS</code> environment variable or <code>null</code> if not set. |
291 | 293 | */ |
292 | 294 | String getMavenOpts(); |
293 | 295 | |
294 | 296 | /** |
295 | 297 | * The show version behavior (-V option) |
296 | * | |
298 | * | |
297 | 299 | * @return The show version behavior |
298 | 300 | * @since 2.0.11 |
299 | 301 | */ |
301 | 303 | |
302 | 304 | /** |
303 | 305 | * Get the value of the {@code threads} argument. |
304 | * | |
306 | * | |
305 | 307 | * @return the value of the {@code threads} argument or {@code null} if not set |
306 | 308 | * @since 2.1 |
307 | 309 | */ |
308 | 310 | 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(); | |
309 | 320 | |
310 | 321 | // ---------------------------------------------------------------------- |
311 | 322 | // Reactor Failure Mode |
333 | 344 | |
334 | 345 | private String longOption; |
335 | 346 | |
336 | private ReactorFailureBehavior( String shortOption, String longOption ) | |
347 | ReactorFailureBehavior( String shortOption, String longOption ) | |
337 | 348 | { |
338 | 349 | this.shortOption = shortOption; |
339 | 350 | this.longOption = longOption; |
368 | 379 | throw new IllegalArgumentException( "The string '" + longOption |
369 | 380 | + "' can not be converted to enumeration." ); |
370 | 381 | } |
371 | }; | |
382 | } | |
372 | 383 | |
373 | 384 | // ---------------------------------------------------------------------- |
374 | 385 | // Artifact repository policies |
397 | 408 | |
398 | 409 | /** |
399 | 410 | * Sets the interaction mode of the Maven invocation. Equivalent of {@code -B} and {@code --batch-mode} |
400 | * | |
411 | * | |
401 | 412 | * @param batchMode <code>true</code> if Maven should be executed in non-interactive mode, <code>false</code> if the |
402 | 413 | * interactive modes is used. |
403 | 414 | * @return This invocation request. |
407 | 418 | |
408 | 419 | /** |
409 | 420 | * Sets the network mode of the Maven invocation. Equivalent of {@code -o} and {@code --offline} |
410 | * | |
421 | * | |
411 | 422 | * @param offline <code>true</code> if Maven should be executed in offline mode, <code>false</code> if the online |
412 | 423 | * mode is used. |
413 | 424 | * @return This invocation request. |
416 | 427 | |
417 | 428 | /** |
418 | 429 | * Sets the debug mode of the Maven invocation. Equivalent of {@code -X} and {@code --debug} |
419 | * | |
430 | * | |
420 | 431 | * @param debug <code>true</code> if Maven should be executed in debug mode, <code>false</code> if the normal mode |
421 | 432 | * should be used. |
422 | 433 | * @return This invocation request. |
425 | 436 | |
426 | 437 | /** |
427 | 438 | * Sets the exception output mode of the Maven invocation. Equivalent of {@code -e} and {@code --errors} |
428 | * | |
439 | * | |
429 | 440 | * @param showErrors <code>true</code> if Maven should print stack traces, <code>false</code> otherwise. |
430 | 441 | * @return This invocation request. |
431 | 442 | */ |
434 | 445 | /** |
435 | 446 | * Specifies whether Maven should enforce an update check for plugins and snapshots. Equivalent of {@code -U} and |
436 | 447 | * {@code --update-snapshots} |
437 | * | |
448 | * | |
438 | 449 | * @param updateSnapshots <code>true</code> if plugins and snapshots should be updated, <code>false</code> |
439 | 450 | * otherwise. |
440 | 451 | * @return This invocation request. |
444 | 455 | /** |
445 | 456 | * Sets the failure mode of the Maven invocation. Equivalent of {@code -ff} and {@code --fail-fast}, {@code -fae} |
446 | 457 | * and {@code --fail-at-end}, {@code -fn} and {@code --fail-never} |
447 | * | |
458 | * | |
448 | 459 | * @param failureBehavior The failure mode, must be one of {@link ReactorFailureBehavior#FailFast}, |
449 | 460 | * {@link ReactorFailureBehavior#FailAtEnd} and {@link ReactorFailureBehavior#FailNever}. |
450 | 461 | * @return This invocation request. |
454 | 465 | |
455 | 466 | /** |
456 | 467 | * Sets the path to the base directory of the local repository to use for the Maven invocation. |
457 | * | |
468 | * | |
458 | 469 | * @param localRepository The path to the base directory of the local repository, may be <code>null</code>. |
459 | 470 | * @return This invocation request. |
460 | 471 | */ |
463 | 474 | /** |
464 | 475 | * Sets the input stream used to provide input for the invoked Maven build. This is in particular useful when |
465 | 476 | * invoking Maven in interactive mode. |
466 | * | |
477 | * | |
467 | 478 | * @param inputStream The input stream used to provide input for the invoked Maven build, may be <code>null</code> |
468 | 479 | * if not required. |
469 | 480 | * @return This invocation request. |
472 | 483 | |
473 | 484 | /** |
474 | 485 | * Sets the handler used to capture the standard output from the Maven build. |
475 | * | |
486 | * | |
476 | 487 | * @param outputHandler The output handler, may be <code>null</code> if the output is not of interest. |
477 | 488 | * @return This invocation request. |
478 | 489 | */ |
480 | 491 | |
481 | 492 | /** |
482 | 493 | * Sets the handler used to capture the error output from the Maven build. |
483 | * | |
494 | * | |
484 | 495 | * @param errorHandler The error handler, may be <code>null</code> if the output is not of interest. |
485 | 496 | * @return This invocation request. |
486 | 497 | */ |
489 | 500 | /** |
490 | 501 | * Sets the path to the POM for the Maven invocation. If no base directory is set, the parent directory of this POM |
491 | 502 | * will be used as the working directory for the Maven invocation. |
492 | * | |
503 | * | |
493 | 504 | * @param pomFile The path to the POM for the Maven invocation, may be <code>null</code> if not used. |
494 | 505 | * @return This invocation request. |
495 | 506 | */ |
499 | 510 | * Sets the (unqualified) filename of the POM for the Maven invocation. This setting is ignored if |
500 | 511 | * {@link #getPomFile()} does not return <code>null</code>. Otherwise, the base directory is assumed to contain a |
501 | 512 | * POM with this name. |
502 | * | |
513 | * | |
503 | 514 | * @param pomFilename The (unqualified) filename of the POM for the Maven invocation, may be <code>null</code> if |
504 | 515 | * not used. |
505 | 516 | * @return This invocation request. |
509 | 520 | /** |
510 | 521 | * Sets the path to the base directory of the POM for the Maven invocation. If {@link #getPomFile()} does not return |
511 | 522 | * <code>null</code>, this setting only affects the working directory for the Maven invocation. |
512 | * | |
523 | * | |
513 | 524 | * @param basedir The path to the base directory of the POM, may be <code>null</code> if not used. |
514 | 525 | * @return This invocation request. |
515 | 526 | */ |
517 | 528 | |
518 | 529 | /** |
519 | 530 | * Sets the path to the base directory of the Java installation used to run Maven. |
520 | * | |
531 | * | |
521 | 532 | * @param javaHome The path to the base directory of the Java installation used to run Maven, may be |
522 | 533 | * <code>null</code> to use the default Java home. |
523 | 534 | * @return This invocation request. |
526 | 537 | |
527 | 538 | /** |
528 | 539 | * Sets the system properties for the Maven invocation. |
529 | * | |
540 | * | |
530 | 541 | * @param properties The system properties for the Maven invocation, may be <code>null</code> if not set. |
531 | 542 | * @return This invocation request. |
532 | 543 | */ |
534 | 545 | |
535 | 546 | /** |
536 | 547 | * Sets the goals for the Maven invocation. |
537 | * | |
548 | * | |
538 | 549 | * @param goals The goals for the Maven invocation, may be <code>null</code> to execute the POMs default goal. |
539 | 550 | * @return This invocation request. |
540 | 551 | */ |
542 | 553 | |
543 | 554 | /** |
544 | 555 | * Sets the profiles for the Maven invocation. Equivalent of {@code -P} and {@code --active-profiles} |
545 | * | |
556 | * | |
546 | 557 | * @param profiles The profiles for the Maven invocation, may be <code>null</code> to use the default profiles. |
547 | 558 | * @return This invocation request. |
548 | 559 | */ |
550 | 561 | |
551 | 562 | /** |
552 | 563 | * Specifies whether the environment variables of the current process should be propagated to the Maven invocation. |
553 | * | |
564 | * | |
554 | 565 | * @param shellEnvironmentInherited <code>true</code> if the environment variables should be propagated, |
555 | 566 | * <code>false</code> otherwise. |
556 | 567 | * @return This invocation request. |
559 | 570 | |
560 | 571 | /** |
561 | 572 | * Sets the path to the user settings for the Maven invocation. Equivalent of {@code -s} and {@code --settings} |
562 | * | |
573 | * | |
563 | 574 | * @param userSettings The path to the user settings for the Maven invocation, may be <code>null</code> to load the |
564 | 575 | * user settings from the default location. |
565 | 576 | * @return This invocation request. |
569 | 580 | /** |
570 | 581 | * Sets the path to the global settings for the Maven invocation. Equivalent of {@code -gs} and |
571 | 582 | * {@code --global-settings} |
572 | * | |
583 | * | |
573 | 584 | * @param globalSettings The path to the global settings for the Maven invocation, may be <code>null</code> to load |
574 | 585 | * the global settings from the default location. |
575 | 586 | * @return This invocation request. |
579 | 590 | |
580 | 591 | /** |
581 | 592 | * Sets the alternate path for the user toolchains file Equivalent of {@code -t} or {@code --toolchains} |
582 | * | |
593 | * | |
583 | 594 | * @param toolchains the alternate path for the user toolchains file |
584 | 595 | * @return This invocation request |
585 | 596 | * @since 2.1 |
588 | 599 | |
589 | 600 | /** |
590 | 601 | * Sets the alternate path for the global toolchains file Equivalent of {@code -gt} or {@code --global-toolchains} |
591 | * | |
602 | * | |
592 | 603 | * @param toolchains the alternate path for the global toolchains file |
593 | 604 | * @return This invocation request |
594 | 605 | * @since 3.0.0 |
598 | 609 | /** |
599 | 610 | * Sets the checksum mode of the Maven invocation. Equivalent of {@code -c} or {@code --lax-checksums}, {@code -C} |
600 | 611 | * or {@code --strict-checksums} |
601 | * | |
612 | * | |
602 | 613 | * @param globalChecksumPolicy The checksum mode, must be one of {@link CheckSumPolicy#Warn} and |
603 | 614 | * {@link CheckSumPolicy#Fail}. |
604 | 615 | * @return This invocation request. |
609 | 620 | /** |
610 | 621 | * Specifies whether Maven should check for plugin updates. |
611 | 622 | * <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> | |
613 | 626 | * <strong>note: </strong>Ineffective with Maven3, only kept for backward compatibility |
614 | 627 | * </p> |
615 | * | |
628 | * | |
616 | 629 | * @param nonPluginUpdates <code>true</code> if plugin updates should be suppressed, <code>false</code> otherwise. |
617 | 630 | * @return This invocation request. |
618 | 631 | */ |
621 | 634 | /** |
622 | 635 | * Sets the recursion behavior of a reactor invocation. <em>Inverse</em> equivalent of {@code -N} and |
623 | 636 | * {@code --non-recursive} |
624 | * | |
637 | * | |
625 | 638 | * @param recursive <code>true</code> if sub modules should be build, <code>false</code> otherwise. |
626 | 639 | * @return This invocation request. |
627 | 640 | */ |
629 | 642 | |
630 | 643 | /** |
631 | 644 | * Adds the specified environment variable to the Maven invocation. |
632 | * | |
645 | * | |
633 | 646 | * @param name The name of the environment variable, must not be <code>null</code>. |
634 | 647 | * @param value The value of the environment variable, must not be <code>null</code>. |
635 | 648 | * @return This invocation request. |
638 | 651 | |
639 | 652 | /** |
640 | 653 | * Sets the value of the <code>MAVEN_OPTS</code> environment variable. |
641 | * | |
654 | * | |
642 | 655 | * @param mavenOpts The value of the <code>MAVEN_OPTS</code> environment variable, may be <code>null</code> to use |
643 | 656 | * the default options. |
644 | 657 | * @return This invocation request. |
647 | 660 | |
648 | 661 | /** |
649 | 662 | * enable displaying version without stopping the build Equivalent of {@code -V} or {@code --show-version} |
650 | * | |
663 | * | |
651 | 664 | * @param showVersion enable displaying version |
652 | 665 | * @return This invocation request. |
653 | 666 | * @since 2.0.11 |
659 | 672 | * <p> |
660 | 673 | * <strong>note: </strong>available since Maven3 |
661 | 674 | * </p> |
662 | * | |
675 | * | |
663 | 676 | * @param threads the threadcount |
664 | 677 | * @return This invocation request. |
665 | 678 | * @since 2.1 |
668 | 681 | |
669 | 682 | /** |
670 | 683 | * Sets the reactor project list. Equivalent of {@code -pl} or {@code --projects} |
671 | * | |
684 | * | |
672 | 685 | * @param projects the reactor project list |
673 | 686 | * @return This invocation request. |
674 | 687 | * @since 2.1 |
677 | 690 | |
678 | 691 | /** |
679 | 692 | * Enable the 'also make' mode. Equivalent of {@code -am} or {@code --also-make} |
680 | * | |
693 | * | |
681 | 694 | * @param alsoMake enable 'also make' mode |
682 | 695 | * @return This invocation request. |
683 | 696 | * @since 2.1 |
686 | 699 | |
687 | 700 | /** |
688 | 701 | * Enable the 'also make dependents' mode. Equivalent of {@code -amd} or {@code --also-make-dependents} |
689 | * | |
702 | * | |
690 | 703 | * @param alsoMakeDependents enable 'also make' mode |
691 | 704 | * @return This invocation request. |
692 | 705 | * @since 2.1 |
695 | 708 | |
696 | 709 | /** |
697 | 710 | * Resume reactor from specified project. Equivalent of {@code -rf} or {@code --resume-from} |
698 | * | |
711 | * | |
699 | 712 | * @param resumeFrom set the project to resume from |
700 | 713 | * @return This invocation request |
701 | 714 | * @since 2.1 |
705 | 718 | /** |
706 | 719 | * The id of the build strategy to use. equivalent of {@code --builder id}. <b>Note. This is available since Maven |
707 | 720 | * 3.2.1</b> |
708 | * | |
721 | * | |
709 | 722 | * @param id The builder id. |
710 | 723 | * @return {@link InvocationRequest} FIXME: How to identify if this is a valid command line option? |
711 | 724 | * @since 3.0.0 |
713 | 726 | InvocationRequest setBuilder( String id ); |
714 | 727 | |
715 | 728 | /** |
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 | /** | |
716 | 739 | * Get the current set builder strategy id equivalent of {@code --builder id}. <b>Note. This is available since |
717 | 740 | * Maven 3.2.1</b> |
718 | * | |
741 | * | |
719 | 742 | * @return The current set builder id. |
720 | 743 | * @since 3.0.0 |
721 | 744 | */ |
722 | 745 | String getBuilder(); |
723 | 746 | |
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 | ||
724 | 765 | } |
18 | 18 | * under the License. |
19 | 19 | */ |
20 | 20 | |
21 | import org.codehaus.plexus.util.cli.CommandLineException; | |
21 | import org.apache.maven.shared.utils.cli.CommandLineException; | |
22 | 22 | |
23 | 23 | /** |
24 | 24 | * Describes the result of a Maven invocation. |
25 | * | |
25 | * | |
26 | 26 | * @author jdcasey |
27 | * @version $Id: InvocationResult.java 1401842 2012-10-24 19:49:47Z rfscholte $ | |
28 | 27 | */ |
29 | 28 | public interface InvocationResult |
30 | 29 | { |
31 | 30 | |
32 | 31 | /** |
33 | 32 | * Gets the exception that possibly occurred during the execution of the command line. |
34 | * | |
33 | * | |
35 | 34 | * @return The exception that prevented to invoke Maven or <code>null</code> if the command line was successfully |
36 | 35 | * processed by the operating system. |
37 | 36 | */ |
40 | 39 | /** |
41 | 40 | * Gets the exit code from the Maven invocation. A non-zero value indicates a build failure. <strong>Note:</strong> |
42 | 41 | * This value is undefined if {@link #getExecutionException()} reports an exception. |
43 | * | |
42 | * | |
44 | 43 | * @return The exit code from the Maven invocation. |
45 | 44 | */ |
46 | 45 | int getExitCode(); |
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Provides a facade to invoke Maven. |
26 | * | |
27 | * @version $Id: Invoker.java 1712636 2015-11-04 20:35:22Z khmarbaise $ | |
26 | * | |
28 | 27 | */ |
29 | 28 | public interface Invoker |
30 | 29 | { |
38 | 37 | * Executes Maven using the parameters specified by the given invocation request. Parameters not specified by the |
39 | 38 | * invocation request will be derived from the state of this invoker instance. In case both the invoker instance and |
40 | 39 | * the invocation request provide a value for a particular option, the value from the invocation request dominates. |
41 | * | |
40 | * | |
42 | 41 | * @param request The invocation request to execute, must not be <code>null</code>. |
43 | 42 | * @return The result of the Maven invocation, never <code>null</code>. |
44 | * @throws MavenInvocationException | |
43 | * @throws MavenInvocationException if cannot configure correctly execution parameters | |
45 | 44 | */ |
46 | 45 | InvocationResult execute( InvocationRequest request ) |
47 | 46 | throws MavenInvocationException; |
48 | 47 | |
49 | 48 | /** |
50 | 49 | * Gets the path to the base directory of the local repository to use for the Maven invocation. |
51 | * | |
50 | * | |
52 | 51 | * @return The path to the base directory of the local repository or <code>null</code> to use the location from |
53 | 52 | * the <code>settings.xml</code>. |
54 | 53 | */ |
56 | 55 | |
57 | 56 | /** |
58 | 57 | * Gets the working directory for the Maven invocation. |
59 | * | |
58 | * | |
60 | 59 | * @return The working directory for the Maven invocation or <code>null</code> if the working directory is derived |
61 | 60 | * from the base directory of the processed POM. |
62 | 61 | */ |
64 | 63 | |
65 | 64 | /** |
66 | 65 | * Gets the logger used by this invoker to output diagnostic messages. |
67 | * | |
66 | * | |
68 | 67 | * @return The logger used by this invoker to output diagnostic messages, never <code>null</code>. |
69 | 68 | */ |
70 | 69 | InvokerLogger getLogger(); |
71 | 70 | |
72 | 71 | /** |
73 | 72 | * Gets the path to the base directory of the Maven installation used to invoke Maven. |
74 | * | |
73 | * | |
75 | 74 | * @return The path to the base directory of the Maven installation or <code>null</code> if using the default |
76 | 75 | * Maven installation. |
77 | 76 | */ |
81 | 80 | * Sets the path to the base directory of the Maven installation used to invoke Maven. This parameter may be left |
82 | 81 | * unspecified to use the default Maven installation which will be discovered by evaluating the system property |
83 | 82 | * <code>maven.home</code> and the environment variable <code>M2_HOME</code>. |
84 | * | |
83 | * | |
85 | 84 | * @param mavenHome The path to the base directory of the Maven installation, may be <code>null</code> to use the |
86 | 85 | * default Maven installation. |
87 | 86 | * @return This invoker instance. |
90 | 89 | |
91 | 90 | /** |
92 | 91 | * 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} | |
95 | 94 | */ |
96 | 95 | File getMavenExecutable(); |
97 | 96 | |
98 | 97 | /** |
99 | 98 | * {@code mavenExecutable} can either be a file relative to ${maven.home}/bin/ or an absolute file. |
100 | * | |
99 | * | |
101 | 100 | * @param mavenExecutable the executable |
102 | 101 | * @return This invoker instance |
103 | 102 | */ |
105 | 104 | |
106 | 105 | /** |
107 | 106 | * Sets the path to the base directory of the local repository to use for the Maven invocation. |
108 | * | |
107 | * | |
109 | 108 | * @param localRepositoryDirectory The path to the base directory of the local repository or <code>null</code> to |
110 | 109 | * use the location from the <code>settings.xml</code>. |
111 | 110 | * @return This invoker instance. |
114 | 113 | |
115 | 114 | /** |
116 | 115 | * Sets the logger used by this invoker to output diagnostic messages. |
117 | * | |
116 | * | |
118 | 117 | * @param logger The logger used by this invoker to output diagnostic messages, may be <code>null</code> to use a |
119 | 118 | * default logger. |
120 | 119 | * @return This invoker instance. |
123 | 122 | |
124 | 123 | /** |
125 | 124 | * Sets the working directory for the Maven invocation. |
126 | * | |
125 | * | |
127 | 126 | * @param workingDirectory The working directory for the Maven invocation, may be <code>null</code> to derive the |
128 | 127 | * working directory from the base directory of the processed POM. |
129 | 128 | * @return This invoker instance. |
133 | 132 | /** |
134 | 133 | * Sets the input stream used to provide input for the invoked Maven build. This is in particular useful when |
135 | 134 | * invoking Maven in interactive mode. |
136 | * | |
135 | * | |
137 | 136 | * @param inputStream The input stream used to provide input for the invoked Maven build, may be <code>null</code> |
138 | 137 | * if not required. |
139 | 138 | * @return This invoker instance. |
142 | 141 | |
143 | 142 | /** |
144 | 143 | * Sets the handler used to capture the standard output from the Maven build. |
145 | * | |
144 | * | |
146 | 145 | * @param outputHandler The output handler, may be <code>null</code> if the output is not of interest. |
147 | 146 | * @return This invoker instance. |
148 | 147 | */ |
150 | 149 | |
151 | 150 | /** |
152 | 151 | * Sets the handler used to capture the error output from the Maven build. |
153 | * | |
152 | * | |
154 | 153 | * @param errorHandler The error handler, may be <code>null</code> if the output is not of interest. |
155 | 154 | * @return This invoker instance. |
156 | 155 | */ |
19 | 19 | */ |
20 | 20 | |
21 | 21 | /** |
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 | * | |
24 | 24 | * @see Invoker#setLogger(InvokerLogger) |
25 | 25 | * @author <a href="mailto:jason@maven.org">Jason van Zyl</a> |
26 | * @version $Id: InvokerLogger.java 1635406 2014-10-30 06:51:13Z hboutemy $ | |
27 | 26 | */ |
28 | 27 | public interface InvokerLogger |
29 | 28 | { |
55 | 54 | |
56 | 55 | /** |
57 | 56 | * Logs the specified debug message. |
58 | * | |
57 | * | |
59 | 58 | * @param message The message to log, may be <code>null</code>. |
60 | 59 | */ |
61 | 60 | void debug( String message ); |
62 | 61 | |
63 | 62 | /** |
64 | 63 | * Logs the specified debug message and the accompanying exception. |
65 | * | |
64 | * | |
66 | 65 | * @param message The message to log, may be <code>null</code>. |
67 | 66 | * @param throwable The exception to log, may be <code>null</code>. |
68 | 67 | */ |
70 | 69 | |
71 | 70 | /** |
72 | 71 | * Tests whether debug output is enabled for this logger. |
73 | * | |
72 | * | |
74 | 73 | * @return <code>true</code> if messages with priority "debug" or above are logged, <code>false</code> |
75 | 74 | * otherwise. |
76 | 75 | */ |
78 | 77 | |
79 | 78 | /** |
80 | 79 | * Logs the specified info message. |
81 | * | |
80 | * | |
82 | 81 | * @param message The message to log, may be <code>null</code>. |
83 | 82 | */ |
84 | 83 | void info( String message ); |
85 | 84 | |
86 | 85 | /** |
87 | 86 | * Logs the specified info message and the accompanying exception. |
88 | * | |
87 | * | |
89 | 88 | * @param message The message to log, may be <code>null</code>. |
90 | 89 | * @param throwable The exception to log, may be <code>null</code>. |
91 | 90 | */ |
93 | 92 | |
94 | 93 | /** |
95 | 94 | * Tests whether info output is enabled for this logger. |
96 | * | |
95 | * | |
97 | 96 | * @return <code>true</code> if messages with priority "info" or above are logged, <code>false</code> otherwise. |
98 | 97 | */ |
99 | 98 | boolean isInfoEnabled(); |
100 | 99 | |
101 | 100 | /** |
102 | 101 | * Logs the specified warning message. |
103 | * | |
102 | * | |
104 | 103 | * @param message The message to log, may be <code>null</code>. |
105 | 104 | */ |
106 | 105 | void warn( String message ); |
107 | 106 | |
108 | 107 | /** |
109 | 108 | * Logs the specified warning message and the accompanying exception. |
110 | * | |
109 | * | |
111 | 110 | * @param message The message to log, may be <code>null</code>. |
112 | 111 | * @param throwable The exception to log, may be <code>null</code>. |
113 | 112 | */ |
115 | 114 | |
116 | 115 | /** |
117 | 116 | * Tests whether warn output is enabled for this logger. |
118 | * | |
117 | * | |
119 | 118 | * @return <code>true</code> if messages with priority "warn" or above are logged, <code>false</code> otherwise. |
120 | 119 | */ |
121 | 120 | boolean isWarnEnabled(); |
122 | 121 | |
123 | 122 | /** |
124 | 123 | * Logs the specified error message. |
125 | * | |
124 | * | |
126 | 125 | * @param message The message to log, may be <code>null</code>. |
127 | 126 | */ |
128 | 127 | void error( String message ); |
129 | 128 | |
130 | 129 | /** |
131 | 130 | * Logs the specified error message and the accompanying exception. |
132 | * | |
131 | * | |
133 | 132 | * @param message The message to log, may be <code>null</code>. |
134 | 133 | * @param throwable The exception to log, may be <code>null</code>. |
135 | 134 | */ |
137 | 136 | |
138 | 137 | /** |
139 | 138 | * Tests whether error output is enabled for this logger. |
140 | * | |
139 | * | |
141 | 140 | * @return <code>true</code> if messages with priority "error" or above are logged, <code>false</code> |
142 | 141 | * otherwise. |
143 | 142 | */ |
145 | 144 | |
146 | 145 | /** |
147 | 146 | * Logs the specified fatal error message. |
148 | * | |
147 | * | |
149 | 148 | * @param message The message to log, may be <code>null</code>. |
150 | 149 | */ |
151 | 150 | void fatalError( String message ); |
152 | 151 | |
153 | 152 | /** |
154 | 153 | * Logs the specified fatal error message and the accompanying exception. |
155 | * | |
154 | * | |
156 | 155 | * @param message The message to log, may be <code>null</code>. |
157 | 156 | * @param throwable The exception to log, may be <code>null</code>. |
158 | 157 | */ |
160 | 159 | |
161 | 160 | /** |
162 | 161 | * Tests whether fatal error output is enabled for this logger. |
163 | * | |
162 | * | |
164 | 163 | * @return <code>true</code> if messages with priority "fatal" or above are logged, <code>false</code> |
165 | 164 | * otherwise. |
166 | 165 | */ |
168 | 167 | |
169 | 168 | /** |
170 | 169 | * Sets the logger's threshold. |
171 | * | |
170 | * | |
172 | 171 | * @param threshold The logger's threshold, must be one of {@link #DEBUG}, {@link #INFO}, {@link #WARN}, |
173 | 172 | * {@link #ERROR} and {@link #FATAL}. |
174 | 173 | */ |
176 | 175 | |
177 | 176 | /** |
178 | 177 | * Gets the logger's threshold. |
179 | * | |
178 | * | |
180 | 179 | * @return The logger's threshold, one of {@link #DEBUG}, {@link #INFO}, {@link #WARN}, {@link #ERROR} and |
181 | 180 | * {@link #FATAL}. |
182 | 181 | */ |
20 | 20 | |
21 | 21 | import java.io.File; |
22 | 22 | import java.io.IOException; |
23 | import java.util.Iterator; | |
24 | 23 | import java.util.List; |
25 | 24 | import java.util.Map; |
26 | 25 | import java.util.Map.Entry; |
28 | 27 | |
29 | 28 | import org.apache.maven.shared.invoker.InvocationRequest.CheckSumPolicy; |
30 | 29 | 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; | |
35 | 35 | |
36 | 36 | /** |
37 | * @version $Id: MavenCommandLineBuilder.java 1760179 2016-09-10 14:49:13Z khmarbaise $ | |
37 | * <p>MavenCommandLineBuilder class.</p> | |
38 | 38 | */ |
39 | 39 | public class MavenCommandLineBuilder |
40 | 40 | { |
53 | 53 | |
54 | 54 | private Properties systemEnvVars; |
55 | 55 | |
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 | */ | |
56 | 63 | public Commandline build( InvocationRequest request ) |
57 | 64 | throws CommandLineConfigurationException |
58 | 65 | { |
64 | 71 | { |
65 | 72 | throw new CommandLineConfigurationException( e.getMessage(), e ); |
66 | 73 | } |
67 | File mvn = null; | |
74 | File mvn; | |
68 | 75 | try |
69 | 76 | { |
70 | 77 | mvn = findMavenExecutable(); |
109 | 116 | return cli; |
110 | 117 | } |
111 | 118 | |
119 | /** | |
120 | * <p>checkRequiredState.</p> | |
121 | * | |
122 | * @throws java.io.IOException if any. | |
123 | */ | |
112 | 124 | protected void checkRequiredState() |
113 | 125 | throws IOException |
114 | 126 | { |
125 | 137 | { |
126 | 138 | throw new IllegalStateException( "Maven application directory was not " |
127 | 139 | + "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 | */ | |
133 | 151 | protected void setSettingsLocation( InvocationRequest request, Commandline cli ) |
134 | 152 | { |
135 | 153 | File userSettingsFile = request.getUserSettingsFile(); |
138 | 156 | { |
139 | 157 | try |
140 | 158 | { |
141 | File canSet = userSettingsFile.getCanonicalFile(); | |
142 | userSettingsFile = canSet; | |
159 | userSettingsFile = userSettingsFile.getCanonicalFile(); | |
143 | 160 | } |
144 | 161 | catch ( IOException e ) |
145 | 162 | { |
157 | 174 | { |
158 | 175 | try |
159 | 176 | { |
160 | File canSet = globalSettingsFile.getCanonicalFile(); | |
161 | globalSettingsFile = canSet; | |
177 | globalSettingsFile = globalSettingsFile.getCanonicalFile(); | |
162 | 178 | } |
163 | 179 | catch ( IOException e ) |
164 | 180 | { |
172 | 188 | |
173 | 189 | } |
174 | 190 | |
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 | */ | |
175 | 197 | protected void setToolchainsLocation( InvocationRequest request, Commandline cli ) |
176 | 198 | { |
177 | 199 | File toolchainsFile = request.getToolchainsFile(); |
180 | 202 | { |
181 | 203 | try |
182 | 204 | { |
183 | File canSet = toolchainsFile.getCanonicalFile(); | |
184 | toolchainsFile = canSet; | |
205 | toolchainsFile = toolchainsFile.getCanonicalFile(); | |
185 | 206 | } |
186 | 207 | catch ( IOException e ) |
187 | 208 | { |
194 | 215 | } |
195 | 216 | } |
196 | 217 | |
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 | */ | |
197 | 225 | protected void setShellEnvironment( InvocationRequest request, Commandline cli ) |
198 | 226 | throws CommandLineConfigurationException |
199 | 227 | { |
207 | 235 | // proper value |
208 | 236 | cli.addEnvironment( "M2_HOME", getMavenHome().getAbsolutePath() ); |
209 | 237 | } |
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; | |
214 | 241 | } |
215 | 242 | catch ( Exception e ) |
216 | 243 | { |
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 ); | |
230 | 246 | } |
231 | 247 | } |
232 | 248 | |
246 | 262 | } |
247 | 263 | } |
248 | 264 | |
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 | */ | |
249 | 271 | protected void setProfiles( InvocationRequest request, Commandline cli ) |
250 | 272 | { |
251 | 273 | List<String> profiles = request.getProfiles(); |
258 | 280 | |
259 | 281 | } |
260 | 282 | |
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 | |
262 | 291 | { |
263 | 292 | List<String> goals = request.getGoals(); |
264 | 293 | |
265 | 294 | if ( ( goals != null ) && !goals.isEmpty() ) |
266 | 295 | { |
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 | */ | |
271 | 313 | protected void setProperties( InvocationRequest request, Commandline cli ) |
272 | 314 | { |
273 | 315 | Properties properties = request.getProperties(); |
274 | 316 | |
275 | 317 | if ( properties != null ) |
276 | 318 | { |
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 | { | |
281 | 321 | String key = (String) entry.getKey(); |
282 | 322 | String value = (String) entry.getValue(); |
283 | 323 | |
287 | 327 | } |
288 | 328 | } |
289 | 329 | |
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 | */ | |
290 | 336 | protected void setPomLocation( InvocationRequest request, Commandline cli ) |
291 | 337 | { |
292 | 338 | boolean pomSpecified = false; |
328 | 374 | { |
329 | 375 | try |
330 | 376 | { |
331 | File canPom = pom.getCanonicalFile(); | |
332 | pom = canPom; | |
377 | pom = pom.getCanonicalFile(); | |
333 | 378 | } |
334 | 379 | catch ( IOException e ) |
335 | 380 | { |
338 | 383 | |
339 | 384 | if ( !"pom.xml".equals( pom.getName() ) ) |
340 | 385 | { |
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..." ); | |
343 | 388 | |
344 | 389 | cli.createArg().setValue( "-f" ); |
345 | 390 | cli.createArg().setValue( pom.getName() ); |
347 | 392 | } |
348 | 393 | } |
349 | 394 | |
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 | */ | |
350 | 401 | protected void setEnvironmentPaths( InvocationRequest request, Commandline cli ) |
351 | 402 | { |
352 | 403 | File workingDirectory = request.getBaseDirectory(); |
394 | 445 | { |
395 | 446 | try |
396 | 447 | { |
397 | File canLRD = localRepositoryDirectory.getCanonicalFile(); | |
398 | localRepositoryDirectory = canLRD; | |
448 | localRepositoryDirectory = localRepositoryDirectory.getCanonicalFile(); | |
399 | 449 | } |
400 | 450 | catch ( IOException e ) |
401 | 451 | { |
405 | 455 | |
406 | 456 | if ( !localRepositoryDirectory.isDirectory() ) |
407 | 457 | { |
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." ); | |
410 | 460 | } |
411 | 461 | |
412 | 462 | cli.createArg().setValue( "-D" ); |
414 | 464 | } |
415 | 465 | } |
416 | 466 | |
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 | */ | |
417 | 473 | protected void setReactorBehavior( InvocationRequest request, Commandline cli ) |
418 | 474 | { |
419 | 475 | // NOTE: The default is "fail-fast" |
456 | 512 | } |
457 | 513 | } |
458 | 514 | |
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 | */ | |
459 | 521 | protected void setFlags( InvocationRequest request, Commandline cli ) |
460 | 522 | { |
461 | 523 | if ( request.isBatchMode() ) |
512 | 574 | { |
513 | 575 | cli.createArg().setValue( request.getBuilder() ); |
514 | 576 | } |
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 | */ | |
517 | 590 | protected void setThreads( InvocationRequest request, Commandline cli ) |
518 | 591 | { |
519 | 592 | String threads = request.getThreads(); |
525 | 598 | |
526 | 599 | } |
527 | 600 | |
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 | */ | |
528 | 608 | protected File findMavenExecutable() |
529 | 609 | throws CommandLineConfigurationException, IOException |
530 | 610 | { |
545 | 625 | } |
546 | 626 | else |
547 | 627 | { |
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 + "'." ); | |
550 | 630 | } |
551 | 631 | } |
552 | 632 | } |
557 | 637 | } |
558 | 638 | } |
559 | 639 | |
560 | logger.debug( "Using ${maven.home} of: \'" + mavenHome + "\'." ); | |
640 | logger.debug( "Using ${maven.home} of: '" + mavenHome + "'." ); | |
561 | 641 | |
562 | 642 | if ( mavenExecutable == null || !mavenExecutable.isAbsolute() ) |
563 | 643 | { |
586 | 666 | |
587 | 667 | try |
588 | 668 | { |
589 | File canonicalMvn = mavenExecutable.getCanonicalFile(); | |
590 | mavenExecutable = canonicalMvn; | |
669 | mavenExecutable = mavenExecutable.getCanonicalFile(); | |
591 | 670 | } |
592 | 671 | catch ( IOException e ) |
593 | 672 | { |
604 | 683 | } |
605 | 684 | |
606 | 685 | private Properties getSystemEnvVars() |
607 | throws IOException | |
608 | 686 | { |
609 | 687 | if ( this.systemEnvVars == null ) |
610 | 688 | { |
614 | 692 | return this.systemEnvVars; |
615 | 693 | } |
616 | 694 | |
695 | /** | |
696 | * <p>Getter for the field <code>localRepositoryDirectory</code>.</p> | |
697 | * | |
698 | * @return a {@link java.io.File} object. | |
699 | */ | |
617 | 700 | public File getLocalRepositoryDirectory() |
618 | 701 | { |
619 | 702 | return localRepositoryDirectory; |
620 | 703 | } |
621 | 704 | |
705 | /** | |
706 | * <p>Setter for the field <code>localRepositoryDirectory</code>.</p> | |
707 | * | |
708 | * @param localRepositoryDirectory a {@link java.io.File} object. | |
709 | */ | |
622 | 710 | public void setLocalRepositoryDirectory( File localRepositoryDirectory ) |
623 | 711 | { |
624 | 712 | this.localRepositoryDirectory = localRepositoryDirectory; |
625 | 713 | } |
626 | 714 | |
715 | /** | |
716 | * <p>Getter for the field <code>logger</code>.</p> | |
717 | * | |
718 | * @return a {@link org.apache.maven.shared.invoker.InvokerLogger} object. | |
719 | */ | |
627 | 720 | public InvokerLogger getLogger() |
628 | 721 | { |
629 | 722 | return logger; |
630 | 723 | } |
631 | 724 | |
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 | */ | |
632 | 730 | public void setLogger( InvokerLogger logger ) |
633 | 731 | { |
634 | 732 | this.logger = logger; |
635 | 733 | } |
636 | 734 | |
735 | /** | |
736 | * <p>Getter for the field <code>mavenHome</code>.</p> | |
737 | * | |
738 | * @return a {@link java.io.File} object. | |
739 | */ | |
637 | 740 | public File getMavenHome() |
638 | 741 | { |
639 | 742 | return mavenHome; |
640 | 743 | } |
641 | 744 | |
745 | /** | |
746 | * <p>Setter for the field <code>mavenHome</code>.</p> | |
747 | * | |
748 | * @param mavenHome a {@link java.io.File} object. | |
749 | */ | |
642 | 750 | public void setMavenHome( File mavenHome ) |
643 | 751 | { |
644 | 752 | this.mavenHome = mavenHome; |
645 | 753 | } |
646 | 754 | |
755 | /** | |
756 | * <p>Getter for the field <code>workingDirectory</code>.</p> | |
757 | * | |
758 | * @return a {@link java.io.File} object. | |
759 | */ | |
647 | 760 | public File getWorkingDirectory() |
648 | 761 | { |
649 | 762 | return workingDirectory; |
650 | 763 | } |
651 | 764 | |
765 | /** | |
766 | * <p>Setter for the field <code>workingDirectory</code>.</p> | |
767 | * | |
768 | * @param workingDirectory a {@link java.io.File} object. | |
769 | */ | |
652 | 770 | public void setWorkingDirectory( File workingDirectory ) |
653 | 771 | { |
654 | 772 | this.workingDirectory = workingDirectory; |
656 | 774 | |
657 | 775 | /** |
658 | 776 | * {@code mavenExecutable} can either be relative to ${maven.home}/bin/ or absolute |
659 | * | |
777 | * | |
660 | 778 | * @param mavenExecutable the executable |
661 | 779 | */ |
662 | 780 | public void setMavenExecutable( File mavenExecutable ) |
664 | 782 | this.mavenExecutable = mavenExecutable; |
665 | 783 | } |
666 | 784 | |
785 | /** | |
786 | * <p>Getter for the field <code>mavenExecutable</code>.</p> | |
787 | * | |
788 | * @return a {@link java.io.File} object. | |
789 | */ | |
667 | 790 | public File getMavenExecutable() |
668 | 791 | { |
669 | 792 | return mavenExecutable; |
22 | 22 | * Signals an error during the construction of the command line used to invoke Maven, e.g. illegal invocation arguments. |
23 | 23 | * This should not be confused with a failure of the invoked Maven build itself which will be reported by means of a |
24 | 24 | * non-zero exit code. |
25 | * | |
25 | * | |
26 | 26 | * @see InvocationResult#getExitCode() |
27 | * @version $Id: MavenInvocationException.java 662043 2008-05-31 16:27:02Z bentmann $ | |
28 | 27 | */ |
29 | 28 | public class MavenInvocationException |
30 | 29 | extends Exception |
34 | 33 | |
35 | 34 | /** |
36 | 35 | * Creates a new exception using the specified detail message and cause. |
37 | * | |
36 | * | |
38 | 37 | * @param message The detail message for this exception, may be <code>null</code>. |
39 | 38 | * @param cause The nested exception, may be <code>null</code>. |
40 | 39 | */ |
45 | 44 | |
46 | 45 | /** |
47 | 46 | * Creates a new exception using the specified detail message. |
48 | * | |
47 | * | |
49 | 48 | * @param message The detail message for this exception, may be <code>null</code>. |
50 | 49 | */ |
51 | 50 | public MavenInvocationException( String message ) |
21 | 21 | import java.io.PrintStream; |
22 | 22 | |
23 | 23 | /** |
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 | * | |
27 | 26 | * @since 2.0.9 |
28 | 27 | */ |
29 | 28 | public class PrintStreamHandler |
41 | 40 | private boolean alwaysFlush; |
42 | 41 | |
43 | 42 | /** |
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}. | |
45 | 44 | */ |
46 | 45 | public PrintStreamHandler() |
47 | 46 | { |
50 | 49 | |
51 | 50 | /** |
52 | 51 | * Creates a new output handler that writes to the specified print stream. |
53 | * | |
52 | * | |
54 | 53 | * @param out The print stream to write to, must not be <code>null</code>. |
55 | 54 | * @param alwaysFlush A flag whether the print stream should be flushed after each line. |
56 | 55 | */ |
64 | 63 | this.alwaysFlush = alwaysFlush; |
65 | 64 | } |
66 | 65 | |
66 | /** {@inheritDoc} */ | |
67 | 67 | public void consumeLine( String line ) |
68 | 68 | { |
69 | 69 | if ( line == null ) |
23 | 23 | import java.io.StringWriter; |
24 | 24 | |
25 | 25 | /** |
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 | * | |
29 | 28 | * @since 2.0.9 |
30 | 29 | */ |
31 | 30 | public class PrintStreamLogger |
43 | 42 | private int threshold; |
44 | 43 | |
45 | 44 | /** |
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}. | |
47 | 46 | */ |
48 | 47 | public PrintStreamLogger() |
49 | 48 | { |
52 | 51 | |
53 | 52 | /** |
54 | 53 | * Creates a new logger that writes to the specified print stream. |
55 | * | |
54 | * | |
56 | 55 | * @param out The print stream to write to, must not be <code>null</code>. |
57 | 56 | * @param threshold The threshold for the logger. |
58 | 57 | */ |
87 | 86 | return; |
88 | 87 | } |
89 | 88 | |
90 | StringBuffer buffer = new StringBuffer(); | |
89 | StringBuilder buffer = new StringBuilder(); | |
91 | 90 | |
92 | 91 | switch ( level ) |
93 | 92 | { |
140 | 139 | out.println( buffer.toString() ); |
141 | 140 | } |
142 | 141 | |
142 | /** {@inheritDoc} */ | |
143 | 143 | public void debug( String message ) |
144 | 144 | { |
145 | 145 | log( DEBUG, message, null ); |
146 | 146 | } |
147 | 147 | |
148 | /** {@inheritDoc} */ | |
148 | 149 | public void debug( String message, Throwable throwable ) |
149 | 150 | { |
150 | 151 | log( DEBUG, message, throwable ); |
151 | 152 | } |
152 | 153 | |
154 | /** {@inheritDoc} */ | |
153 | 155 | public void info( String message ) |
154 | 156 | { |
155 | 157 | log( INFO, message, null ); |
156 | 158 | } |
157 | 159 | |
160 | /** {@inheritDoc} */ | |
158 | 161 | public void info( String message, Throwable throwable ) |
159 | 162 | { |
160 | 163 | log( INFO, message, throwable ); |
161 | 164 | } |
162 | 165 | |
166 | /** {@inheritDoc} */ | |
163 | 167 | public void warn( String message ) |
164 | 168 | { |
165 | 169 | log( WARN, message, null ); |
166 | 170 | } |
167 | 171 | |
172 | /** {@inheritDoc} */ | |
168 | 173 | public void warn( String message, Throwable throwable ) |
169 | 174 | { |
170 | 175 | log( WARN, message, throwable ); |
171 | 176 | } |
172 | 177 | |
178 | /** {@inheritDoc} */ | |
173 | 179 | public void error( String message ) |
174 | 180 | { |
175 | 181 | log( ERROR, message, null ); |
176 | 182 | } |
177 | 183 | |
184 | /** {@inheritDoc} */ | |
178 | 185 | public void error( String message, Throwable throwable ) |
179 | 186 | { |
180 | 187 | log( ERROR, message, throwable ); |
181 | 188 | } |
182 | 189 | |
190 | /** {@inheritDoc} */ | |
183 | 191 | public void fatalError( String message ) |
184 | 192 | { |
185 | 193 | log( FATAL, message, null ); |
186 | 194 | } |
187 | 195 | |
196 | /** {@inheritDoc} */ | |
188 | 197 | public void fatalError( String message, Throwable throwable ) |
189 | 198 | { |
190 | 199 | log( FATAL, message, throwable ); |
191 | 200 | } |
192 | 201 | |
202 | /** | |
203 | * <p>isDebugEnabled.</p> | |
204 | * | |
205 | * @return a boolean. | |
206 | */ | |
193 | 207 | public boolean isDebugEnabled() |
194 | 208 | { |
195 | 209 | return threshold >= DEBUG; |
196 | 210 | } |
197 | 211 | |
212 | /** | |
213 | * <p>isErrorEnabled.</p> | |
214 | * | |
215 | * @return a boolean. | |
216 | */ | |
198 | 217 | public boolean isErrorEnabled() |
199 | 218 | { |
200 | 219 | return threshold >= ERROR; |
201 | 220 | } |
202 | 221 | |
222 | /** | |
223 | * <p>isFatalErrorEnabled.</p> | |
224 | * | |
225 | * @return a boolean. | |
226 | */ | |
203 | 227 | public boolean isFatalErrorEnabled() |
204 | 228 | { |
205 | 229 | return threshold >= FATAL; |
206 | 230 | } |
207 | 231 | |
232 | /** | |
233 | * <p>isInfoEnabled.</p> | |
234 | * | |
235 | * @return a boolean. | |
236 | */ | |
208 | 237 | public boolean isInfoEnabled() |
209 | 238 | { |
210 | 239 | return threshold >= INFO; |
211 | 240 | } |
212 | 241 | |
242 | /** | |
243 | * <p>isWarnEnabled.</p> | |
244 | * | |
245 | * @return a boolean. | |
246 | */ | |
213 | 247 | public boolean isWarnEnabled() |
214 | 248 | { |
215 | 249 | return threshold >= WARN; |
216 | 250 | } |
217 | 251 | |
252 | /** | |
253 | * <p>Getter for the field <code>threshold</code>.</p> | |
254 | * | |
255 | * @return a int. | |
256 | */ | |
218 | 257 | public int getThreshold() |
219 | 258 | { |
220 | 259 | return threshold; |
221 | 260 | } |
222 | 261 | |
262 | /** {@inheritDoc} */ | |
223 | 263 | public void setThreshold( int threshold ) |
224 | 264 | { |
225 | 265 | this.threshold = threshold; |
19 | 19 | */ |
20 | 20 | |
21 | 21 | /** |
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 | * | |
25 | 24 | */ |
26 | 25 | public class SystemOutHandler |
27 | 26 | extends PrintStreamHandler |
37 | 36 | |
38 | 37 | /** |
39 | 38 | * Creates a new output handler. |
40 | * | |
39 | * | |
41 | 40 | * @param alwaysFlush A flag whether the print stream should be flushed after each line. |
42 | 41 | */ |
43 | 42 | public SystemOutHandler( boolean alwaysFlush ) |
19 | 19 | */ |
20 | 20 | |
21 | 21 | /** |
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 | * | |
25 | 24 | */ |
26 | 25 | public class SystemOutLogger |
27 | 26 | extends PrintStreamLogger |
140 | 140 | <plugin> |
141 | 141 | <groupId>org.apache.maven.plugins</groupId> |
142 | 142 | <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 --> | |
144 | 144 | <configuration> |
145 | 145 | <systemPropertyVariables> |
146 | 146 | <maven.home>${maven.home}</maven.home> |
18 | 18 | under the License. |
19 | 19 | --> |
20 | 20 | |
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> | |
23 | 28 | <body> |
24 | 29 | <menu name="Overview"> |
25 | 30 | <item name="Introduction" href="index.html"/> |
28 | 33 | <item name="Source Xref" href="xref/index.html"/> |
29 | 34 | <!--item name="FAQ" href="faq.html"/--> |
30 | 35 | <!-- 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/"/> | |
32 | 37 | <item name="Download" href="download.html"/> |
33 | 38 | </menu> |
34 | 39 | </body> |
33 | 33 | |
34 | 34 | <p>In order to guard against corrupted downloads/installations, it is highly recommended to |
35 | 35 | <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 | |
37 | 37 | developers.</p> |
38 | 38 | |
39 | 39 | <p>${project.name} is distributed under the <a href="http://www.apache.org/licenses/">Apache License, version 2.0</a>.</p> |
107 | 107 | <tr> |
108 | 108 | <td>${project.name} ${project.version} (Source zip)</td> |
109 | 109 | <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> | |
112 | 112 | </tr> |
113 | 113 | </tbody> |
114 | 114 | </table> |
18 | 18 | * under the License. |
19 | 19 | */ |
20 | 20 | |
21 | import static org.junit.Assert.assertEquals; | |
22 | ||
23 | 21 | import java.io.File; |
24 | 22 | import java.io.IOException; |
25 | 23 | import java.net.URI; |
26 | 24 | import java.net.URISyntaxException; |
27 | 25 | import java.net.URL; |
28 | import java.util.ArrayList; | |
29 | import java.util.List; | |
26 | import java.util.Arrays; | |
27 | import java.util.Collections; | |
30 | 28 | import java.util.Properties; |
31 | 29 | |
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; | |
34 | 32 | import org.junit.Test; |
33 | ||
34 | import static org.junit.Assert.assertEquals; | |
35 | 35 | |
36 | 36 | public class DefaultInvokerTest |
37 | 37 | { |
46 | 46 | |
47 | 47 | InvocationRequest request = new DefaultInvocationRequest(); |
48 | 48 | 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() ); | |
57 | 52 | |
58 | 53 | InvocationResult result = invoker.execute( request ); |
59 | 54 | |
70 | 65 | |
71 | 66 | InvocationRequest request = new DefaultInvocationRequest(); |
72 | 67 | 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() ); | |
81 | 71 | |
82 | 72 | InvocationResult result = invoker.execute( request ); |
83 | 73 | |
85 | 75 | } |
86 | 76 | |
87 | 77 | @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 | |
88 | 108 | public void testSpacePom() |
89 | 109 | throws Exception |
90 | 110 | { |
96 | 116 | |
97 | 117 | InvocationRequest request = new DefaultInvocationRequest(); |
98 | 118 | request.setBaseDirectory( basedir ); |
99 | ||
100 | 119 | 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 | ||
109 | 124 | InvocationResult result = invoker.execute( request ); |
110 | 125 | |
111 | 126 | assertEquals( 0, result.getExitCode() ); |
123 | 138 | |
124 | 139 | InvocationRequest request = new DefaultInvocationRequest(); |
125 | 140 | request.setBaseDirectory( basedir ); |
126 | ||
127 | 141 | 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() ); | |
135 | 145 | |
136 | 146 | InvocationResult result = invoker.execute( request ); |
137 | 147 | |
150 | 160 | |
151 | 161 | InvocationRequest request = new DefaultInvocationRequest(); |
152 | 162 | request.setBaseDirectory( basedir ); |
153 | ||
154 | 163 | 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() ); | |
162 | 167 | |
163 | 168 | InvocationResult result = invoker.execute( request ); |
164 | 169 | |
177 | 182 | |
178 | 183 | InvocationRequest request = new DefaultInvocationRequest(); |
179 | 184 | request.setBaseDirectory( basedir ); |
180 | ||
181 | 185 | 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() ); | |
189 | 189 | |
190 | 190 | InvocationResult result = invoker.execute( request ); |
191 | 191 | |
205 | 205 | InvocationRequest request = new DefaultInvocationRequest(); |
206 | 206 | request.setBaseDirectory( basedir ); |
207 | 207 | |
208 | Properties props = new Properties(); | |
208 | Properties props = getProperties(); | |
209 | 209 | props.setProperty( "key", "value with spaces" ); |
210 | 210 | props.setProperty( "key with spaces", "value" ); |
211 | 211 | 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" ) ); | |
219 | 214 | |
220 | 215 | InvocationResult result = invoker.execute( request ); |
221 | 216 | |
223 | 218 | } |
224 | 219 | |
225 | 220 | private Invoker newInvoker() |
226 | throws IOException | |
227 | 221 | { |
228 | 222 | Invoker invoker = new DefaultInvoker(); |
229 | 223 | |
239 | 233 | } |
240 | 234 | |
241 | 235 | private File findMavenHome() |
242 | throws IOException | |
243 | 236 | { |
244 | 237 | String mavenHome = System.getProperty( "maven.home" ); |
245 | 238 | |
251 | 244 | if ( mavenHome == null ) |
252 | 245 | { |
253 | 246 | 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." ); | |
255 | 248 | } |
256 | 249 | |
257 | 250 | return new File( mavenHome ); |
282 | 275 | |
283 | 276 | if ( dirResource == null ) |
284 | 277 | { |
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." ); | |
286 | 280 | } |
287 | 281 | |
288 | 282 | return new File( new URI( dirResource.toString() ).getPath() ); |
296 | 290 | |
297 | 291 | System.out.println( "Starting: " + element.getMethodName() ); |
298 | 292 | } |
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 | } | |
300 | 310 | } |
18 | 18 | * under the License. |
19 | 19 | */ |
20 | 20 | |
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 | ||
26 | 21 | import java.io.File; |
27 | 22 | import java.io.FileWriter; |
28 | 23 | import java.io.IOException; |
34 | 29 | import java.util.Properties; |
35 | 30 | import java.util.Set; |
36 | 31 | |
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; | |
42 | 34 | import org.junit.After; |
43 | 35 | import org.junit.Assume; |
44 | 36 | import org.junit.Before; |
37 | import org.junit.Rule; | |
45 | 38 | 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; | |
46 | 48 | |
47 | 49 | public class MavenCommandLineBuilderTest |
48 | 50 | { |
49 | ||
50 | private List<File> toDelete = new ArrayList<File>(); | |
51 | @Rule | |
52 | public TemporaryFolder temporaryFolder = new TemporaryFolder(); | |
51 | 53 | |
52 | 54 | 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 | ||
54 | 78 | @Test |
55 | 79 | 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 | ||
65 | 82 | tcb.setLocalRepositoryDirectory( lrd ); |
66 | ||
67 | Commandline cli = new Commandline(); | |
68 | 83 | |
69 | 84 | try |
70 | 85 | { |
71 | 86 | tcb.setEnvironmentPaths( newRequest(), cli ); |
72 | 87 | fail( "Should not set local repo location to point to a file." ); |
73 | 88 | } |
74 | catch ( IllegalArgumentException e ) | |
75 | { | |
76 | assertTrue( true ); | |
89 | catch ( IllegalArgumentException expected ) | |
90 | { | |
77 | 91 | } |
78 | 92 | } |
79 | 93 | |
80 | 94 | @Test |
81 | 95 | 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 | { | |
94 | 97 | try |
95 | 98 | { |
96 | 99 | tcb.setEnvironmentPaths( newRequest().setLocalRepositoryDirectory( lrd ), cli ); |
97 | 100 | fail( "Should not set local repo location to point to a file." ); |
98 | 101 | } |
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(); | |
119 | 111 | tcb.setLocalRepositoryDirectory( lrd ); |
120 | ||
121 | Commandline cli = new Commandline(); | |
122 | ||
123 | 112 | tcb.setEnvironmentPaths( newRequest(), cli ); |
124 | 113 | |
125 | 114 | assertArgumentsPresentInOrder( cli, "-D", "maven.repo.local=" + lrd.getPath() ); |
129 | 118 | public void testShouldSetLocalRepoLocationFromRequest() |
130 | 119 | throws Exception |
131 | 120 | { |
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(); | |
145 | 122 | tcb.setEnvironmentPaths( newRequest().setLocalRepositoryDirectory( lrd ), cli ); |
146 | 123 | |
147 | 124 | assertArgumentsPresentInOrder( cli, "-D", "maven.repo.local=" + lrd.getPath() ); |
151 | 128 | public void testRequestProvidedLocalRepoLocationShouldOverrideGlobal() |
152 | 129 | throws Exception |
153 | 130 | { |
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 | ||
168 | 134 | tcb.setLocalRepositoryDirectory( glrd ); |
169 | ||
170 | Commandline cli = new Commandline(); | |
171 | ||
172 | 135 | tcb.setEnvironmentPaths( newRequest().setLocalRepositoryDirectory( lrd ), cli ); |
173 | 136 | |
174 | 137 | assertArgumentsPresentInOrder( cli, "-D", "maven.repo.local=" + lrd.getPath() ); |
178 | 141 | public void testShouldSetWorkingDirectoryGlobally() |
179 | 142 | throws Exception |
180 | 143 | { |
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" ); | |
192 | 145 | tcb.setWorkingDirectory( wd ); |
193 | ||
194 | Commandline cli = new Commandline(); | |
195 | ||
196 | 146 | tcb.setEnvironmentPaths( newRequest(), cli ); |
197 | 147 | |
198 | assertEquals( cli.getWorkingDirectory(), wd ); | |
148 | assertEquals( cli.getWorkingDirectory(), wd.getCanonicalFile() ); | |
199 | 149 | } |
200 | 150 | |
201 | 151 | @Test |
202 | 152 | public void testShouldSetWorkingDirectoryFromRequest() |
203 | 153 | throws Exception |
204 | 154 | { |
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 | ||
216 | 157 | InvocationRequest req = newRequest(); |
217 | 158 | req.setBaseDirectory( wd ); |
218 | 159 | |
219 | Commandline cli = new Commandline(); | |
220 | 160 | |
221 | 161 | tcb.setEnvironmentPaths( req, cli ); |
222 | 162 | |
223 | assertEquals( cli.getWorkingDirectory(), wd ); | |
163 | assertEquals( cli.getWorkingDirectory(), wd.getCanonicalFile() ); | |
224 | 164 | } |
225 | 165 | |
226 | 166 | @Test |
227 | 167 | public void testRequestProvidedWorkingDirectoryShouldOverrideGlobal() |
228 | 168 | throws Exception |
229 | 169 | { |
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 | ||
244 | 173 | tcb.setWorkingDirectory( gwd ); |
245 | 174 | |
246 | 175 | InvocationRequest req = newRequest(); |
247 | 176 | req.setBaseDirectory( wd ); |
248 | 177 | |
249 | Commandline cli = new Commandline(); | |
250 | 178 | |
251 | 179 | tcb.setEnvironmentPaths( req, cli ); |
252 | 180 | |
253 | assertEquals( cli.getWorkingDirectory(), wd ); | |
181 | assertEquals( cli.getWorkingDirectory(), wd.getCanonicalFile() ); | |
254 | 182 | } |
255 | 183 | |
256 | 184 | @Test |
257 | 185 | public void testShouldUseSystemOutLoggerWhenNoneSpecified() |
258 | 186 | throws Exception |
259 | 187 | { |
260 | logTestStart(); | |
261 | 188 | setupTempMavenHomeIfMissing( false ); |
262 | 189 | |
263 | 190 | TestCommandLineBuilder tclb = new TestCommandLineBuilder(); |
269 | 196 | { |
270 | 197 | String mavenHome = System.getProperty( "maven.home" ); |
271 | 198 | |
272 | File appDir = null; | |
199 | File appDir; | |
273 | 200 | |
274 | 201 | if ( forceDummy || ( mavenHome == null ) || !new File( mavenHome ).exists() ) |
275 | 202 | { |
276 | File tmpDir = getTempDir(); | |
277 | appDir = new File( tmpDir, "invoker-tests/maven-home" ); | |
203 | appDir = temporaryFolder.newFolder( "invoker-tests", "maven-home" ); | |
278 | 204 | |
279 | 205 | File binDir = new File( appDir, "bin" ); |
280 | ||
281 | 206 | binDir.mkdirs(); |
282 | toDelete.add( appDir ); | |
283 | 207 | |
284 | 208 | if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) |
285 | 209 | { |
304 | 228 | } |
305 | 229 | |
306 | 230 | @Test |
307 | public void testShouldFailIfLoggerSetToNull() | |
308 | { | |
309 | logTestStart(); | |
310 | ||
231 | public void testShouldFailIfLoggerSetToNull() throws Exception | |
232 | { | |
311 | 233 | TestCommandLineBuilder tclb = new TestCommandLineBuilder(); |
312 | 234 | tclb.setLogger( null ); |
313 | 235 | |
316 | 238 | tclb.checkRequiredState(); |
317 | 239 | fail( "Should not allow execution to proceed when logger is missing." ); |
318 | 240 | } |
319 | catch ( IllegalStateException e ) | |
320 | { | |
321 | assertTrue( true ); | |
322 | } | |
323 | catch ( IOException e ) | |
324 | { | |
325 | fail( e.getMessage() ); | |
241 | catch ( IllegalStateException expected ) | |
242 | { | |
326 | 243 | } |
327 | 244 | } |
328 | 245 | |
330 | 247 | public void testShouldFindDummyMavenExecutable() |
331 | 248 | throws Exception |
332 | 249 | { |
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" ); | |
344 | 251 | |
345 | 252 | File check; |
346 | 253 | if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) |
352 | 259 | check = createDummyFile( dummyMavenHomeBin, "mvn" ); |
353 | 260 | } |
354 | 261 | |
355 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
356 | 262 | tcb.setMavenHome( dummyMavenHomeBin.getParentFile() ); |
357 | 263 | |
358 | 264 | File mavenExe = tcb.findMavenExecutable(); |
363 | 269 | @Test |
364 | 270 | public void testShouldSetBatchModeFlagFromRequest() |
365 | 271 | { |
366 | logTestStart(); | |
367 | ||
368 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
369 | Commandline cli = new Commandline(); | |
370 | 272 | |
371 | 273 | tcb.setFlags( newRequest().setBatchMode( true ), cli ); |
372 | 274 | |
376 | 278 | @Test |
377 | 279 | public void testShouldSetOfflineFlagFromRequest() |
378 | 280 | { |
379 | logTestStart(); | |
380 | ||
381 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
382 | Commandline cli = new Commandline(); | |
383 | 281 | |
384 | 282 | tcb.setFlags( newRequest().setOffline( true ), cli ); |
385 | 283 | |
389 | 287 | @Test |
390 | 288 | public void testShouldSetUpdateSnapshotsFlagFromRequest() |
391 | 289 | { |
392 | logTestStart(); | |
393 | ||
394 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
395 | Commandline cli = new Commandline(); | |
396 | 290 | |
397 | 291 | tcb.setFlags( newRequest().setUpdateSnapshots( true ), cli ); |
398 | 292 | |
402 | 296 | @Test |
403 | 297 | public void testShouldSetDebugFlagFromRequest() |
404 | 298 | { |
405 | logTestStart(); | |
406 | ||
407 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
408 | Commandline cli = new Commandline(); | |
409 | 299 | |
410 | 300 | tcb.setFlags( newRequest().setDebug( true ), cli ); |
411 | 301 | |
415 | 305 | @Test |
416 | 306 | public void testShouldSetErrorFlagFromRequest() |
417 | 307 | { |
418 | logTestStart(); | |
419 | ||
420 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
421 | Commandline cli = new Commandline(); | |
422 | 308 | |
423 | 309 | tcb.setFlags( newRequest().setShowErrors( true ), cli ); |
424 | 310 | |
426 | 312 | } |
427 | 313 | |
428 | 314 | @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 | |
429 | 324 | public void testDebugOptionShouldMaskShowErrorsOption() |
430 | 325 | { |
431 | logTestStart(); | |
432 | ||
433 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
434 | Commandline cli = new Commandline(); | |
435 | 326 | |
436 | 327 | tcb.setFlags( newRequest().setDebug( true ).setShowErrors( true ), cli ); |
437 | 328 | |
442 | 333 | @Test |
443 | 334 | public void testAlsoMake() |
444 | 335 | { |
445 | logTestStart(); | |
446 | ||
447 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
448 | Commandline cli = new Commandline(); | |
449 | 336 | |
450 | 337 | tcb.setReactorBehavior( newRequest().setAlsoMake( true ), cli ); |
451 | 338 | |
456 | 343 | @Test |
457 | 344 | public void testProjectsAndAlsoMake() |
458 | 345 | { |
459 | logTestStart(); | |
460 | ||
461 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
462 | Commandline cli = new Commandline(); | |
463 | 346 | |
464 | 347 | tcb.setReactorBehavior( newRequest().setProjects( Collections.singletonList( "proj1" ) ).setAlsoMake( true ), |
465 | 348 | cli ); |
470 | 353 | @Test |
471 | 354 | public void testAlsoMakeDependents() |
472 | 355 | { |
473 | logTestStart(); | |
474 | ||
475 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
476 | Commandline cli = new Commandline(); | |
477 | 356 | |
478 | 357 | tcb.setReactorBehavior( newRequest().setAlsoMakeDependents( true ), cli ); |
479 | 358 | |
484 | 363 | @Test |
485 | 364 | public void testProjectsAndAlsoMakeDependents() |
486 | 365 | { |
487 | logTestStart(); | |
488 | ||
489 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
490 | Commandline cli = new Commandline(); | |
491 | 366 | |
492 | 367 | tcb.setReactorBehavior( newRequest().setProjects( Collections.singletonList( "proj1" ) ).setAlsoMakeDependents( true ), |
493 | 368 | cli ); |
498 | 373 | @Test |
499 | 374 | public void testProjectsAndAlsoMakeAndAlsoMakeDependents() |
500 | 375 | { |
501 | logTestStart(); | |
502 | ||
503 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
504 | Commandline cli = new Commandline(); | |
505 | 376 | |
506 | 377 | tcb.setReactorBehavior( newRequest().setProjects( Collections.singletonList( "proj1" ) ).setAlsoMake( true ).setAlsoMakeDependents( true ), |
507 | 378 | cli ); |
512 | 383 | @Test |
513 | 384 | public void testShouldSetResumeFrom() |
514 | 385 | { |
515 | logTestStart(); | |
516 | ||
517 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
518 | Commandline cli = new Commandline(); | |
519 | 386 | |
520 | 387 | tcb.setReactorBehavior( newRequest().setResumeFrom( ":module3" ), cli ); |
521 | 388 | |
525 | 392 | @Test |
526 | 393 | public void testShouldSetStrictChecksumPolityFlagFromRequest() |
527 | 394 | { |
528 | logTestStart(); | |
529 | ||
530 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
531 | Commandline cli = new Commandline(); | |
532 | 395 | |
533 | 396 | tcb.setFlags( newRequest().setGlobalChecksumPolicy( InvocationRequest.CheckSumPolicy.Fail ), cli ); |
534 | 397 | |
538 | 401 | @Test |
539 | 402 | public void testShouldSetLaxChecksumPolicyFlagFromRequest() |
540 | 403 | { |
541 | logTestStart(); | |
542 | ||
543 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
544 | Commandline cli = new Commandline(); | |
545 | 404 | |
546 | 405 | tcb.setFlags( newRequest().setGlobalChecksumPolicy( InvocationRequest.CheckSumPolicy.Warn ), cli ); |
547 | 406 | |
551 | 410 | @Test |
552 | 411 | public void testShouldSetFailAtEndFlagFromRequest() |
553 | 412 | { |
554 | logTestStart(); | |
555 | ||
556 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
557 | Commandline cli = new Commandline(); | |
558 | 413 | |
559 | 414 | tcb.setReactorBehavior( newRequest().setReactorFailureBehavior( InvocationRequest.ReactorFailureBehavior.FailAtEnd ), |
560 | 415 | cli ); |
565 | 420 | @Test |
566 | 421 | public void testShouldSetFailNeverFlagFromRequest() |
567 | 422 | { |
568 | logTestStart(); | |
569 | ||
570 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
571 | Commandline cli = new Commandline(); | |
572 | 423 | |
573 | 424 | tcb.setReactorBehavior( newRequest().setReactorFailureBehavior( InvocationRequest.ReactorFailureBehavior.FailNever ), |
574 | 425 | cli ); |
579 | 430 | @Test |
580 | 431 | public void testShouldUseDefaultOfFailFastWhenSpecifiedInRequest() |
581 | 432 | { |
582 | logTestStart(); | |
583 | ||
584 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
585 | Commandline cli = new Commandline(); | |
586 | 433 | |
587 | 434 | tcb.setReactorBehavior( newRequest().setReactorFailureBehavior( InvocationRequest.ReactorFailureBehavior.FailFast ), |
588 | 435 | cli ); |
589 | 436 | |
590 | Set<String> banned = new HashSet<String>(); | |
437 | Set<String> banned = new HashSet<>(); | |
591 | 438 | banned.add( "-fae" ); |
592 | 439 | banned.add( "-fn" ); |
593 | 440 | |
598 | 445 | public void testShouldSpecifyFileOptionUsingNonStandardPomFileLocation() |
599 | 446 | throws Exception |
600 | 447 | { |
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" ); | |
611 | 449 | |
612 | 450 | File pomFile = createDummyFile( projectDir, "non-standard-pom.xml" ).getCanonicalFile(); |
613 | 451 | |
614 | Commandline cli = new Commandline(); | |
615 | 452 | |
616 | 453 | InvocationRequest req = newRequest().setPomFile( pomFile ); |
617 | 454 | |
618 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
619 | 455 | tcb.setEnvironmentPaths( req, cli ); |
620 | 456 | tcb.setPomLocation( req, cli ); |
621 | 457 | |
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<>(); | |
625 | 461 | args.add( "-f" ); |
626 | 462 | args.add( "non-standard-pom.xml" ); |
627 | 463 | |
632 | 468 | public void testShouldSpecifyFileOptionUsingNonStandardPomInBasedir() |
633 | 469 | throws Exception |
634 | 470 | { |
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" ); | |
645 | 472 | |
646 | 473 | File basedir = createDummyFile( projectDir, "non-standard-pom.xml" ).getCanonicalFile(); |
647 | 474 | |
648 | Commandline cli = new Commandline(); | |
649 | 475 | |
650 | 476 | InvocationRequest req = newRequest().setBaseDirectory( basedir ); |
651 | 477 | |
652 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
653 | 478 | tcb.setEnvironmentPaths( req, cli ); |
654 | 479 | tcb.setPomLocation( req, cli ); |
655 | 480 | |
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<>(); | |
659 | 484 | args.add( "-f" ); |
660 | 485 | args.add( "non-standard-pom.xml" ); |
661 | 486 | |
666 | 491 | public void testShouldNotSpecifyFileOptionUsingStandardPomFileLocation() |
667 | 492 | throws Exception |
668 | 493 | { |
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" ); | |
679 | 495 | |
680 | 496 | File pomFile = createDummyFile( projectDir, "pom.xml" ).getCanonicalFile(); |
681 | 497 | |
682 | Commandline cli = new Commandline(); | |
683 | 498 | |
684 | 499 | InvocationRequest req = newRequest().setPomFile( pomFile ); |
685 | 500 | |
686 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
687 | 501 | tcb.setEnvironmentPaths( req, cli ); |
688 | 502 | tcb.setPomLocation( req, cli ); |
689 | 503 | |
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<>(); | |
693 | 507 | args.add( "-f" ); |
694 | 508 | args.add( "pom.xml" ); |
695 | 509 | |
700 | 514 | public void testShouldNotSpecifyFileOptionUsingStandardPomInBasedir() |
701 | 515 | throws Exception |
702 | 516 | { |
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" ); | |
713 | 518 | |
714 | 519 | File basedir = createDummyFile( projectDir, "pom.xml" ).getCanonicalFile(); |
715 | 520 | |
716 | Commandline cli = new Commandline(); | |
717 | 521 | |
718 | 522 | InvocationRequest req = newRequest().setBaseDirectory( basedir ); |
719 | 523 | |
720 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
721 | 524 | tcb.setEnvironmentPaths( req, cli ); |
722 | 525 | tcb.setPomLocation( req, cli ); |
723 | 526 | |
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<>(); | |
727 | 530 | args.add( "-f" ); |
728 | 531 | args.add( "pom.xml" ); |
729 | 532 | |
734 | 537 | public void testShouldUseDefaultPomFileWhenBasedirSpecifiedWithoutPomFileName() |
735 | 538 | throws Exception |
736 | 539 | { |
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 | ||
749 | 542 | |
750 | 543 | InvocationRequest req = newRequest().setBaseDirectory( projectDir ); |
751 | 544 | |
752 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
753 | 545 | tcb.setEnvironmentPaths( req, cli ); |
754 | 546 | tcb.setPomLocation( req, cli ); |
755 | 547 | |
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<>(); | |
759 | 551 | args.add( "-f" ); |
760 | 552 | args.add( "pom.xml" ); |
761 | 553 | |
766 | 558 | public void testShouldSpecifyPomFileWhenBasedirSpecifiedWithPomFileName() |
767 | 559 | throws Exception |
768 | 560 | { |
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 | ||
781 | 563 | |
782 | 564 | InvocationRequest req = newRequest().setBaseDirectory( projectDir ).setPomFileName( "non-standard-pom.xml" ); |
783 | 565 | |
784 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
785 | 566 | tcb.setEnvironmentPaths( req, cli ); |
786 | 567 | tcb.setPomLocation( req, cli ); |
787 | 568 | |
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<>(); | |
791 | 572 | args.add( "-f" ); |
792 | 573 | args.add( "non-standard-pom.xml" ); |
793 | 574 | |
798 | 579 | public void testShouldSpecifyCustomUserSettingsLocationFromRequest() |
799 | 580 | throws Exception |
800 | 581 | { |
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" ); | |
811 | 583 | |
812 | 584 | File settingsFile = createDummyFile( projectDir, "settings.xml" ); |
813 | 585 | |
814 | Commandline cli = new Commandline(); | |
815 | ||
816 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
586 | ||
817 | 587 | tcb.setSettingsLocation( newRequest().setUserSettingsFile( settingsFile ), cli ); |
818 | 588 | |
819 | Set<String> args = new HashSet<String>(); | |
589 | Set<String> args = new HashSet<>(); | |
820 | 590 | args.add( "-s" ); |
821 | 591 | args.add( settingsFile.getCanonicalPath() ); |
822 | 592 | |
827 | 597 | public void testShouldSpecifyCustomGlobalSettingsLocationFromRequest() |
828 | 598 | throws Exception |
829 | 599 | { |
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(); | |
840 | 601 | |
841 | 602 | File settingsFile = createDummyFile( projectDir, "settings.xml" ); |
842 | 603 | |
843 | Commandline cli = new Commandline(); | |
844 | ||
845 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
604 | ||
846 | 605 | tcb.setSettingsLocation( newRequest().setGlobalSettingsFile( settingsFile ), cli ); |
847 | 606 | |
848 | Set<String> args = new HashSet<String>(); | |
607 | Set<String> args = new HashSet<>(); | |
849 | 608 | args.add( "-gs" ); |
850 | 609 | args.add( settingsFile.getCanonicalPath() ); |
851 | 610 | |
856 | 615 | public void testShouldSpecifyCustomToolchainsLocationFromRequest() |
857 | 616 | throws Exception |
858 | 617 | { |
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" ); | |
869 | 619 | |
870 | 620 | File toolchainsFile = createDummyFile( projectDir, "toolchains.xml" ); |
871 | 621 | |
872 | Commandline cli = new Commandline(); | |
873 | ||
874 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
622 | ||
875 | 623 | tcb.setToolchainsLocation( newRequest().setToolchainsFile( toolchainsFile ), cli ); |
876 | 624 | |
877 | Set<String> args = new HashSet<String>(); | |
625 | Set<String> args = new HashSet<>(); | |
878 | 626 | args.add( "-t" ); |
879 | 627 | args.add( toolchainsFile.getCanonicalPath() ); |
880 | 628 | |
883 | 631 | |
884 | 632 | @Test |
885 | 633 | public void testShouldSpecifyCustomPropertyFromRequest() |
886 | throws IOException | |
887 | { | |
888 | logTestStart(); | |
889 | ||
890 | Commandline cli = new Commandline(); | |
634 | { | |
891 | 635 | |
892 | 636 | Properties properties = new Properties(); |
893 | 637 | properties.setProperty( "key", "value" ); |
894 | 638 | |
895 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
896 | 639 | tcb.setProperties( newRequest().setProperties( properties ), cli ); |
897 | 640 | |
898 | 641 | assertArgumentsPresentInOrder( cli, "-D", "key=value" ); |
900 | 643 | |
901 | 644 | @Test |
902 | 645 | public void testShouldSpecifyCustomPropertyWithSpacesInValueFromRequest() |
903 | throws IOException | |
904 | { | |
905 | logTestStart(); | |
906 | ||
907 | Commandline cli = new Commandline(); | |
646 | { | |
908 | 647 | |
909 | 648 | Properties properties = new Properties(); |
910 | 649 | properties.setProperty( "key", "value with spaces" ); |
911 | 650 | |
912 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
913 | 651 | tcb.setProperties( newRequest().setProperties( properties ), cli ); |
914 | 652 | |
915 | 653 | assertArgumentsPresentInOrder( cli, "-D", "key=value with spaces" ); |
917 | 655 | |
918 | 656 | @Test |
919 | 657 | public void testShouldSpecifyCustomPropertyWithSpacesInKeyFromRequest() |
920 | throws IOException | |
921 | { | |
922 | logTestStart(); | |
923 | ||
924 | Commandline cli = new Commandline(); | |
658 | { | |
925 | 659 | |
926 | 660 | Properties properties = new Properties(); |
927 | 661 | properties.setProperty( "key with spaces", "value with spaces" ); |
928 | 662 | |
929 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
930 | 663 | tcb.setProperties( newRequest().setProperties( properties ), cli ); |
931 | 664 | |
932 | 665 | assertArgumentsPresentInOrder( cli, "-D", "key with spaces=value with spaces" ); |
933 | 666 | } |
934 | 667 | |
935 | 668 | @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<>(); | |
944 | 673 | goals.add( "test" ); |
945 | 674 | |
946 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
947 | 675 | tcb.setGoals( newRequest().setGoals( goals ), cli ); |
948 | 676 | |
949 | 677 | assertArgumentsPresent( cli, Collections.singleton( "test" ) ); |
950 | 678 | } |
951 | 679 | |
952 | 680 | @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<>(); | |
961 | 684 | goals.add( "test" ); |
962 | 685 | goals.add( "clean" ); |
963 | 686 | |
964 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
965 | 687 | tcb.setGoals( newRequest().setGoals( goals ), cli ); |
966 | 688 | |
967 | assertArgumentsPresent( cli, new HashSet<String>( goals ) ); | |
689 | assertArgumentsPresent( cli, new HashSet<>( goals ) ); | |
968 | 690 | assertArgumentsPresentInOrder( cli, goals ); |
969 | 691 | } |
970 | 692 | |
971 | 693 | @Test |
972 | 694 | public void testShouldSpecifyThreadsFromRequest() |
973 | throws IOException | |
974 | { | |
975 | logTestStart(); | |
976 | ||
977 | Commandline cli = new Commandline(); | |
978 | ||
979 | TestCommandLineBuilder tcb = new TestCommandLineBuilder(); | |
695 | { | |
980 | 696 | tcb.setThreads( newRequest().setThreads( "2.0C" ), cli ); |
981 | 697 | |
982 | 698 | assertArgumentsPresentInOrder( cli, "-T", "2.0C" ); |
986 | 702 | public void testBuildTypicalMavenInvocationEndToEnd() |
987 | 703 | throws Exception |
988 | 704 | { |
989 | logTestStart(); | |
990 | 705 | File mavenDir = setupTempMavenHomeIfMissing( false ); |
991 | 706 | |
992 | 707 | InvocationRequest request = newRequest(); |
993 | 708 | |
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" ); | |
999 | 710 | |
1000 | 711 | request.setBaseDirectory( projectDir ); |
1001 | 712 | |
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<>(); | |
1004 | 715 | |
1005 | 716 | createDummyFile( projectDir, "pom.xml" ); |
1006 | 717 | |
1019 | 730 | |
1020 | 731 | expectedArgs.add( "-o" ); |
1021 | 732 | |
1022 | List<String> goals = new ArrayList<String>(); | |
733 | List<String> goals = new ArrayList<>(); | |
1023 | 734 | |
1024 | 735 | goals.add( "post-clean" ); |
1025 | 736 | goals.add( "deploy" ); |
1037 | 748 | |
1038 | 749 | String executable = commandline.getExecutable(); |
1039 | 750 | |
1040 | assertTrue( executable.indexOf( new File( mavenDir, "bin/mvn" ).getCanonicalPath() ) > -1 ); | |
751 | assertTrue( executable.contains( new File( mavenDir, "bin/mvn" ).getCanonicalPath() ) ); | |
1041 | 752 | assertEquals( projectDir.getCanonicalPath(), commandline.getWorkingDirectory().getCanonicalPath() ); |
1042 | 753 | } |
1043 | 754 | |
1045 | 756 | public void testShouldSetEnvVar_MAVEN_TERMINATE_CMD() |
1046 | 757 | throws Exception |
1047 | 758 | { |
1048 | logTestStart(); | |
1049 | 759 | setupTempMavenHomeIfMissing( false ); |
1050 | 760 | |
1051 | 761 | InvocationRequest request = newRequest(); |
1052 | 762 | |
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" ); | |
1058 | 764 | |
1059 | 765 | request.setBaseDirectory( projectDir ); |
1060 | 766 | |
1061 | 767 | createDummyFile( projectDir, "pom.xml" ); |
1062 | 768 | |
1063 | List<String> goals = new ArrayList<String>(); | |
769 | List<String> goals = new ArrayList<>(); | |
1064 | 770 | |
1065 | 771 | goals.add( "clean" ); |
1066 | 772 | request.setGoals( goals ); |
1071 | 777 | |
1072 | 778 | String[] environmentVariables = commandline.getEnvironmentVariables(); |
1073 | 779 | String envVarMavenTerminateCmd = null; |
1074 | for ( int i = 0; i < environmentVariables.length; i++ ) | |
1075 | { | |
1076 | String envVar = environmentVariables[i]; | |
780 | for ( String envVar : environmentVariables ) | |
781 | { | |
1077 | 782 | if ( envVar.startsWith( "MAVEN_TERMINATE_CMD=" ) ) |
1078 | 783 | { |
1079 | 784 | envVarMavenTerminateCmd = envVar; |
1095 | 800 | |
1096 | 801 | InvocationRequest request = newRequest(); |
1097 | 802 | |
1098 | List<String> profiles = new ArrayList<String>(); | |
803 | List<String> profiles = new ArrayList<>(); | |
1099 | 804 | profiles.add( profile1 ); |
1100 | 805 | profiles.add( profile2 ); |
1101 | 806 | |
1114 | 819 | { |
1115 | 820 | Assume.assumeNotNull( System.getenv( "M2_HOME" ) ); |
1116 | 821 | |
1117 | logTestStart(); | |
1118 | 822 | setupTempMavenHomeIfMissing( true ); |
1119 | 823 | |
1120 | 824 | InvocationRequest request = newRequest(); |
1121 | 825 | |
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" ); | |
1127 | 827 | |
1128 | 828 | request.setBaseDirectory( projectDir ); |
1129 | 829 | |
1130 | 830 | createDummyFile( projectDir, "pom.xml" ); |
1131 | 831 | |
1132 | List<String> goals = new ArrayList<String>(); | |
832 | List<String> goals = new ArrayList<>(); | |
1133 | 833 | |
1134 | 834 | goals.add( "clean" ); |
1135 | 835 | request.setGoals( goals ); |
1142 | 842 | |
1143 | 843 | String[] environmentVariables = commandline.getEnvironmentVariables(); |
1144 | 844 | String m2Home = null; |
1145 | for ( int i = 0; i < environmentVariables.length; i++ ) | |
1146 | { | |
1147 | String envVar = environmentVariables[i]; | |
845 | for ( String envVar : environmentVariables ) | |
846 | { | |
1148 | 847 | if ( envVar.startsWith( "M2_HOME=" ) ) |
1149 | 848 | { |
1150 | 849 | m2Home = envVar; |
1157 | 856 | public void testMvnCommand() |
1158 | 857 | throws Exception |
1159 | 858 | { |
859 | assumeThat( "Test only works when called with surefire", System.getProperty( "maven.home" ), | |
860 | is( notNullValue() ) ); | |
1160 | 861 | MavenCommandLineBuilder commandLineBuilder = new MavenCommandLineBuilder(); |
1161 | 862 | File mavenExecutable = new File( "mvnDebug" ); |
1162 | 863 | commandLineBuilder.setMavenExecutable( mavenExecutable ); |
1190 | 891 | assertEnvironmentVariablePresent( commandline, envVar2Name, envVar2Value ); |
1191 | 892 | } |
1192 | 893 | |
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 | ||
1234 | 894 | private void assertEnvironmentVariablePresent( Commandline cli, String varName, String varValue ) |
1235 | throws CommandLineException | |
1236 | 895 | { |
1237 | 896 | List<String> environmentVariables = Arrays.asList( cli.getEnvironmentVariables() ); |
1238 | 897 | |
1239 | 898 | String expectedDeclaration = varName + "=" + varValue; |
1240 | 899 | |
1241 | assertTrue( "Environment variable setting: \'" + expectedDeclaration + "\' is mssing in " | |
900 | assertTrue( "Environment variable setting: '" + expectedDeclaration + "' is mssing in " | |
1242 | 901 | + environmentVariables, environmentVariables.contains( expectedDeclaration ) ); |
1243 | 902 | } |
1244 | 903 | |
1253 | 912 | |
1254 | 913 | int expectedCounter = 0; |
1255 | 914 | |
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 ) ) ) | |
1259 | 918 | { |
1260 | 919 | expectedCounter++; |
1261 | 920 | } |
1272 | 931 | |
1273 | 932 | for ( String arg : requiredArgs ) |
1274 | 933 | { |
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 ) ); | |
1276 | 935 | } |
1277 | 936 | } |
1278 | 937 | |
1283 | 942 | |
1284 | 943 | for ( String arg : bannedArgs ) |
1285 | 944 | { |
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 ) ); | |
1287 | 946 | } |
1288 | 947 | } |
1289 | 948 | |
1291 | 950 | throws IOException |
1292 | 951 | { |
1293 | 952 | 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 | { | |
1299 | 956 | writer.write( "This is a dummy file." ); |
1300 | 957 | } |
1301 | finally | |
1302 | { | |
1303 | IOUtil.close( writer ); | |
1304 | } | |
1305 | ||
1306 | toDelete.add( dummyFile ); | |
1307 | 958 | |
1308 | 959 | return dummyFile; |
1309 | 960 | } |
1333 | 984 | super.setFlags( request, cli ); |
1334 | 985 | } |
1335 | 986 | |
1336 | public void setGoals( InvocationRequest request, Commandline cli ) | |
987 | public void setGoals( InvocationRequest request, Commandline cli ) throws CommandLineConfigurationException | |
1337 | 988 | { |
1338 | 989 | super.setGoals( request, cli ); |
1339 | 990 | } |
1366 | 1017 | |
1367 | 1018 | } |
1368 | 1019 | |
1369 | private File getTempDir() | |
1370 | throws Exception | |
1371 | { | |
1372 | return new File( System.getProperty( "java.io.tmpdir" ) ).getCanonicalFile(); | |
1373 | } | |
1374 | ||
1375 | 1020 | private InvocationRequest newRequest() |
1376 | 1021 | { |
1377 | 1022 | return new DefaultInvocationRequest(); |
26 | 26 | <dependency> |
27 | 27 | <groupId>junit</groupId> |
28 | 28 | <artifactId>junit</artifactId> |
29 | <version>3.8.2</version> | |
29 | <version>4.13.1</version> | |
30 | 30 | <scope>test</scope> |
31 | 31 | </dependency> |
32 | 32 | </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> |
+32
-0
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 | } |
+44
-0
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 | } |
27 | 27 | <plugin> |
28 | 28 | <groupId>org.apache.maven.plugins</groupId> |
29 | 29 | <artifactId>maven-antrun-plugin</artifactId> |
30 | <version>1.1</version> | |
30 | <version>3.0.0</version> | |
31 | 31 | <configuration> |
32 | <tasks> | |
32 | <target> | |
33 | 33 | <property name="prop0" value="${key}"/> |
34 | 34 | <echo>${prop0}</echo> |
35 | 35 | <property name="prop1" value="${key with spaces}"/> |
48 | 48 | </not> |
49 | 49 | </condition> |
50 | 50 | </fail> |
51 | </tasks> | |
51 | </target> | |
52 | 52 | </configuration> |
53 | 53 | <executions> |
54 | 54 | <execution> |