From 95dcd2fb7984c3279c2a068e94b7a520a1dc43f8 Mon Sep 17 00:00:00 2001 From: Manfred Moser Date: Mon, 18 Feb 2019 11:56:54 -0800 Subject: [PATCH] consistent usage of MVNW_USERNAME and MVWN_PASSWORD --- .../.mvn/wrapper/MavenWrapperDownloader.java | 6 +++--- maven-wrapper/README.md | 13 +++++++------ maven-wrapper/mvnw | 8 ++++---- maven-wrapper/mvnw.cmd | 4 ++-- .../org/apache/maven/wrapper/DefaultDownloader.java | 8 ++++---- .../org/apache/maven/wrapper/MavenWrapperMain.java | 2 +- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/maven-wrapper/.mvn/wrapper/MavenWrapperDownloader.java b/maven-wrapper/.mvn/wrapper/MavenWrapperDownloader.java index eabf010ffd..bbdc7d8b8d 100644 --- a/maven-wrapper/.mvn/wrapper/MavenWrapperDownloader.java +++ b/maven-wrapper/.mvn/wrapper/MavenWrapperDownloader.java @@ -98,9 +98,9 @@ public class MavenWrapperDownloader { } private static void downloadFileFromURL(String urlString, File destination) throws Exception { - if (System.getenv("MVNW_WRAPPER_AUTH_USERNAME") != null && System.getenv("MVNW_WRAPPER_AUTH_PASSWORD") != null) { - String username = System.getenv("MVNW_WRAPPER_AUTH_USERNAME"); - char[] password = System.getenv("MVNW_WRAPPER_AUTH_PASSWORD").toCharArray(); + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); Authenticator.setDefault(new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { diff --git a/maven-wrapper/README.md b/maven-wrapper/README.md index eed05350ae..2ad44836e0 100644 --- a/maven-wrapper/README.md +++ b/maven-wrapper/README.md @@ -83,9 +83,9 @@ download the file from the URL specified in download is attempted via curl, wget and, as last resort, by compiling the `./mvn/wrapper/MavenWrapperDownloader.java` file and executing the resulting class. -If your maven repository is password protected you can specify your username via the -environment variable `MVNW_WRAPPER_AUTH_USERNAME` and the password via the environment -variable `MVNW_WRAPPER_AUTH_PASSWORD`. +If your Maven repository is password protected you can specify your username via the +environment variable `MVNW_USERNAME` and the password via the environment +variable `MVNW_PASSWORD`. ## Using a Different Version of Maven @@ -106,7 +106,7 @@ distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-mav To download Maven from a location that requires Basic Authentication you have 2 options: -1. Set the environment variables MVNW_USER and MVNW_PASSWORD +1. Set the environment variables MVNW_USERNAME and MVNW_PASSWORD or @@ -137,10 +137,11 @@ To test Maven wrapper usage: - use on test project with maven plugin version + For release -- make sure version in mvnw files and config files and pom files is new upcoming - release +- make sure version in mvnw files, MavenWrapperDownloader.java and config files + and pom files is new upcoming release - cut maven release with usual release plugin usage - update maven plugin to release version - release it as well diff --git a/maven-wrapper/mvnw b/maven-wrapper/mvnw index fbaf85ffc5..24e1b87ad2 100755 --- a/maven-wrapper/mvnw +++ b/maven-wrapper/mvnw @@ -228,19 +228,19 @@ else if [ "$MVNW_VERBOSE" = true ]; then echo "Found wget ... using wget" fi - if [ -z "$MVNW_WRAPPER_AUTH_USERNAME" ] || [ -z "$MVNW_WRAPPER_AUTH_PASSWORD" ]; then + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then wget "$jarUrl" -O "$wrapperJarPath" else - wget --http-user=$MVNW_WRAPPER_AUTH_USERNAME --http-password=$MVNW_WRAPPER_AUTH_PASSWORD "$jarUrl" -O "$wrapperJarPath" + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" fi elif command -v curl > /dev/null; then if [ "$MVNW_VERBOSE" = true ]; then echo "Found curl ... using curl" fi - if [ -z "$MVNW_WRAPPER_AUTH_USERNAME" ] || [ -z "$MVNW_WRAPPER_AUTH_PASSWORD" ]; then + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then curl -o "$wrapperJarPath" "$jarUrl" -f else - curl --user $MVNW_WRAPPER_AUTH_USERNAME:$MVNW_WRAPPER_AUTH_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f fi else diff --git a/maven-wrapper/mvnw.cmd b/maven-wrapper/mvnw.cmd index 38d8ee74c4..64c4ecda9b 100644 --- a/maven-wrapper/mvnw.cmd +++ b/maven-wrapper/mvnw.cmd @@ -135,8 +135,8 @@ if exist %WRAPPER_JAR% ( powershell -Command "&{"^ "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_WRAPPER_AUTH_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_WRAPPER_AUTH_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_WRAPPER_AUTH_USERNAME%', '%MVNW_WRAPPER_AUTH_PASSWORD%');"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ "}"^ "$webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ "}" diff --git a/maven-wrapper/src/main/java/org/apache/maven/wrapper/DefaultDownloader.java b/maven-wrapper/src/main/java/org/apache/maven/wrapper/DefaultDownloader.java index 7332cedb43..396541672c 100644 --- a/maven-wrapper/src/main/java/org/apache/maven/wrapper/DefaultDownloader.java +++ b/maven-wrapper/src/main/java/org/apache/maven/wrapper/DefaultDownloader.java @@ -17,7 +17,7 @@ package org.apache.maven.wrapper; import static org.apache.maven.wrapper.MavenWrapperMain.MVNW_PASSWORD; -import static org.apache.maven.wrapper.MavenWrapperMain.MVNW_USER; +import static org.apache.maven.wrapper.MavenWrapperMain.MVNW_USERNAME; import java.io.BufferedOutputStream; import java.io.File; @@ -58,10 +58,10 @@ public class DefaultDownloader implements Downloader { } private void configureAuthentication() { - if (System.getProperty("MVNW_WRAPPER_AUTH_USERNAME") != null && System.getProperty("MVNW_WRAPPER_AUTH_PASSWORD") != null && System.getProperty("http.proxyUser") == null) { + if (System.getProperty("MVNW_USERNAME") != null && System.getProperty("MVNW_PASSWORD") != null && System.getProperty("http.proxyUser") == null) { Authenticator.setDefault(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(System.getProperty("MVNW_WRAPPER_AUTH_USERNAME"), System.getProperty("MVNW_WRAPPER_AUTH_PASSWORD").toCharArray()); + return new PasswordAuthentication(System.getProperty("MVNW_USERNAME"), System.getProperty("MVNW_PASSWORD").toCharArray()); } }); } @@ -150,7 +150,7 @@ public class DefaultDownloader implements Downloader { } private String calculateUserInfo(URI uri) { - String username = System.getenv(MVNW_USER); + String username = System.getenv(MVNW_USERNAME); String password = System.getenv(MVNW_PASSWORD); if (username != null && password != null) { return username + ':' + password; 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 21e5f2ccf7..0f96f6abcc 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 @@ -37,7 +37,7 @@ public class MavenWrapperMain { public static final String MAVEN_USER_HOME_ENV_KEY = "MAVEN_USER_HOME"; public static final String MVNW_VERBOSE = "MVNW_VERBOSE"; - public static final String MVNW_USER = "MVNW_USER"; + public static final String MVNW_USERNAME = "MVNW_USERNAME"; public static final String MVNW_PASSWORD = "MVNW_PASSWORD"; public static void main(String[] args) throws Exception {