blob: 7a08281300bac1761541f5125359e76fbf37d9c5 [file] [log] [blame]
robert.tomczyk5fe5de72019-07-22 20:48:58 +01001#!/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
19set -e
20
21BASE_DIR=$(pwd)
22
23SOURCE="${BASH_SOURCE[0]}"
24while [ -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
28done
29SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
30source ${BASE_DIR}/geode/ci/scripts/shared_utilities.sh
31
32if [[ -z "${GRADLE_TASK}" ]]; then
33 echo "GRADLE_TASK must be set. exiting..."
34 exit 1
35fi
36
37ROOT_DIR=$(pwd)
38BUILD_DATE=$(date +%s)
39
40# Precheckin does not get a geode-build-version
41if [ -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.tomczyk0c8e2ec2019-07-25 16:50:20 +010052 BUILD_DATE=$(cat ${GEODE_BUILD_VERSION_FILE} | cut -d'-' -f2 | cut -d'.' -f2)
53 echo -e "GEODE BUILD_DATE is ${BUILD_DATE}"
robert.tomczyk5fe5de72019-07-22 20:48:58 +010054 FULL_PRODUCT_VERSION=$(cat ${GEODE_BUILD_VERSION_FILE})
55 echo -e "FULL PRODUCT VERSION is ${FULL_PRODUCT_VERSION}\n"
56 fi
57fi
58
59if [[ ${PARALLEL_GRADLE:-"true"} == "true" ]]; then
60 PARALLEL_GRADLE="--parallel"
61else
62 PARALLEL_GRADLE=""
63fi
64DEFAULT_GRADLE_TASK_OPTIONS="${PARALLEL_GRADLE} --console=plain --no-daemon"
65GRADLE_SKIP_TASK_OPTIONS=""
66
67if [[ -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
72else
73 PARALLEL_DUNIT=""
74 DUNIT_PARALLEL_FORKS=""
75fi
76
77SET_JAVA_HOME="export JAVA_HOME=/usr/lib/jvm/java-${JAVA_BUILD_VERSION}-openjdk-amd64"
78
79if [ -z "${FULL_PRODUCT_VERSION}" ] ; then
80 FULL_PRODUCT_VERSION="0.0.0-UndefinedVersion"
81fi
82
83GRADLE_ARGS="\
84 ${DEFAULT_GRADLE_TASK_OPTIONS} \
85 ${GRADLE_SKIP_TASK_OPTIONS} \
86 ${GRADLE_GLOBAL_ARGS} \
87 -Pversion=${FULL_PRODUCT_VERSION} \
robert.tomczyk0c8e2ec2019-07-25 16:50:20 +010088 -PbuildId=${BUILD_DATE} \
robert.tomczyk5fe5de72019-07-22 20:48:58 +010089 build install javadoc spotlessCheck rat checkPom resolveDependencies -x test"
90
91EXEC_COMMAND="mkdir -p tmp && cd geode && ${SET_JAVA_HOME} && ./gradlew ${GRADLE_ARGS}"
92echo "${EXEC_COMMAND}"
93eval ${EXEC_COMMAND}