mirror of https://github.com/apache/maven.git
consistent usage of MVNW_USERNAME and MVWN_PASSWORD
This commit is contained in:
parent
0e55dc7366
commit
bca8bfd583
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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%')"^
|
||||
"}"
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue