Skip to content

Commit 634a490

Browse files
authored
Merge pull request #89 from zalando-stups/fix-maven-wrapper
Fix maven wrapper
2 parents 7e68a03 + ff1b1de commit 634a490

File tree

4 files changed

+36
-89
lines changed

4 files changed

+36
-89
lines changed

.mvn/wrapper/MavenWrapperDownloader.java

100644100755
Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
11
/*
2-
* Copyright 2007-present the original author or authors.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
*/
19+
1620
import java.net.*;
1721
import java.io.*;
1822
import java.nio.channels.*;
1923
import java.util.Properties;
2024

2125
public class MavenWrapperDownloader {
2226

23-
private static final String WRAPPER_VERSION = "0.5.5";
2427
/**
2528
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
2629
*/
27-
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
28-
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
30+
private static final String DEFAULT_DOWNLOAD_URL =
31+
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
2932

3033
/**
3134
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
@@ -73,13 +76,13 @@ public static void main(String args[]) {
7376
}
7477
}
7578
}
76-
System.out.println("- Downloading from: " + url);
79+
System.out.println("- Downloading from: : " + url);
7780

7881
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
7982
if(!outputFile.getParentFile().exists()) {
8083
if(!outputFile.getParentFile().mkdirs()) {
8184
System.out.println(
82-
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
85+
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
8386
}
8487
}
8588
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
@@ -95,16 +98,6 @@ public static void main(String args[]) {
9598
}
9699

97100
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
98-
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
99-
String username = System.getenv("MVNW_USERNAME");
100-
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
101-
Authenticator.setDefault(new Authenticator() {
102-
@Override
103-
protected PasswordAuthentication getPasswordAuthentication() {
104-
return new PasswordAuthentication(username, password);
105-
}
106-
});
107-
}
108101
URL website = new URL(urlString);
109102
ReadableByteChannel rbc;
110103
rbc = Channels.newChannel(website.openStream());

.mvn/wrapper/maven-wrapper.properties

100644100755
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip
2-
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip

mvnw

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ if $mingw ; then
114114
M2_HOME="`(cd "$M2_HOME"; pwd)`"
115115
[ -n "$JAVA_HOME" ] &&
116116
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
117+
# TODO classpath?
117118
fi
118119

119120
if [ -z "$JAVA_HOME" ]; then
@@ -211,11 +212,7 @@ else
211212
if [ "$MVNW_VERBOSE" = true ]; then
212213
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
213214
fi
214-
if [ -n "$MVNW_REPOURL" ]; then
215-
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
216-
else
217-
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
218-
fi
215+
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
219216
while IFS="=" read key value; do
220217
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
221218
esac
@@ -224,38 +221,22 @@ else
224221
echo "Downloading from: $jarUrl"
225222
fi
226223
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
227-
if $cygwin; then
228-
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
229-
fi
230224

231225
if command -v wget > /dev/null; then
232226
if [ "$MVNW_VERBOSE" = true ]; then
233227
echo "Found wget ... using wget"
234228
fi
235-
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
236-
wget "$jarUrl" -O "$wrapperJarPath"
237-
else
238-
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
239-
fi
229+
wget "$jarUrl" -O "$wrapperJarPath"
240230
elif command -v curl > /dev/null; then
241231
if [ "$MVNW_VERBOSE" = true ]; then
242232
echo "Found curl ... using curl"
243233
fi
244-
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
245-
curl -o "$wrapperJarPath" "$jarUrl" -f
246-
else
247-
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
248-
fi
249-
234+
curl -o "$wrapperJarPath" "$jarUrl"
250235
else
251236
if [ "$MVNW_VERBOSE" = true ]; then
252237
echo "Falling back to using Java to download"
253238
fi
254239
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
255-
# For Cygwin, switch paths to Windows format before running javac
256-
if $cygwin; then
257-
javaClass=`cygpath --path --windows "$javaClass"`
258-
fi
259240
if [ -e "$javaClass" ]; then
260241
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
261242
if [ "$MVNW_VERBOSE" = true ]; then
@@ -296,11 +277,6 @@ if $cygwin; then
296277
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
297278
fi
298279

299-
# Provide a "standardized" way to retrieve the CLI args that will
300-
# work with both Windows and non-Windows executions.
301-
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
302-
export MAVEN_CMD_LINE_ARGS
303-
304280
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
305281

306282
exec "$JAVACMD" \

mvnw.cmd

100644100755
Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
@echo off
3838
@REM set title of command window
3939
title %0
40-
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
40+
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
4141
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
4242

4343
@REM set %HOME% to equivalent of $HOME
@@ -120,44 +120,23 @@ SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120120
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
121121
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
122122

123-
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
124-
125-
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126-
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
123+
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
124+
FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
125+
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
127126
)
128127

129128
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
130129
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
131130
if exist %WRAPPER_JAR% (
132-
if "%MVNW_VERBOSE%" == "true" (
133-
echo Found %WRAPPER_JAR%
134-
)
131+
echo Found %WRAPPER_JAR%
135132
) else (
136-
if not "%MVNW_REPOURL%" == "" (
137-
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
138-
)
139-
if "%MVNW_VERBOSE%" == "true" (
140-
echo Couldn't find %WRAPPER_JAR%, downloading it ...
141-
echo Downloading from: %DOWNLOAD_URL%
142-
)
143-
144-
powershell -Command "&{"^
145-
"$webclient = new-object System.Net.WebClient;"^
146-
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
147-
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
148-
"}"^
149-
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
150-
"}"
151-
if "%MVNW_VERBOSE%" == "true" (
152-
echo Finished downloading %WRAPPER_JAR%
153-
)
133+
echo Couldn't find %WRAPPER_JAR%, downloading it ...
134+
echo Downloading from: %DOWNLOAD_URL%
135+
powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
136+
echo Finished downloading %WRAPPER_JAR%
154137
)
155138
@REM End of extension
156139

157-
@REM Provide a "standardized" way to retrieve the CLI args that will
158-
@REM work with both Windows and non-Windows executions.
159-
set MAVEN_CMD_LINE_ARGS=%*
160-
161140
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
162141
if ERRORLEVEL 1 goto error
163142
goto end

0 commit comments

Comments
 (0)