robert.tomczyk | 5fe5de7 | 2019-07-22 20:48:58 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # Licensed to the Apache Software Foundation (ASF) under one |
| 4 | # or more contributor license agreements. See the NOTICE file |
| 5 | # distributed with this work for additional information |
| 6 | # regarding copyright ownership. The ASF licenses this file |
| 7 | # to you under the Apache License, Version 2.0 (the |
| 8 | # "License"); you may not use this file except in compliance |
| 9 | # with 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 | set -e |
| 20 | |
| 21 | BASE_DIR=$(pwd) |
| 22 | |
| 23 | SOURCE="${BASH_SOURCE[0]}" |
| 24 | while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink |
| 25 | SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" |
| 26 | SOURCE="$(readlink "$SOURCE")" |
| 27 | [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located |
| 28 | done |
| 29 | SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" |
| 30 | source ${BASE_DIR}/geode/ci/scripts/shared_utilities.sh |
| 31 | |
| 32 | if [[ -z "${GRADLE_TASK}" ]]; then |
| 33 | echo "GRADLE_TASK must be set. exiting..." |
| 34 | exit 1 |
| 35 | fi |
| 36 | |
| 37 | ROOT_DIR=$(pwd) |
| 38 | BUILD_DATE=$(date +%s) |
| 39 | |
| 40 | # Precheckin does not get a geode-build-version |
| 41 | if [ -e "${ROOT_DIR}/geode-build-version" ] ; then |
| 42 | GEODE_BUILD_VERSION_FILE=${ROOT_DIR}/geode-build-version/number |
| 43 | GEODE_BUILD_DIR=/tmp/geode-build |
| 44 | GEODE_PULL_REQUEST_ID_FILE=${ROOT_DIR}/geode/.git/resource/version.json |
| 45 | |
| 46 | if [ -e "${GEODE_PULL_REQUEST_ID_FILE}" ]; then |
| 47 | GEODE_PULL_REQUEST_ID=$(cat ${GEODE_PULL_REQUEST_ID_FILE} | jq --raw-output '.["pr"]') |
| 48 | FULL_PRODUCT_VERSION="geode-pr-${GEODE_PULL_REQUEST_ID}" |
| 49 | else |
| 50 | GEODE_VERSION=$(cat ${GEODE_BUILD_VERSION_FILE} | cut -d'-' -f1) |
| 51 | echo -e "\nGEODE VERSION is ${GEODE_VERSION}" |
robert.tomczyk | 0c8e2ec | 2019-07-25 16:50:20 +0100 | [diff] [blame] | 52 | BUILD_DATE=$(cat ${GEODE_BUILD_VERSION_FILE} | cut -d'-' -f2 | cut -d'.' -f2) |
| 53 | echo -e "GEODE BUILD_DATE is ${BUILD_DATE}" |
robert.tomczyk | 5fe5de7 | 2019-07-22 20:48:58 +0100 | [diff] [blame] | 54 | FULL_PRODUCT_VERSION=$(cat ${GEODE_BUILD_VERSION_FILE}) |
| 55 | echo -e "FULL PRODUCT VERSION is ${FULL_PRODUCT_VERSION}\n" |
| 56 | fi |
| 57 | fi |
| 58 | |
| 59 | if [[ ${PARALLEL_GRADLE:-"true"} == "true" ]]; then |
| 60 | PARALLEL_GRADLE="--parallel" |
| 61 | else |
| 62 | PARALLEL_GRADLE="" |
| 63 | fi |
| 64 | DEFAULT_GRADLE_TASK_OPTIONS="${PARALLEL_GRADLE} --console=plain --no-daemon" |
| 65 | GRADLE_SKIP_TASK_OPTIONS="" |
| 66 | |
| 67 | if [[ -n "${PARALLEL_DUNIT}" && "${PARALLEL_DUNIT}" == "true" ]]; then |
| 68 | PARALLEL_DUNIT="-PparallelDunit -PdunitDockerUser=geode" |
| 69 | if [ -n "${DUNIT_PARALLEL_FORKS}" ]; then |
| 70 | DUNIT_PARALLEL_FORKS="-PdunitParallelForks=${DUNIT_PARALLEL_FORKS}" |
| 71 | fi |
| 72 | else |
| 73 | PARALLEL_DUNIT="" |
| 74 | DUNIT_PARALLEL_FORKS="" |
| 75 | fi |
| 76 | |
| 77 | SET_JAVA_HOME="export JAVA_HOME=/usr/lib/jvm/java-${JAVA_BUILD_VERSION}-openjdk-amd64" |
| 78 | |
| 79 | if [ -z "${FULL_PRODUCT_VERSION}" ] ; then |
| 80 | FULL_PRODUCT_VERSION="0.0.0-UndefinedVersion" |
| 81 | fi |
| 82 | |
| 83 | GRADLE_ARGS="\ |
| 84 | ${DEFAULT_GRADLE_TASK_OPTIONS} \ |
| 85 | ${GRADLE_SKIP_TASK_OPTIONS} \ |
| 86 | ${GRADLE_GLOBAL_ARGS} \ |
| 87 | -Pversion=${FULL_PRODUCT_VERSION} \ |
robert.tomczyk | 0c8e2ec | 2019-07-25 16:50:20 +0100 | [diff] [blame] | 88 | -PbuildId=${BUILD_DATE} \ |
robert.tomczyk | 5fe5de7 | 2019-07-22 20:48:58 +0100 | [diff] [blame] | 89 | build install javadoc spotlessCheck rat checkPom resolveDependencies -x test" |
| 90 | |
| 91 | EXEC_COMMAND="mkdir -p tmp && cd geode && ${SET_JAVA_HOME} && ./gradlew ${GRADLE_ARGS}" |
| 92 | echo "${EXEC_COMMAND}" |
| 93 | eval ${EXEC_COMMAND} |