From 5fa049619d75fb24ecd1f88336394e2902da03b9 Mon Sep 17 00:00:00 2001 From: John Patrick <142304+nhojpatrick@users.noreply.github.com> Date: Sun, 17 Jan 2021 18:56:47 +0000 Subject: [PATCH 1/3] Reduce maven-compiler-plugin config by using user properties --- pom.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index f65fb2f3..59271fc8 100644 --- a/pom.xml +++ b/pom.xml @@ -63,8 +63,13 @@ - 1.7 - UTF-8 + UTF-8 + 1.7 + ${project.custom.java.version} + ${project.custom.java.version} + ${project.custom.encoding} + ${project.custom.encoding} + ${project.custom.encoding} 3.6.0 @@ -100,11 +105,6 @@ org.apache.maven.plugins maven-compiler-plugin 3.8.1 - - ${java.version} - ${java.version} - ${project.build.sourceEncoding} - org.apache.maven.plugins From 8cd93ac6da6f5173d55f985aa5d06a402e4d06a0 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 2/3] 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 c668086a..7bae026a 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java @@ -15,6 +15,7 @@ */ package com.amashchenko.maven.plugin.gitflow; +import java.io.File; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -25,6 +26,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 +207,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); } From 053a15ce2c0bdd62458e7c36c9ee6db84c534613 Mon Sep 17 00:00:00 2001 From: John Patrick <142304+nhojpatrick@users.noreply.github.com> Date: Sun, 17 Jan 2021 19:20:51 +0000 Subject: [PATCH 3/3] Maven Wrapper detection --- .../plugin/gitflow/AbstractGitFlowMojo.java | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) 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 7bae026a..50977dcc 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java @@ -205,13 +205,44 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo { * */ private void initExecutables() { + + boolean mainClassIsMavenWrapper = false; + for (final Map.Entry p : this.mavenSession.getSystemProperties() + .entrySet()) { + mainClassIsMavenWrapper |= (String.valueOf(p.getKey()).startsWith("env.JAVA_MAIN_CLASS") + && "org.apache.maven.wrapper.MavenWrapperMain".equals(p.getValue())); + } + // TechDebt Java 1.8+ version +// final boolean mainClassIsMavenWrapper = this.mavenSession.getSystemProperties().entrySet().stream() +// .filter(p -> String.valueOf(p.getKey()).startsWith("env.JAVA_MAIN_CLASS")) +// .filter(p -> "org.apache.maven.wrapper.MavenWrapperMain".equals(p.getValue())) +// .findAny() +// .isPresent(); + + boolean mavenHomeIsWrapperDists = false; + for (final Map.Entry p : this.mavenSession.getSystemProperties() + .entrySet()) { + mavenHomeIsWrapperDists |= ("maven.home".equals(p.getKey()) + && String.valueOf(p.getValue()).contains("/wrapper/dists/")); + } + // TechDebt Java 1.8+ version +// final boolean mavenHomeIsWrapperDists = this.mavenSession.getSystemProperties().entrySet().stream() +// .filter(p -> "maven.home".equals(p.getKey())) +// .filter(p -> String.valueOf(p.getValue()).contains("/wrapper/dists/")) +// .findAny() +// .isPresent(); + + final boolean runningWithinMavenWrapper = mainClassIsMavenWrapper && mavenHomeIsWrapperDists; + if (StringUtils.isBlank(cmdMvn.getExecutable())) { if (StringUtils.isBlank(mvnExecutable)) { if (SystemUtils.IS_OS_UNIX - && new File(".", "mvnw").isFile()) { + && new File(".", "mvnw").isFile() + && runningWithinMavenWrapper) { mvnExecutable = "./mvnw"; } else if (SystemUtils.IS_OS_WINDOWS - && new File(".", "mvnw.cmd").isFile()) { + && new File(".", "mvnw.cmd").isFile() + && runningWithinMavenWrapper) { mvnExecutable = "mvnw.cmd"; } else { mvnExecutable = "mvn";