Skip to content

Commit

Permalink
[SPARK-35178][BUILD] Use new Apache 'closer.lua' syntax to obtain Maven
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?

Use new Apache 'closer.lua' syntax to obtain Maven

### Why are the changes needed?

The current closer.lua redirector, which redirects to download Maven from a local mirror, has a new syntax. build/mvn does not work properly otherwise now.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Manual testing.

Closes #32277 from srowen/SPARK-35178.

Authored-by: Sean Owen <srowen@gmail.com>
Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
(cherry picked from commit 6860efe)
Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
  • Loading branch information
srowen authored and dongjoon-hyun committed Apr 22, 2021
1 parent 0208810 commit 3c5b3e2
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions build/mvn
Expand Up @@ -31,7 +31,7 @@ _COMPILE_JVM_OPTS="-Xmx2g -XX:ReservedCodeCacheSize=1g"
## Arg2 - Tarball Name
## Arg3 - Checkable Binary
install_app() {
local remote_tarball="$1/$2"
local remote_tarball="$1"
local local_tarball="${_DIR}/$2"
local binary="${_DIR}/$3"

Expand Down Expand Up @@ -71,19 +71,20 @@ install_mvn() {
local MVN_DETECTED_VERSION="$(mvn --version | head -n1 | awk '{print $3}')"
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='}

local FILE_PATH="maven/maven-3/${MVN_VERSION}/binaries/apache-maven-${MVN_VERSION}-bin.tar.gz"
local APACHE_MIRROR=${APACHE_MIRROR:-'https://www.apache.org/dyn/closer.lua'}
local MIRROR_URL="${APACHE_MIRROR}/${FILE_PATH}?action=download"

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
if ! curl -L --output /dev/null --silent --head --fail "${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"
MIRROR_URL="https://archive.apache.org/dist/${FILE_PATH}"
fi
fi

install_app \
"${APACHE_MIRROR}/maven/maven-3/${MVN_VERSION}/binaries" \
"${MIRROR_URL}" \
"apache-maven-${MVN_VERSION}-bin.tar.gz" \
"apache-maven-${MVN_VERSION}/bin/mvn"

Expand Down Expand Up @@ -123,7 +124,7 @@ install_scala() {
local TYPESAFE_MIRROR=${TYPESAFE_MIRROR:-https://downloads.lightbend.com}

install_app \
"${TYPESAFE_MIRROR}/scala/${scala_version}" \
"${TYPESAFE_MIRROR}/scala/${scala_version}/scala-${scala_version}.tgz" \
"scala-${scala_version}.tgz" \
"scala-${scala_version}/bin/scala"

Expand Down

0 comments on commit 3c5b3e2

Please sign in to comment.