From 98db3ffd8796cbda8141e3e36926adcbb852a2e2 Mon Sep 17 00:00:00 2001 From: Manfred Moser Date: Mon, 18 Feb 2019 22:51:47 -0800 Subject: [PATCH] MVN_REPOURL env var usage for Maven binary download --- maven-wrapper/CHANGELOG.md | 11 +++++++++++ .../main/java/org/apache/maven/wrapper/Installer.java | 11 ++++++++++- .../org/apache/maven/wrapper/MavenWrapperMain.java | 7 ++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/maven-wrapper/CHANGELOG.md b/maven-wrapper/CHANGELOG.md index 1161177626..96a0f549c8 100644 --- a/maven-wrapper/CHANGELOG.md +++ b/maven-wrapper/CHANGELOG.md @@ -25,6 +25,13 @@ The following provides most information at an easier glance. - see https://github.com/takari/maven-wrapper/pull/105 - fixes https://github.com/takari/maven-wrapper/issues/104 - contributed by Manfred Moser http://www.simpligility.com +- Support MVNW_REPOURL environment variable usage + - during wrapper install and wrapper usage + - for wrapper and maven distro download + - in scripts and wrapper binary + - contributed by Manfred Moser http://www.simpligility.com + +Release performed by Manfred Moser - http://www.simpligility.com ## Version 0.4.2 - 2018-07-02 @@ -33,6 +40,8 @@ The following provides most information at an easier glance. - end of line in properties file - parent pom upgrade +Release performed by Manfred Moser - http://www.simpligility.com + ## Version 0.4.0 - 2018-02-19 - Allow for wrapper to work without the jar file @@ -44,6 +53,8 @@ The following provides most information at an easier glance. - Change URLs used to official Maven repo URL - done as part of above changes +Release performed by Manfred Moser - http://www.simpligility.com + ## Version 0.3.0 - 2017-10-25 - Set title on shell window in Windows diff --git a/maven-wrapper/src/main/java/org/apache/maven/wrapper/Installer.java b/maven-wrapper/src/main/java/org/apache/maven/wrapper/Installer.java index e24bb42ba5..7c1acc38fb 100644 --- a/maven-wrapper/src/main/java/org/apache/maven/wrapper/Installer.java +++ b/maven-wrapper/src/main/java/org/apache/maven/wrapper/Installer.java @@ -32,6 +32,7 @@ import java.util.Locale; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; + /** * @author Hans Dockter */ @@ -48,7 +49,15 @@ public class Installer { } public File createDist(WrapperConfiguration configuration) throws Exception { - URI distributionUrl = configuration.getDistribution(); + URI distributionUrl; + String mvnwRepoUrl = System.getenv(MavenWrapperMain.MVNW_REPOURL); + if (mvnwRepoUrl != null && !mvnwRepoUrl.isEmpty()) { + distributionUrl = new URI(mvnwRepoUrl + "/" + MavenWrapperMain.MVN_PATH); + Logger.info("Detected MVNW_REPOURL environment variable " + mvnwRepoUrl); + } else { + distributionUrl = configuration.getDistribution(); + } + Logger.info("Downloading Maven binary from " + distributionUrl); boolean alwaysDownload = configuration.isAlwaysDownload(); boolean alwaysUnpack = configuration.isAlwaysUnpack(); diff --git a/maven-wrapper/src/main/java/org/apache/maven/wrapper/MavenWrapperMain.java b/maven-wrapper/src/main/java/org/apache/maven/wrapper/MavenWrapperMain.java index d85b9498b6..47933a3731 100644 --- a/maven-wrapper/src/main/java/org/apache/maven/wrapper/MavenWrapperMain.java +++ b/maven-wrapper/src/main/java/org/apache/maven/wrapper/MavenWrapperMain.java @@ -38,7 +38,12 @@ public class MavenWrapperMain { public static final String MVNW_VERBOSE = "MVNW_VERBOSE"; public static final String MVNW_USERNAME = "MVNW_USERNAME"; public static final String MVNW_PASSWORD = "MVNW_PASSWORD"; - + public static final String MVNW_REPOURL = "MVNW_REPOURL"; + + public static final String MVN_VERSION = "3.6.0"; + public static final String MVN_PATH = + "org/apache/maven/apache-maven/" + MVN_VERSION + "/apache-maven-"+ MVN_VERSION + "-bin.zip"; + public static void main(String[] args) throws Exception { File wrapperJar = wrapperJar(); File propertiesFile = wrapperProperties(wrapperJar);