Skip to content

Commit 460582c

Browse files
[MINVOKER-330] Allow relative path for mavenExecutable
1 parent 82c5d7d commit 460582c

File tree

5 files changed

+94
-4
lines changed

5 files changed

+94
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<groupId>org.apache.maven.plugins.invoker.its</groupId>
26+
<artifactId>minvoker-330</artifactId>
27+
<version>1.0-SNAPSHOT</version>
28+
<packaging>pom</packaging>
29+
30+
<description>
31+
Test to check for usage of relative path in mavenExecutable.
32+
</description>
33+
34+
<properties>
35+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36+
</properties>
37+
38+
<build>
39+
<plugins>
40+
<plugin>
41+
<groupId>org.apache.maven.plugins</groupId>
42+
<artifactId>maven-invoker-plugin</artifactId>
43+
<version>@project.version@</version>
44+
<executions>
45+
<execution>
46+
<id>integration-test</id>
47+
<phase>initialize</phase>
48+
<goals>
49+
<goal>run</goal>
50+
</goals>
51+
</execution>
52+
</executions>
53+
<configuration>
54+
<mavenExecutable>mvn</mavenExecutable>
55+
</configuration>
56+
</plugin>
57+
</plugins>
58+
</build>
59+
60+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
23+
<modelVersion>4.0.0</modelVersion>
24+
<groupId>org.apache.maven.plugins.invoker.its</groupId>
25+
<artifactId>minvoker-330</artifactId>
26+
<version>0.1-SNAPSHOT</version>
27+
<packaging>pom</packaging>
28+
</project>

src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ public abstract class AbstractInvokerMojo extends AbstractMojo {
429429
* @since 1.8
430430
*/
431431
@Parameter(property = "invoker.mavenExecutable")
432-
private File mavenExecutable;
432+
private String mavenExecutable;
433433

434434
/**
435435
* The <code>JAVA_HOME</code> environment variable to use for forked Maven invocations. Defaults to the current Java

src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,10 @@ public void setDefaultProfiles(List<String> defaultProfiles) {
153153
* Default value for mavenExecutable
154154
* @param defaultMavenExecutable a default value
155155
*/
156-
public void setDefaultMavenExecutable(File defaultMavenExecutable) {
157-
this.defaultMavenExecutable = defaultMavenExecutable;
156+
public void setDefaultMavenExecutable(String defaultMavenExecutable) {
157+
if (StringUtils.isNotBlank(defaultMavenExecutable)) {
158+
this.defaultMavenExecutable = new File(defaultMavenExecutable);
159+
}
158160
}
159161

160162
/**

src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public void testConfigureRequestMavenExecutable() {
216216

217217
InvokerProperties facade = new InvokerProperties(props);
218218
File aDefExecutable = new File("defExecutable");
219-
facade.setDefaultMavenExecutable(aDefExecutable);
219+
facade.setDefaultMavenExecutable(aDefExecutable.toString());
220220

221221
props.setProperty("invoker.mavenExecutable", "aPropExecutable");
222222
facade.configureInvocation(request, 0);

0 commit comments

Comments
 (0)