Skip to content

Commit

Permalink
Support maven wrapper for internal commands
Browse files Browse the repository at this point in the history
If plugin is started with maven wrapper then run internal maven command with it
  • Loading branch information
aleksandr-m committed Sep 13, 2021
1 parent 1369698 commit 72da507
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 72da507

Please sign in to comment.