From 72da5071405e18d8f969f94d2bc291ef2aeded0f Mon Sep 17 00:00:00 2001 From: Aleksandr Mashchenko Date: Mon, 13 Sep 2021 18:23:46 +0300 Subject: [PATCH] Support maven wrapper for internal commands If plugin is started with maven wrapper then run internal maven command with it --- .../maven/plugin/gitflow/AbstractGitFlowMojo.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java index c668086a..98fb03dc 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java @@ -25,6 +25,7 @@ import java.util.TimeZone; import java.util.regex.Pattern; +import org.apache.commons.lang3.SystemUtils; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; @@ -205,7 +206,14 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo { private void initExecutables() { if (StringUtils.isBlank(cmdMvn.getExecutable())) { if (StringUtils.isBlank(mvnExecutable)) { - mvnExecutable = "mvn"; + final String javaCommand = mavenSession.getSystemProperties().getProperty("sun.java.command", ""); + final boolean wrapper = javaCommand.startsWith("org.apache.maven.wrapper.MavenWrapperMain"); + + if (wrapper) { + mvnExecutable = "." + SystemUtils.FILE_SEPARATOR + "mvnw"; + } else { + mvnExecutable = "mvn"; + } } cmdMvn.setExecutable(mvnExecutable); }