Skip to content

Commit 458468a

Browse files
dongjoon-hyunsrowen
authored andcommitted
[SPARK-25335][BUILD] Skip Zinc downloading if it's installed in the system
## What changes were proposed in this pull request? Zinc is 23.5MB (tgz). ``` $ curl -LO https://downloads.lightbend.com/zinc/0.3.15/zinc-0.3.15.tgz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 23.5M 100 23.5M 0 0 35.4M 0 --:--:-- --:--:-- --:--:-- 35.3M ``` Currently, Spark downloads Zinc once. However, it occurs too many times in build systems. This PR aims to skip Zinc downloading when the system already has it. ``` $ build/mvn clean exec: curl --progress-bar -L https://downloads.lightbend.com/zinc/0.3.15/zinc-0.3.15.tgz ######################################################################## 100.0% ``` This will reduce many resources(CPU/Networks/DISK) at least in Mac and Docker-based build system. ## How was this patch tested? Pass the Jenkins. Closes apache#22333 from dongjoon-hyun/SPARK-25335. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Sean Owen <[email protected]>
1 parent 71bd796 commit 458468a

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

build/mvn

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ install_app() {
6767
fi
6868
}
6969

70+
# See simple version normalization: http://stackoverflow.com/questions/16989598/bash-comparing-version-numbers
71+
function version { echo "$@" | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }'; }
72+
7073
# Determine the Maven version from the root pom.xml file and
7174
# install maven under the build/ folder if needed.
7275
install_mvn() {
@@ -75,8 +78,6 @@ install_mvn() {
7578
if [ "$MVN_BIN" ]; then
7679
local MVN_DETECTED_VERSION="$(mvn --version | head -n1 | awk '{print $3}')"
7780
fi
78-
# See simple version normalization: http://stackoverflow.com/questions/16989598/bash-comparing-version-numbers
79-
function version { echo "$@" | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }'; }
8081
if [ $(version $MVN_DETECTED_VERSION) -lt $(version $MVN_VERSION) ]; then
8182
local APACHE_MIRROR=${APACHE_MIRROR:-'https://www.apache.org/dyn/closer.lua?action=download&filename='}
8283

@@ -91,15 +92,23 @@ install_mvn() {
9192

9293
# Install zinc under the build/ folder
9394
install_zinc() {
94-
local zinc_path="zinc-0.3.15/bin/zinc"
95-
[ ! -f "${_DIR}/${zinc_path}" ] && ZINC_INSTALL_FLAG=1
96-
local TYPESAFE_MIRROR=${TYPESAFE_MIRROR:-https://downloads.lightbend.com}
95+
local ZINC_VERSION=0.3.15
96+
ZINC_BIN="$(command -v zinc)"
97+
if [ "$ZINC_BIN" ]; then
98+
local ZINC_DETECTED_VERSION="$(zinc -version | head -n1 | awk '{print $5}')"
99+
fi
97100

98-
install_app \
99-
"${TYPESAFE_MIRROR}/zinc/0.3.15" \
100-
"zinc-0.3.15.tgz" \
101-
"${zinc_path}"
102-
ZINC_BIN="${_DIR}/${zinc_path}"
101+
if [ $(version $ZINC_DETECTED_VERSION) -lt $(version $ZINC_VERSION) ]; then
102+
local zinc_path="zinc-${ZINC_VERSION}/bin/zinc"
103+
[ ! -f "${_DIR}/${zinc_path}" ] && ZINC_INSTALL_FLAG=1
104+
local TYPESAFE_MIRROR=${TYPESAFE_MIRROR:-https://downloads.lightbend.com}
105+
106+
install_app \
107+
"${TYPESAFE_MIRROR}/zinc/${ZINC_VERSION}" \
108+
"zinc-${ZINC_VERSION}.tgz" \
109+
"${zinc_path}"
110+
ZINC_BIN="${_DIR}/${zinc_path}"
111+
fi
103112
}
104113

105114
# Determine the Scala version from the root pom.xml file, set the Scala URL,

0 commit comments

Comments
 (0)