You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2023/03/25 10:10:54 UTC

[maven-invoker-plugin] branch MINVOKER-330 created (now 14e5c87)

This is an automated email from the ASF dual-hosted git repository.

sjaranowski pushed a change to branch MINVOKER-330
in repository https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git


      at 14e5c87  [MINVOKER-330] Allow relative path for mavenExecutable

This branch includes the following new commits:

     new 14e5c87  [MINVOKER-330] Allow relative path for mavenExecutable

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-invoker-plugin] 01/01: [MINVOKER-330] Allow relative path for mavenExecutable

Posted by sj...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sjaranowski pushed a commit to branch MINVOKER-330
in repository https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git

commit 14e5c87c0c64dc38c71a3c4fd55410686d81e343
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Sat Mar 25 11:07:59 2023 +0100

    [MINVOKER-330] Allow relative path for mavenExecutable
---
 .../MINVOKER-330-realative-mavenExacutable/pom.xml | 60 ++++++++++++++++++++++
 .../src/it/project/pom.xml                         | 28 ++++++++++
 .../maven/plugins/invoker/AbstractInvokerMojo.java |  2 +-
 .../maven/plugins/invoker/InvokerProperties.java   |  6 ++-
 .../plugins/invoker/InvokerPropertiesTest.java     |  2 +-
 5 files changed, 94 insertions(+), 4 deletions(-)

diff --git a/src/it/MINVOKER-330-realative-mavenExacutable/pom.xml b/src/it/MINVOKER-330-realative-mavenExacutable/pom.xml
new file mode 100644
index 0000000..ae7d2ca
--- /dev/null
+++ b/src/it/MINVOKER-330-realative-mavenExacutable/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<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">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.invoker.its</groupId>
+  <artifactId>minvoker-330</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <description>
+    Test to check for usage of relative path in mavenExecutable.
+  </description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-invoker-plugin</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>integration-test</id>
+            <phase>initialize</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <mavenExecutable>mvn</mavenExecutable>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/src/it/MINVOKER-330-realative-mavenExacutable/src/it/project/pom.xml b/src/it/MINVOKER-330-realative-mavenExacutable/src/it/project/pom.xml
new file mode 100644
index 0000000..e83b429
--- /dev/null
+++ b/src/it/MINVOKER-330-realative-mavenExacutable/src/it/project/pom.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<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">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.plugins.invoker.its</groupId>
+  <artifactId>minvoker-330</artifactId>
+  <version>0.1-SNAPSHOT</version>
+  <packaging>pom</packaging>
+</project>
diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
index 4a3bd35..84bf5b7 100644
--- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
+++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
@@ -429,7 +429,7 @@ public abstract class AbstractInvokerMojo extends AbstractMojo {
      * @since 1.8
      */
     @Parameter(property = "invoker.mavenExecutable")
-    private File mavenExecutable;
+    private String mavenExecutable;
 
     /**
      * The <code>JAVA_HOME</code> environment variable to use for forked Maven invocations. Defaults to the current Java
diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java b/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java
index 08721a0..5901ad5 100644
--- a/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java
+++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java
@@ -153,8 +153,10 @@ class InvokerProperties {
      * Default value for mavenExecutable
      * @param defaultMavenExecutable a default value
      */
-    public void setDefaultMavenExecutable(File defaultMavenExecutable) {
-        this.defaultMavenExecutable = defaultMavenExecutable;
+    public void setDefaultMavenExecutable(String defaultMavenExecutable) {
+        if (StringUtils.isNotBlank(defaultMavenExecutable)) {
+            this.defaultMavenExecutable = new File(defaultMavenExecutable);
+        }
     }
 
     /**
diff --git a/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java b/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java
index 2ba1d78..8db6c39 100644
--- a/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java
+++ b/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java
@@ -216,7 +216,7 @@ public class InvokerPropertiesTest {
 
         InvokerProperties facade = new InvokerProperties(props);
         File aDefExecutable = new File("defExecutable");
-        facade.setDefaultMavenExecutable(aDefExecutable);
+        facade.setDefaultMavenExecutable(aDefExecutable.toString());
 
         props.setProperty("invoker.mavenExecutable", "aPropExecutable");
         facade.configureInvocation(request, 0);