|
| 1 | +#!/bin/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 | +## |
| 21 | +## Variables with defaults (if not overwritten by environment) |
| 22 | +## |
| 23 | +MVN=${MVN:-mvn} |
| 24 | +# fail immediately |
| 25 | +set -o errexit |
| 26 | +set -o nounset |
| 27 | + |
| 28 | +CURR_DIR=$(pwd) |
| 29 | +if [ ! -d "$CURR_DIR/packaging" ] ; then |
| 30 | + echo "You have to call the script from the repository root dir that contains 'packaging/'" |
| 31 | + exit 1 |
| 32 | +fi |
| 33 | + |
| 34 | +if [ "$#" -gt "1" ]; then |
| 35 | + echo "Only accept 0 or 1 argument. Use -h to see examples." |
| 36 | + exit 1 |
| 37 | +fi |
| 38 | + |
| 39 | +declare -a ALL_VERSION_OPTS=( |
| 40 | +"-T 1C -Dscala-2.12 -Dflink2.0 -Davro.version=1.11.4 -Dparquet.version=1.14.4 -pl packaging/hudi-flink-bundle -am" |
| 41 | +) |
| 42 | +printf -v joined "'%s'\n" "${ALL_VERSION_OPTS[@]}" |
| 43 | + |
| 44 | +if [ "${1:-}" == "-h" ]; then |
| 45 | + echo " |
| 46 | +Usage: $(basename "$0") [OPTIONS] |
| 47 | +
|
| 48 | +Options: |
| 49 | +<version option> One of the version options below |
| 50 | +${joined} |
| 51 | +-h, --help |
| 52 | +" |
| 53 | + exit 0 |
| 54 | +fi |
| 55 | + |
| 56 | +VERSION_OPT=${1:-} |
| 57 | +valid_version_opt=false |
| 58 | +for v in "${ALL_VERSION_OPTS[@]}"; do |
| 59 | + [[ $VERSION_OPT == "$v" ]] && valid_version_opt=true |
| 60 | +done |
| 61 | + |
| 62 | +if [ "$valid_version_opt" = true ]; then |
| 63 | + # run deploy for only specified version option |
| 64 | + ALL_VERSION_OPTS=("$VERSION_OPT") |
| 65 | +elif [ "$#" == "1" ]; then |
| 66 | + echo "Version option $VERSION_OPT is invalid. Use -h to see examples." |
| 67 | + exit 1 |
| 68 | +fi |
| 69 | + |
| 70 | +COMMON_OPTIONS="-DdeployArtifacts=true -DskipTests -DretryFailedDeploymentCount=10" |
| 71 | +for v in "${ALL_VERSION_OPTS[@]}" |
| 72 | +do |
| 73 | + # TODO: consider cleaning all modules by listing directories instead of specifying profile |
| 74 | + echo "Cleaning everything before any deployment" |
| 75 | + $MVN clean $COMMON_OPTIONS ${v} |
| 76 | + echo "Building with options ${v}" |
| 77 | + $MVN install $COMMON_OPTIONS ${v} |
| 78 | + |
| 79 | + echo "Deploying to repository.apache.org with version options ${v%-am}" |
| 80 | + # remove `-am` option to only deploy intended modules |
| 81 | + $MVN deploy $COMMON_OPTIONS ${v%-am} |
| 82 | +done |
0 commit comments