[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 <sean.owen@databricks.com>
Signed-off-by: HyukjinKwon <gurwls223@apache.org>
This commit is contained in:
Sean Owen 2019-09-04 13:11:09 +09:00 committed by HyukjinKwon
parent a838699ee0
commit df39855db8

View file

@ -81,6 +81,15 @@ install_mvn() {
if [ $(version $MVN_DETECTED_VERSION) -lt $(version $MVN_VERSION) ]; then 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='} 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 \ install_app \
"${APACHE_MIRROR}/maven/maven-3/${MVN_VERSION}/binaries" \ "${APACHE_MIRROR}/maven/maven-3/${MVN_VERSION}/binaries" \
"apache-maven-${MVN_VERSION}-bin.tar.gz" \ "apache-maven-${MVN_VERSION}-bin.tar.gz" \