Alice Kober-Sotzek | 9a89567 | 2019-08-07 12:45:56 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2019 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # This script compiles a Gerrit plugin whose name is passed as first parameter |
| 18 | # and copies it over to the plugin folder of the testsite. The path to the |
| 19 | # testsite needs to be provided by the variable GERRIT_TESTSITE or as second |
| 20 | # parameter. |
| 21 | |
| 22 | SCRIPT_DIR=$(dirname -- "$(readlink -f -- "$BASH_SOURCE")") |
| 23 | GERRIT_CODE_DIR="$SCRIPT_DIR/.." |
| 24 | cd "$GERRIT_CODE_DIR" |
| 25 | |
| 26 | if [ "$#" -lt 1 ] |
| 27 | then |
| 28 | echo "No plugin name provided as first argument. Stopping." |
| 29 | exit 1 |
| 30 | else |
| 31 | PLUGIN_NAME="$1" |
| 32 | fi |
| 33 | |
| 34 | |
| 35 | if [ "$#" -lt 2 ] |
| 36 | then |
| 37 | if [ -z ${GERRIT_TESTSITE+x} ] |
| 38 | then |
| 39 | echo "Path to local testsite is neiter set as GERRIT_TESTSITE nor passed as second argument. Stopping." |
| 40 | exit 1 |
| 41 | fi |
| 42 | else |
| 43 | GERRIT_TESTSITE="$2" |
| 44 | fi |
| 45 | |
| 46 | if [ ! -d "$GERRIT_TESTSITE" ] |
| 47 | then |
| 48 | echo "Testsite directory $GERRIT_TESTSITE does not exist. Stopping." |
| 49 | exit 1 |
| 50 | fi |
| 51 | |
| 52 | bazel build //plugins/"$PLUGIN_NAME"/... |
| 53 | if [ $? -ne 0 ] |
| 54 | then |
| 55 | echo "Building the $PLUGIN_NAME plugin failed" |
| 56 | exit 1 |
| 57 | fi |
| 58 | |
| 59 | yes | cp -f "$GERRIT_CODE_DIR/bazel-genfiles/plugins/$PLUGIN_NAME/$PLUGIN_NAME.jar" "$GERRIT_TESTSITE/plugins/" |
| 60 | if [ $? -eq 0 ] |
| 61 | then |
| 62 | echo "Plugin $PLUGIN_NAME copied successfully to testsite." |
| 63 | fi |