Skip to content

Commit 494078f

Browse files
committed
introduce mvnd
1 parent 31077b5 commit 494078f

File tree

7 files changed

+220
-12
lines changed

7 files changed

+220
-12
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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: 'Install the maven daemon'
20+
inputs:
21+
version:
22+
description: 'The version of the maven daemon to install'
23+
required: true
24+
default: '0.9.0'
25+
outputs:
26+
mvnd-dir:
27+
description: "The directory where the command mvnd is located"
28+
value: ${{ steps.mvnd-location.outputs.mvnd-dir }}
29+
runs:
30+
using: "composite"
31+
steps:
32+
- name: Cache Mvnd
33+
if: false
34+
id: cache-mvnd
35+
uses: actions/cache@v3
36+
with:
37+
path: build/maven-mvnd-*
38+
key: ${{ runner.os }}-mvnd
39+
- run: |
40+
case "$(uname -s)" in
41+
Linux*) osType=linux;;
42+
Darwin*) osType=darwin;;
43+
CYGWIN*) osType=windows;;
44+
MINGW*) osType=windows;;
45+
*) osType="UNKNOWN:${unameOsOut}"
46+
esac
47+
case "$(uname -m)" in
48+
x86_64*) arch=amd64;;
49+
arm64*) arch=aarch64;;
50+
*) arch="UNKNOWN:${unameOsOut}"
51+
esac
52+
echo "$osType"
53+
echo "$arch"
54+
if test ! -f "build/maven-mvnd-${{ inputs.version }}-${osType}-${arch}/bin/mvnd"; then
55+
build/mvnd -v
56+
fi
57+
shell: bash
58+
- id: check-mvnd-version
59+
run: build/mvnd -v
60+
shell: bash

.github/workflows/dep.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ on:
2525
paths:
2626
# dependency check happens only pom changes
2727
- '**/pom.xml'
28+
- .github/actions/install-mvnd/*.yaml
2829

2930
concurrency:
3031
group: dep-${{ github.ref }}
@@ -43,11 +44,13 @@ jobs:
4344
java-version: 8
4445
cache: 'maven'
4546
check-latest: false
47+
- name: Setup Mvnd
48+
uses: ./.github/actions/install-mvnd
4649
- name: build
4750
env:
4851
MAVEN_OPTS: -Dorg.slf4j.simpleLogger.defaultLogLevel=error
4952
run: >-
50-
build/mvn clean install
53+
build/mvnd clean install
5154
-Pflink-provided,spark-provided,hive-provided
5255
-Dmaven.javadoc.skip=true
5356
-Drat.skip=true

.github/workflows/master.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,13 @@ jobs:
254254
java-version: ${{ matrix.java }}
255255
cache: 'maven'
256256
check-latest: false
257+
- name: Setup Mvnd
258+
uses: ./.github/actions/install-mvnd
257259
- name: Build and test JDBC with maven w/o linters
258260
run: |
259261
TEST_MODULES="externals/kyuubi-jdbc-engine,integration-tests/kyuubi-jdbc-it"
260-
./build/mvn ${MVN_OPT} -pl ${TEST_MODULES} -am clean install -DskipTests
261-
./build/mvn ${MVN_OPT} -pl ${TEST_MODULES} test
262+
mvnd ${MVN_OPT} -pl ${TEST_MODULES} -am clean install -DskipTests
263+
mvnd ${MVN_OPT} -pl ${TEST_MODULES} test
262264
- name: Upload test logs
263265
if: failure()
264266
uses: actions/upload-artifact@v3
@@ -282,6 +284,8 @@ jobs:
282284
- uses: actions/checkout@v3
283285
- name: Tune Runner VM
284286
uses: ./.github/actions/tune-runner-vm
287+
- name: Setup Mvnd
288+
uses: ./.github/actions/install-mvnd
285289
- name: Setup JDK ${{ matrix.java }}
286290
uses: actions/setup-java@v3
287291
with:
@@ -292,8 +296,8 @@ jobs:
292296
- name: Build and test Trino with maven w/o linters
293297
run: |
294298
TEST_MODULES="externals/kyuubi-trino-engine,integration-tests/kyuubi-trino-it"
295-
./build/mvn ${MVN_OPT} -pl ${TEST_MODULES} -am clean install -DskipTests
296-
./build/mvn ${MVN_OPT} -pl ${TEST_MODULES} test
299+
mvnd ${MVN_OPT} -pl ${TEST_MODULES} -am clean install -DskipTests
300+
mvnd ${MVN_OPT} -pl ${TEST_MODULES} test
297301
- name: Upload test logs
298302
if: failure()
299303
uses: actions/upload-artifact@v3

.github/workflows/style.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ concurrency:
2929

3030
jobs:
3131
linter:
32+
if: true
3233
name: Style check
3334
runs-on: ubuntu-22.04
3435
strategy:
@@ -45,14 +46,16 @@ jobs:
4546
java-version: 8
4647
cache: 'maven'
4748
check-latest: false
49+
- name: Setup Mvnd
50+
uses: ./.github/actions/install-mvnd
4851
- name: Setup Python 3
4952
uses: actions/setup-python@v4
5053
with:
5154
python-version: '3.9'
5255
cache: 'pip'
53-
- name: Check kyuubi modules avaliable
56+
- name: Check kyuubi modules available
5457
id: modules-check
55-
run: build/mvn dependency:resolve -DincludeGroupIds="org.apache.kyuubi" -DincludeScope="compile" -DexcludeTransitive=true ${{ matrix.profiles }}
58+
run: build/mvnd dependency:resolve -DincludeGroupIds="org.apache.kyuubi" -DincludeScope="compile" -DexcludeTransitive=true ${{ matrix.profiles }}
5659
continue-on-error: true
5760

5861
- name: Install
@@ -61,13 +64,13 @@ jobs:
6164
if: steps.modules-check.conclusion == 'success' && steps.modules-check.outcome == 'failure'
6265
run: |
6366
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
67+
build/mvnd clean install ${MVN_OPT} -Pflink-provided,hive-provided,spark-provided,spark-block-cleaner,spark-3.2,tpcds
68+
build/mvnd clean install ${MVN_OPT} -pl extensions/spark/kyuubi-extension-spark-3-1 -Pspark-3.1
69+
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
6770
6871
- name: Scalastyle with maven
6972
id: scalastyle-check
70-
run: build/mvn scalastyle:check ${{ matrix.profiles }}
73+
run: build/mvnd scalastyle:check ${{ matrix.profiles }}
7174
- name: Print scalastyle error report
7275
if: failure() && steps.scalastyle-check.outcome != 'success'
7376
run: >-
@@ -81,7 +84,7 @@ jobs:
8184
run: |
8285
SPOTLESS_BLACK_VERSION=$(build/mvn help:evaluate -Dexpression=spotless.python.black.version -q -DforceStdout)
8386
pip install black==$SPOTLESS_BLACK_VERSION
84-
build/mvn spotless:check ${{ matrix.profiles }} -Pspotless-python
87+
build/mvnd spotless:check ${{ matrix.profiles }} -Pspotless-python
8588
- name: setup npm
8689
uses: actions/setup-node@v3
8790
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: 2 additions & 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>
@@ -244,6 +245,7 @@
244245
<distMgmtSnapshotsId>apache.snapshots.https</distMgmtSnapshotsId>
245246
<distMgmtSnapshotsName>Apache Development Snapshot Repository</distMgmtSnapshotsName>
246247
<distMgmtSnapshotsUrl>https://repository.apache.org/content/repositories/snapshots</distMgmtSnapshotsUrl>
248+
247249
</properties>
248250

249251
<dependencyManagement>

0 commit comments

Comments
 (0)