You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ch...@apache.org on 2023/04/13 15:26:25 UTC

[kyuubi] branch master updated: [KYUUBI #4278] Use new Apache 'closer.lua' syntax to obtain Maven

This is an automated email from the ASF dual-hosted git repository.

chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new 1603342de [KYUUBI #4278] Use new Apache 'closer.lua' syntax to obtain Maven
1603342de is described below

commit 1603342de3fa253145a7d41cc67ca4f30e5de72d
Author: Kent Yao <ya...@apache.org>
AuthorDate: Thu Apr 13 23:26:15 2023 +0800

    [KYUUBI #4278] Use new Apache 'closer.lua' syntax to obtain Maven
    
    ### _Why are the changes needed?_
    
    Use official download link and provide a way to fallback.
    
    - Doc reference: https://infra.apache.org/release-download-pages.html#download-scripts
    
    ### _How was this patch tested?_
    - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [x] [Run test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request
    
    ```shell
    build/mvn compile
    exec: curl --progress-bar -L https://www.apache.org/dyn/closer.lua/maven/maven-3/3.8.7/binaries/apache-maven-3.8.7-bin.tar.gz?action=download
    ```
    
    Closes #4704 from yaooqinn/4278.
    
    Closes #4278
    
    27a1fc284 [Kent Yao] [KYUUBI #4278] Use new Apache 'closer.lua' syntax to obtain Maven
    
    Authored-by: Kent Yao <ya...@apache.org>
    Signed-off-by: Cheng Pan <ch...@apache.org>
---
 build/mvn | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/build/mvn b/build/mvn
index 67aa02b4f..cd6c0c796 100755
--- a/build/mvn
+++ b/build/mvn
@@ -35,7 +35,7 @@ fi
 ## Arg2 - Tarball Name
 ## Arg3 - Checkable Binary
 install_app() {
-  local remote_tarball="$1/$2"
+  local remote_tarball="$1/$2$4"
   local local_tarball="${_DIR}/$2"
   local binary="${_DIR}/$3"
 
@@ -77,12 +77,25 @@ install_mvn() {
   # See simple version normalization: http://stackoverflow.com/questions/16989598/bash-comparing-version-numbers
   function version { echo "$@" | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }'; }
   if [ $(version $MVN_DETECTED_VERSION) -ne $(version $MVN_VERSION) ]; then
-    local APACHE_MIRROR=${APACHE_MIRROR:-'https://archive.apache.org/dist/'}
+    local APACHE_MIRROR=${APACHE_MIRROR:-'https://www.apache.org/dyn/closer.lua'}
+    local MIRROR_URL_QUERY="?action=download"
+    local MVN_TARBALL="apache-maven-${MVN_VERSION}-bin.tar.gz"
+    local FILE_PATH="maven/maven-3/${MVN_VERSION}/binaries"
+
+    if [ $(command -v curl) ]; then
+      if ! curl -L --output /dev/null --silent --head --fail "${APACHE_MIRROR}/${FILE_PATH}/${MVN_TARBALL}${MIRROR_URL_QUERY}" ; 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_QUERY=""
+      fi
+    fi
 
     install_app \
-      "${APACHE_MIRROR}/maven/maven-3/${MVN_VERSION}/binaries" \
-      "apache-maven-${MVN_VERSION}-bin.tar.gz" \
-      "apache-maven-${MVN_VERSION}/bin/mvn"
+      "${APACHE_MIRROR}/${FILE_PATH}" \
+      "${MVN_TARBALL}" \
+      "apache-maven-${MVN_VERSION}/bin/mvn" \
+      "${MIRROR_URL_QUERY}"
 
     MVN_BIN="${_DIR}/apache-maven-${MVN_VERSION}/bin/mvn"
   fi