From df39855db826fd4bead85a2ca01eda15c101bbbe Mon Sep 17 00:00:00 2001 From: Sean Owen Date: Wed, 4 Sep 2019 13:11:09 +0900 Subject: [PATCH] [SPARK-28963][BUILD] Fall back to archive.apache.org in build/mvn for older releases ### What changes were proposed in this pull request? Fall back to archive.apache.org in `build/mvn` to download Maven, in case the ASF mirrors no longer have an older release. ### Why are the changes needed? If an older release's specified Maven doesn't exist in the mirrors, {{build/mvn}} will fail. ### Does this PR introduce any user-facing change? No ### How was this patch tested? Manually tested different paths and failures by commenting in/out parts of the script and modifying it directly. Closes #25667 from srowen/SPARK-28963. Authored-by: Sean Owen Signed-off-by: HyukjinKwon --- build/mvn | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build/mvn b/build/mvn index 75feb2f718..f68377b3dd 100755 --- a/build/mvn +++ b/build/mvn @@ -80,6 +80,15 @@ install_mvn() { fi if [ $(version $MVN_DETECTED_VERSION) -lt $(version $MVN_VERSION) ]; then local APACHE_MIRROR=${APACHE_MIRROR:-'https://www.apache.org/dyn/closer.lua?action=download&filename='} + + if [ $(command -v curl) ]; then + local TEST_MIRROR_URL="${APACHE_MIRROR}/maven/maven-3/${MVN_VERSION}/binaries/apache-maven-${MVN_VERSION}-bin.tar.gz" + if ! curl -L --output /dev/null --silent --head --fail "$TEST_MIRROR_URL" ; then + # Fall back to archive.apache.org for older Maven + echo "Falling back to archive.apache.org to download Maven" + APACHE_MIRROR="https://archive.apache.org/dist" + fi + fi install_app \ "${APACHE_MIRROR}/maven/maven-3/${MVN_VERSION}/binaries" \