Skip to content

Commit f6d0eb2

Browse files
committed
introduce mvnd
1 parent 3f5121a commit f6d0eb2

File tree

6 files changed

+185
-9
lines changed

6 files changed

+185
-9
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
name: 'setup-mvnd'
19+
description: 'Setup the maven daemon'
20+
runs:
21+
using: "composite"
22+
steps:
23+
- name: Cache Mvnd
24+
uses: actions/cache@v3
25+
with:
26+
path: |
27+
build/maven-mvnd-*
28+
build/apache-maven-*
29+
key: ${{ runner.os }}-mvnd
30+
- name: Check Mvnd
31+
run: build/mvnd -v
32+
shell: bash

.github/workflows/dep.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ on:
2323
- master
2424
- branch-*
2525
paths:
26-
# dependency check happens only pom changes
26+
# dependency check happens when pom changes
2727
- '**/pom.xml'
28+
# dependency check happens when workflow changes
29+
- .github/workflows/dep.yaml
30+
- .github/actions/setup-mvnd/*.yaml
2831

2932
concurrency:
3033
group: dep-${{ github.ref }}
@@ -43,11 +46,13 @@ jobs:
4346
java-version: 8
4447
cache: 'maven'
4548
check-latest: false
49+
- name: Setup Mvnd
50+
uses: ./.github/actions/setup-mvnd
4651
- name: build
4752
env:
4853
MAVEN_OPTS: -Dorg.slf4j.simpleLogger.defaultLogLevel=error
4954
run: >-
50-
build/mvn clean install
55+
build/mvnd clean install
5156
-Pflink-provided,spark-provided,hive-provided
5257
-Dmaven.javadoc.skip=true
5358
-Drat.skip=true

.github/workflows/style.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@ jobs:
4545
java-version: 8
4646
cache: 'maven'
4747
check-latest: false
48+
- name: Setup Mvnd
49+
uses: ./.github/actions/setup-mvnd
4850
- name: Setup Python 3
4951
uses: actions/setup-python@v4
5052
with:
5153
python-version: '3.9'
5254
cache: 'pip'
53-
- name: Check kyuubi modules avaliable
55+
- name: Check kyuubi modules available
5456
id: modules-check
55-
run: build/mvn dependency:resolve -DincludeGroupIds="org.apache.kyuubi" -DincludeScope="compile" -DexcludeTransitive=true ${{ matrix.profiles }}
57+
run: build/mvnd dependency:resolve -DincludeGroupIds="org.apache.kyuubi" -DincludeScope="compile" -DexcludeTransitive=true ${{ matrix.profiles }}
5658
continue-on-error: true
5759

5860
- name: Install
@@ -61,13 +63,13 @@ jobs:
6163
if: steps.modules-check.conclusion == 'success' && steps.modules-check.outcome == 'failure'
6264
run: |
6365
MVN_OPT="-DskipTests -Dorg.slf4j.simpleLogger.defaultLogLevel=warn -Dmaven.javadoc.skip=true -Drat.skip=true -Dscalastyle.skip=true -Dspotless.check.skip"
64-
build/mvn clean install ${MVN_OPT} -Pflink-provided,hive-provided,spark-provided,spark-block-cleaner,spark-3.2,tpcds
65-
build/mvn clean install ${MVN_OPT} -pl extensions/spark/kyuubi-extension-spark-3-1 -Pspark-3.1
66-
build/mvn clean install ${MVN_OPT} -pl extensions/spark/kyuubi-extension-spark-3-3,extensions/spark/kyuubi-spark-connector-kudu,extensions/spark/kyuubi-spark-connector-hive -Pspark-3.3
66+
build/mvnd clean install ${MVN_OPT} -Pflink-provided,hive-provided,spark-provided,spark-block-cleaner,spark-3.2,tpcds
67+
build/mvnd clean install ${MVN_OPT} -pl extensions/spark/kyuubi-extension-spark-3-1 -Pspark-3.1
68+
build/mvnd clean install ${MVN_OPT} -pl extensions/spark/kyuubi-extension-spark-3-3,extensions/spark/kyuubi-spark-connector-kudu,extensions/spark/kyuubi-spark-connector-hive -Pspark-3.3
6769
6870
- name: Scalastyle with maven
6971
id: scalastyle-check
70-
run: build/mvn scalastyle:check ${{ matrix.profiles }}
72+
run: build/mvnd scalastyle:check ${{ matrix.profiles }}
7173
- name: Print scalastyle error report
7274
if: failure() && steps.scalastyle-check.outcome != 'success'
7375
run: >-
@@ -81,7 +83,7 @@ jobs:
8183
run: |
8284
SPOTLESS_BLACK_VERSION=$(build/mvn help:evaluate -Dexpression=spotless.python.black.version -q -DforceStdout)
8385
pip install black==$SPOTLESS_BLACK_VERSION
84-
build/mvn spotless:check ${{ matrix.profiles }} -Pspotless-python
86+
build/mvnd spotless:check ${{ matrix.profiles }} -Pspotless-python
8587
- name: setup npm
8688
uses: actions/setup-node@v3
8789
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
.scala_dependencies
4141
.settings
4242
build/apache-maven*
43+
build/maven-mvnd*
4344
build/release/tmp
4445
build/scala*
4546
build/test

build/mvnd

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership.
7+
# The ASF licenses this file to You under the Apache License, Version 2.0
8+
# (the "License"); you may not use this file except in compliance with
9+
# the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
# Determine the current working directory
21+
_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
22+
# Preserve the calling directory
23+
_CALLING_DIR="$(pwd)"
24+
# Options used during compilation
25+
_COMPILE_JVM_OPTS="-Xms2g -Xmx2g -XX:ReservedCodeCacheSize=1g -Xss128m"
26+
27+
if [ "$CI" ]; then
28+
export MAVEN_CLI_OPTS="--no-transfer-progress --errors --fail-fast"
29+
fi
30+
31+
# Installs any application tarball given a URL, the expected tarball name,
32+
# and, optionally, a checkable binary path to determine if the binary has
33+
# already been installed
34+
## Arg1 - URL
35+
## Arg2 - Tarball Name
36+
## Arg3 - Checkable Binary
37+
install_app() {
38+
local remote_tarball="$1/$2"
39+
local local_tarball="${_DIR}/$2"
40+
local binary="${_DIR}/$3"
41+
42+
# setup `curl` and `wget` silent options if we're running on Jenkins
43+
local curl_opts="-L"
44+
local wget_opts=""
45+
curl_opts="--progress-bar ${curl_opts}"
46+
wget_opts="--progress=bar:force ${wget_opts}"
47+
48+
if [ -z "$3" -o ! -f "$binary" ]; then
49+
# check if we already have the tarball
50+
# check if we have curl installed
51+
# download application
52+
rm -f "$local_tarball"
53+
[ ! -f "${local_tarball}" ] && [ $(command -v curl) ] && \
54+
echo "exec: curl ${curl_opts} ${remote_tarball}" 1>&2 && \
55+
curl ${curl_opts} "${remote_tarball}" > "${local_tarball}"
56+
# if the file still doesn't exist, lets try `wget` and cross our fingers
57+
[ ! -f "${local_tarball}" ] && [ $(command -v wget) ] && \
58+
echo "exec: wget ${wget_opts} ${remote_tarball}" 1>&2 && \
59+
wget ${wget_opts} -O "${local_tarball}" "${remote_tarball}"
60+
# if both were unsuccessful, exit
61+
[ ! -f "${local_tarball}" ] && \
62+
echo -n "ERROR: Cannot download $2 with cURL or wget; " && \
63+
echo "please install manually and try again." && \
64+
exit 2
65+
cd "${_DIR}" && tar -xzf "$2"
66+
rm -rf "$local_tarball"
67+
fi
68+
}
69+
70+
function get_os_type(){
71+
local unameOsOut=$(uname -s)
72+
local osType
73+
case "${unameOsOut}" in
74+
Linux*) osType=linux;;
75+
Darwin*) osType=darwin;;
76+
CYGWIN*) osType=windows;;
77+
MINGW*) osType=windows;;
78+
*) osType="UNKNOWN:${unameOsOut}"
79+
esac
80+
echo "$osType"
81+
}
82+
83+
function get_os_arch(){
84+
local unameArchOut="$(uname -m)"
85+
local arch
86+
case "${unameArchOut}" in
87+
x86_64*) arch=amd64;;
88+
arm64*) arch=aarch64;;
89+
*) arch="UNKNOWN:${unameOsOut}"
90+
esac
91+
echo "$arch"
92+
}
93+
94+
# Determine the Maven version from the root pom.xml file and
95+
# install maven under the build/ folder if needed.
96+
install_mvn() {
97+
local MVND_VERSION=`grep "<mvnd.version>" "${_DIR}/../pom.xml" | head -n1 | awk -F '[<>]' '{print $3}'`
98+
local MVN_VERSION=`grep "<maven.version>" "${_DIR}/../pom.xml" | head -n1 | awk -F '[<>]' '{print $3}'`
99+
MVND_BIN="$(command -v mvnd)"
100+
if [ "$MVND_BIN" ]; then
101+
local MVND_DETECTED_VERSION="$(mvnd -v 2>&1| grep '(mvnd)' | awk '{print $5}')"
102+
local MVN_DETECTED_VERSION="$(mvnd -v 2>&1 | grep 'Apache Maven' | awk 'NR==2 {print $3}')"
103+
fi
104+
# See simple version normalization: http://stackoverflow.com/questions/16989598/bash-comparing-version-numbers
105+
function version { echo "$@" | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }'; }
106+
107+
if [ $(version $MVND_DETECTED_VERSION) -ne $(version $MVND_VERSION) ]
108+
then
109+
local APACHE_MIRROR=${APACHE_MIRROR:-'https://downloads.apache.org'}
110+
local OS_TYPE=$(get_os_type)
111+
local ARCH=$(get_os_arch)
112+
113+
install_app \
114+
"${APACHE_MIRROR}/maven/mvnd/${MVND_VERSION}" \
115+
"maven-mvnd-${MVND_VERSION}-${OS_TYPE}-${ARCH}.tar.gz" \
116+
"maven-mvnd-${MVND_VERSION}-${OS_TYPE}-${ARCH}/bin/mvnd"
117+
118+
MVND_BIN="${_DIR}/maven-mvnd-${MVND_VERSION}-${OS_TYPE}-${ARCH}/bin/mvnd"
119+
else
120+
if [ $(version $MVN_DETECTED_VERSION) -ne $(version $MVN_VERSION) ]; then
121+
echo "Mvnd $MVND_DETECTED_VERSION embedded maven version $MVN_DETECTED_VERSION is not equivalent to $MVN_VERSION required in pom."
122+
exit 1
123+
fi
124+
fi
125+
}
126+
127+
install_mvn
128+
129+
cd "${_CALLING_DIR}"
130+
131+
# Set any `mvn` options if not already present
132+
export MAVEN_OPTS=${MAVEN_OPTS:-"$_COMPILE_JVM_OPTS"}
133+
134+
echo "Using \`mvnd\` from path: $MVND_BIN" 1>&2
135+
${MVND_BIN} $MAVEN_CLI_OPTS "$@"

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
<properties>
110110
<java.version>1.8</java.version>
111111
<maven.version>3.8.7</maven.version>
112+
<mvnd.version>0.9.0</mvnd.version>
112113
<maven.compiler.source>${java.version}</maven.compiler.source>
113114
<maven.compiler.target>${java.version}</maven.compiler.target>
114115
<scala.version>2.12.17</scala.version>

0 commit comments

Comments
 (0)