[KYUUBI #1834] [BUILD] Add support of external mvn with default mvn jvm opts when making distribution

### _Why are the changes needed?_

most of time, we use the mvn pre-installed in the OS

### _How was this patch tested?_

After running the script `build/dist`, it should echo the 'MVN' location before building the release package

```bash
build/dist --tgz --name release-demo \
        --spark-provided --flink-provided \
        --mvn $(which mvn) \
        -DskipTests \
        -Pjava-8 -Pspark-hadoop-3.2 -Pspark-3.0
```

Closes #1834 from goldenbean/dev/mvn.

Closes #1834

26f13da8 [jing10.gao] break usage into multi-lines
e1d14d3c [jing10.gao] update the usage
954e8471 [jing10.gao] external mvn
056c518f [jing10.gao] external mvn

Authored-by: jing10.gao <jing10.gao@vipshop.com>
Signed-off-by: Cheng Pan <chengpan@apache.org>
This commit is contained in:
jing10.gao 2022-01-25 16:36:03 +08:00 committed by Cheng Pan
parent 20d832ab21
commit fecbd70121
No known key found for this signature in database
GPG Key ID: 8001952629BCC75D

View File

@ -41,12 +41,14 @@ function usage {
echo ""
echo "Usage:"
echo "+--------------------------------------------------------------------------------------+"
echo "| ./build/dist [--name <custom_name>] [--tgz] [--flink-provided] [--spark-provided] <maven build options> |"
echo "| ./build/dist [--name <custom_name>] [--tgz] [--flink-provided] [--spark-provided] |"
echo "| [--mvn <maven_executable>] <maven build options> |"
echo "+--------------------------------------------------------------------------------------+"
echo "name: - custom binary name, using project version if undefined"
echo "tgz: - whether to make a whole bundled package"
echo "flink-provided: - whether to make a package without Flink binary"
echo "spark-provided: - whether to make a package without Spark binary"
echo "mvn: - external maven executable location"
echo ""
}
@ -68,6 +70,10 @@ while (( "$#" )); do
--spark-provided)
SPARK_PROVIDED=true
;;
--mvn)
MVN="$2"
shift
;;
--name)
NAME="$2"
shift
@ -112,6 +118,16 @@ if [[ $(command -v git) ]]; then
unset GITREV
fi
if [ ! "$(command -v "$MVN")" ] ; then
echo -e "Could not locate Maven command: '$MVN'."
echo -e "Specify the Maven command with the --mvn flag"
exit -1;
fi
echo "MVN is set to $MVN"
VERSION=$("$MVN" help:evaluate -Dexpression=project.version $@ 2>/dev/null\
| grep -v "INFO"\
| grep -v "WARNING"\
@ -170,6 +186,7 @@ else
fi
MVN_DIST_OPT="-DskipTests"
if [[ "$SPARK_PROVIDED" == "true" ]]; then
MVN_DIST_OPT="$MVN_DIST_OPT -Pspark-provided"
fi
@ -178,6 +195,8 @@ if [[ "$FLINK_PROVIDED" == "true" ]]; then
MVN_DIST_OPT="$MVN_DIST_OPT -Pflink-provided"
fi
export MAVEN_OPTS="${MAVEN_OPTS:--Xmx2g}"
BUILD_COMMAND=("$MVN" clean install $MVN_DIST_OPT $@)
echo -e "\nBuilding with..."