From 6050979ee7294cd82108683aea9fc184facf42ed Mon Sep 17 00:00:00 2001 From: John Patrick <142304+nhojpatrick@users.noreply.github.com> Date: Mon, 27 Jul 2020 23:29:49 +0100 Subject: [PATCH] Maven Wrapper mvnw and mvnw.cmd built-in support --- .../maven/plugin/gitflow/AbstractGitFlowMojo.java | 12 +++++++++++- 1 file changed, 11 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 32803926..d726a681 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java @@ -15,12 +15,14 @@ */ package com.amashchenko.maven.plugin.gitflow; +import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Map.Entry; 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; @@ -191,7 +193,15 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo { private void initExecutables() { if (StringUtils.isBlank(cmdMvn.getExecutable())) { if (StringUtils.isBlank(mvnExecutable)) { - mvnExecutable = "mvn"; + if (SystemUtils.IS_OS_UNIX + && new File(".", "mvnw").isFile()) { + mvnExecutable = "./mvnw"; + } else if (SystemUtils.IS_OS_WINDOWS + && new File(".", "mvnw.cmd").isFile()) { + mvnExecutable = "mvnw.cmd"; + } else { + mvnExecutable = "mvn"; + } } cmdMvn.setExecutable(mvnExecutable); }