blob: bb42ce821a857b35a599a5dcc1a88565802b1192 [file] [log] [blame]
Alice Kober-Sotzek9a895672019-08-07 12:45:56 +02001#!/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
22SCRIPT_DIR=$(dirname -- "$(readlink -f -- "$BASH_SOURCE")")
23GERRIT_CODE_DIR="$SCRIPT_DIR/.."
24cd "$GERRIT_CODE_DIR"
25
26if [ "$#" -lt 1 ]
27then
28 echo "No plugin name provided as first argument. Stopping."
29 exit 1
30else
31 PLUGIN_NAME="$1"
32fi
33
34
35if [ "$#" -lt 2 ]
36then
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
42else
43 GERRIT_TESTSITE="$2"
44fi
45
46if [ ! -d "$GERRIT_TESTSITE" ]
47then
48 echo "Testsite directory $GERRIT_TESTSITE does not exist. Stopping."
49 exit 1
50fi
51
52bazel build //plugins/"$PLUGIN_NAME"/...
53if [ $? -ne 0 ]
54then
55 echo "Building the $PLUGIN_NAME plugin failed"
56 exit 1
57fi
58
59yes | cp -f "$GERRIT_CODE_DIR/bazel-genfiles/plugins/$PLUGIN_NAME/$PLUGIN_NAME.jar" "$GERRIT_TESTSITE/plugins/"
60if [ $? -eq 0 ]
61then
62 echo "Plugin $PLUGIN_NAME copied successfully to testsite."
63fi