You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by sz...@apache.org on 2023/03/22 08:20:31 UTC

[ratis] 15/18: RATIS-1819. Use Maven Wrapper in CI workflows (#859)

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

szetszwo pushed a commit to branch branch-2_readIndex
in repository https://gitbox.apache.org/repos/asf/ratis.git

commit 649e5fef2b39de06afe8caba7eb481ae73560721
Author: tison <wa...@gmail.com>
AuthorDate: Tue Mar 21 11:31:29 2023 +0800

    RATIS-1819. Use Maven Wrapper in CI workflows (#859)
    
    (cherry picked from commit 5a8bdef821c24bda579859e3bd3dacd9b0792b7d)
---
 dev-support/checks/_mvn_unit_report.sh |  2 +-
 dev-support/checks/build.sh            |  4 +++-
 dev-support/checks/checkstyle.sh       |  6 ++++--
 dev-support/checks/findbugs.sh         |  6 ++++--
 dev-support/checks/rat.sh              |  4 +++-
 dev-support/checks/sonar.sh            |  5 ++++-
 dev-support/checks/unit.sh             |  4 +++-
 dev-support/find_maven.sh              | 30 ++++++++++++++++++++++++++++++
 dev-support/make_rc.sh                 | 10 ++++------
 dev-support/run-test-repeatedly.sh     |  6 ++++--
 10 files changed, 60 insertions(+), 17 deletions(-)

diff --git a/dev-support/checks/_mvn_unit_report.sh b/dev-support/checks/_mvn_unit_report.sh
index f7123775f..cc14817a9 100755
--- a/dev-support/checks/_mvn_unit_report.sh
+++ b/dev-support/checks/_mvn_unit_report.sh
@@ -75,7 +75,7 @@ for failed_test in $(< ${REPORT_DIR}/summary.txt); do
 done
 
 ## Check if Maven was killed
-if grep -q 'Killed.* mvn .* test ' "${REPORT_DIR}/output.log"; then
+if grep -q "Killed.* ${MVN} .* test " "${REPORT_DIR}/output.log"; then
   echo 'Maven test run was killed' >> "${REPORT_DIR}/summary.txt"
 fi
 
diff --git a/dev-support/checks/build.sh b/dev-support/checks/build.sh
index ad029d626..4d7090aff 100755
--- a/dev-support/checks/build.sh
+++ b/dev-support/checks/build.sh
@@ -16,6 +16,8 @@
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
 cd "$DIR/../.." || exit 1
 
+source "${DIR}/../find_maven.sh"
+
 export MAVEN_OPTS="-Xmx4096m"
-mvn -V -B -Dmaven.javadoc.skip=true -DskipTests clean install "$@"
+${MVN} -V -B -Dmaven.javadoc.skip=true -DskipTests clean install "$@"
 exit $?
diff --git a/dev-support/checks/checkstyle.sh b/dev-support/checks/checkstyle.sh
index 490f1c470..cb06fdaac 100755
--- a/dev-support/checks/checkstyle.sh
+++ b/dev-support/checks/checkstyle.sh
@@ -16,6 +16,8 @@
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
 cd "$DIR/../.." || exit 1
 
+source "${DIR}/../find_maven.sh"
+
 BASE_DIR="$(pwd -P)"
 REPORT_DIR=${OUTPUT_DIR:-"$DIR/../../target/checkstyle"}
 mkdir -p "$REPORT_DIR"
@@ -24,10 +26,10 @@ REPORT_FILE="$REPORT_DIR/summary.txt"
 MAVEN_OPTIONS='-B -fae -Dcheckstyle.failOnViolation=false'
 
 declare -i rc
-mvn ${MAVEN_OPTIONS} checkstyle:check | tee  "${REPORT_DIR}/output.log"
+${MVN} ${MAVEN_OPTIONS} checkstyle:check | tee  "${REPORT_DIR}/output.log"
 rc=$?
 if [[ ${rc} -ne 0 ]]; then
-  mvn ${MAVEN_OPTIONS} clean test-compile checkstyle:check
+  ${MVN} ${MAVEN_OPTIONS} clean test-compile checkstyle:check
   rc=$?
   mkdir -p "$REPORT_DIR" # removed by mvn clean
 else
diff --git a/dev-support/checks/findbugs.sh b/dev-support/checks/findbugs.sh
index bcb43fd4f..c1723f437 100755
--- a/dev-support/checks/findbugs.sh
+++ b/dev-support/checks/findbugs.sh
@@ -16,16 +16,18 @@
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
 cd "$DIR/../.." || exit 1
 
+source "${DIR}/../find_maven.sh"
+
 MAVEN_OPTIONS='-B -fae'
 
 if ! type unionBugs >/dev/null 2>&1 || ! type convertXmlToText >/dev/null 2>&1; then
   #shellcheck disable=SC2086
-  mvn ${MAVEN_OPTIONS} test-compile spotbugs:check
+  ${MVN} ${MAVEN_OPTIONS} test-compile spotbugs:check
   exit $?
 fi
 
 #shellcheck disable=SC2086
-mvn ${MAVEN_OPTIONS} test-compile spotbugs:spotbugs
+${MVN} ${MAVEN_OPTIONS} test-compile spotbugs:spotbugs
 rc=$?
 
 REPORT_DIR=${OUTPUT_DIR:-"$DIR/../../target/findbugs"}
diff --git a/dev-support/checks/rat.sh b/dev-support/checks/rat.sh
index 86802e9db..9b55878ef 100755
--- a/dev-support/checks/rat.sh
+++ b/dev-support/checks/rat.sh
@@ -16,12 +16,14 @@
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
 cd "$DIR/../.." || exit 1
 
+source "${DIR}/../find_maven.sh"
+
 REPORT_DIR=${OUTPUT_DIR:-"$DIR/../../target/rat"}
 mkdir -p "$REPORT_DIR"
 
 REPORT_FILE="$REPORT_DIR/summary.txt"
 
-mvn -B -fn org.apache.rat:apache-rat-plugin:0.13:check
+${MVN} -B -fn org.apache.rat:apache-rat-plugin:0.13:check
 
 cd "$DIR/../.." || exit 1
 
diff --git a/dev-support/checks/sonar.sh b/dev-support/checks/sonar.sh
index a1f9dbe60..d78c8875f 100755
--- a/dev-support/checks/sonar.sh
+++ b/dev-support/checks/sonar.sh
@@ -16,8 +16,11 @@
 DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
 cd "$DIR/../.." || exit 1
 
+source "${DIR}/../find_maven.sh"
+
 if [ ! "$SONAR_TOKEN" ]; then
   echo "SONAR_TOKEN environment variable should be set"
   exit 1
 fi
-mvn -B verify -DskipShade -DskipTests org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=apache -Dsonar.projectKey=apache-ratis
+
+${MVN} -B verify -DskipShade -DskipTests org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=apache -Dsonar.projectKey=apache-ratis
diff --git a/dev-support/checks/unit.sh b/dev-support/checks/unit.sh
index 50a1c712f..69edde287 100755
--- a/dev-support/checks/unit.sh
+++ b/dev-support/checks/unit.sh
@@ -19,6 +19,8 @@ set -o pipefail
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
 cd "$DIR/../.." || exit 1
 
+source "${DIR}/../find_maven.sh"
+
 : ${ITERATIONS:="1"}
 
 declare -i ITERATIONS
@@ -39,7 +41,7 @@ for i in $(seq 1 ${ITERATIONS}); do
     mkdir -p "${REPORT_DIR}"
   fi
 
-  mvn -B -fae test "$@" \
+  ${MVN} -B -fae test "$@" \
     | tee "${REPORT_DIR}/output.log"
   irc=$?
 
diff --git a/dev-support/find_maven.sh b/dev-support/find_maven.sh
new file mode 100644
index 000000000..20b6462b1
--- /dev/null
+++ b/dev-support/find_maven.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+function find_maven() {
+    if [ "$MAVEN" != "" ]; then
+      echo "${MAVEN}"
+    else
+      local DIR
+      DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+      ( cd "$DIR/.." || exit 1 ; echo "$( pwd -P )/mvnw" )
+    fi
+}
+
+MVN="$( find_maven )"
+export MVN
diff --git a/dev-support/make_rc.sh b/dev-support/make_rc.sh
index e02145555..b5bec51dd 100755
--- a/dev-support/make_rc.sh
+++ b/dev-support/make_rc.sh
@@ -27,17 +27,15 @@
 # Presumes your settings.xml all set up so can sign artifacts published to mvn, etc.
 set -e
 # Set mvn and mvnopts
-mvn=mvn
-if [ "$MAVEN" != "" ]; then
-  mvn="${MAVEN}"
-fi
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+source "${DIR}/find_maven.sh"
 mvnopts="-Xmx1g"
 if [ "$MAVEN_OPTS" != "" ]; then
   mvnopts="${MAVEN_OPTS}"
 fi
 
 mvnGet() {
-  ${mvn} -q -Dexec.executable="echo" -Dexec.args="\${${1}}" --non-recursive \
+  ${MVN} -q -Dexec.executable="echo" -Dexec.args="\${${1}}" --non-recursive \
     org.codehaus.mojo:exec-maven-plugin:1.6.0:exec 2>/dev/null
 }
 
@@ -90,7 +88,7 @@ fi
 
 
 mvnFun() {
-  MAVEN_OPTS="${mvnopts}" ${mvn} -Dmaven.repo.local="${repodir}" "$@"
+  MAVEN_OPTS="${mvnopts}" ${MVN} -Dmaven.repo.local="${repodir}" "$@"
 }
 
 prepare-src() {
diff --git a/dev-support/run-test-repeatedly.sh b/dev-support/run-test-repeatedly.sh
index dd3b87421..6824c1449 100755
--- a/dev-support/run-test-repeatedly.sh
+++ b/dev-support/run-test-repeatedly.sh
@@ -24,10 +24,12 @@ fi
 TEST_PATTERN=$1
 TEST_NAME=`echo ${TEST_PATTERN} | cut -d# -f 1`
 
-MVN="mvn"
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+source "${DIR}/find_maven.sh"
+
 set -ex
 
-mvn clean
+${MVN} clean
 
 for i in `seq 1 99`;
 do