| #!/usr/bin/env bash |
| # |
| # Licensed to the Apache Software Foundation (ASF) under one |
| # or more contributor license agreements. See the NOTICE file |
| # distributed with this work for additional information |
| # regarding copyright ownership. The ASF licenses this file |
| # to you under the Apache License, Version 2.0 (the |
| # "License"); you may not use this file except in compliance |
| # with the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| set -e |
| |
| BASE_DIR=$(pwd) |
| |
| SOURCE="${BASH_SOURCE[0]}" |
| while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink |
| SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" |
| SOURCE="$(readlink "$SOURCE")" |
| [[ $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 |
| done |
| SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" |
| |
| if [[ -z "${GRADLE_TASK}" ]]; then |
| echo "GRADLE_TASK must be set. exiting..." |
| exit 1 |
| fi |
| |
| REPODIR=$(cd geode; git rev-parse --show-toplevel) |
| |
| if [[ ${PARALLEL_GRADLE:-"true"} == "true" ]]; then |
| PARALLEL_GRADLE="--parallel" |
| else |
| PARALLEL_GRADLE="--no-parallel" |
| fi |
| DEFAULT_GRADLE_TASK_OPTIONS="${PARALLEL_GRADLE} --console=plain --no-daemon" |
| GRADLE_SKIP_TASK_OPTIONS="-x javadoc -x spotlessCheck -x rat" |
| |
| if [[ -n "${PARALLEL_DUNIT}" && "${PARALLEL_DUNIT}" == "true" ]]; then |
| PARALLEL_DUNIT="-PparallelDunit -PdunitDockerUser=geode" |
| if [ -n "${DUNIT_PARALLEL_FORKS}" ]; then |
| DUNIT_PARALLEL_FORKS="-PdunitParallelForks=${DUNIT_PARALLEL_FORKS}" |
| fi |
| else |
| PARALLEL_DUNIT="" |
| DUNIT_PARALLEL_FORKS="" |
| fi |
| |
| case $ARTIFACT_SLUG in |
| windows*) |
| JAVA_BUILD_PATH=C:/java${JAVA_BUILD_VERSION} |
| JAVA_TEST_PATH=C:/java${JAVA_TEST_VERSION} |
| SEP=";" |
| ;; |
| *) |
| JAVA_BUILD_PATH=/usr/lib/jvm/java-${JAVA_BUILD_VERSION}-openjdk-amd64 |
| JAVA_TEST_PATH=/usr/lib/jvm/java-${JAVA_TEST_VERSION}-openjdk-amd64 |
| SEP="&&" |
| ;; |
| esac |
| |
| GRADLE_ARGS=" \ |
| -PcompileJVM=${JAVA_BUILD_PATH} \ |
| -PcompileJVMVer=${JAVA_BUILD_VERSION} \ |
| -PtestJVM=${JAVA_TEST_PATH} \ |
| -PtestJVMVer=${JAVA_TEST_VERSION} \ |
| ${PARALLEL_DUNIT} \ |
| ${DUNIT_PARALLEL_FORKS} \ |
| -PdunitDockerImage=\$(docker images --format '{{.Repository}}:{{.Tag}}' | grep test-container) \ |
| ${DEFAULT_GRADLE_TASK_OPTIONS} \ |
| ${GRADLE_SKIP_TASK_OPTIONS} \ |
| ${GRADLE_TASK} \ |
| ${GRADLE_TASK_OPTIONS} \ |
| ${GRADLE_GLOBAL_ARGS}" |
| |
| EXEC_COMMAND="bash -c 'echo Building with: $SEP \ |
| ${JAVA_BUILD_PATH}/bin/java -version $SEP \ |
| echo Testing with: $SEP \ |
| ${JAVA_TEST_PATH}/bin/java -version $SEP \ |
| cd geode $SEP \ |
| cp gradlew gradlewStrict $SEP \ |
| sed -e 's/JAVA_HOME/GRADLE_JVM/g' -i.bak gradlewStrict $SEP \ |
| GRADLE_JVM=${JAVA_BUILD_PATH} ./gradlewStrict ${GRADLE_ARGS}'" |
| echo "${EXEC_COMMAND}" |
| eval "${EXEC_COMMAND}" |
| |
| # Cleanup |
| # Make sure all test containers are stopped and removed when tests are finished |
| DOCKER_CONTAINERS=$(sudo docker ps -a -q 2> /dev/null) |
| if [ -n "${DOCKER_CONTAINERS}" ]; then |
| docker stop ${DOCKER_CONTAINERS} > /dev/null |
| echo -e "Removing containers with ID:" |
| docker rm ${DOCKER_CONTAINERS} |
| fi |
| |