forked from salesforce/rules_spring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrite_bazelrun_env.sh
executable file
·46 lines (39 loc) · 1.37 KB
/
write_bazelrun_env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
#
# Copyright (c) 2021, salesforce.com, inc.
# All rights reserved.
# Licensed under the BSD 3-Clause license.
# For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
#
# This file is used to generate the environment variables used by the
# default_bazelrun_script.sh for launching Spring Boot applications with
# bazel run, as in 'bazel run //examples/helloworld'
set -e
RULE_NAME=${1}
SPRINGBOOTJAR_FILENAME=${2}
LABEL_PATH=${3}
OUTPUTFILE_PATH=${4}
DO_BACKGROUND=${5}
FIRST_JVMFLAG_ARG=6
if [ "$LABEL_PATH" == "root" ]; then
# token that indicates that the target is in the root path, which for the
# purposes of the label path, is empty string
LABEL_PATH=""
fi
#echo "Generating 'bazel run' env."
#echo "SPRINGBOOTJAR_FILENAME=$SPRINGBOOTJAR_FILENAME"
#echo "LABEL_PATH=$LABEL_PATH"
#echo "OUTPUTFILE_PATH=$OUTPUTFILE_PATH"
#echo "DO_BACKGROUND=$DO_BACKGROUND"
JVM_FLAGS=""
i=$FIRST_JVMFLAG_ARG
while [ "$i" -le "$#" ]; do
eval "FLAG=\${$i}"
JVM_FLAGS="$JVM_FLAGS $FLAG"
i=$((i + 1))
done
echo "export RULE_NAME=$RULE_NAME" > $OUTPUTFILE_PATH
echo "export LABEL_PATH=$LABEL_PATH" >> $OUTPUTFILE_PATH
echo "export SPRINGBOOTJAR_FILENAME=$SPRINGBOOTJAR_FILENAME" >> $OUTPUTFILE_PATH
echo "export DO_BACKGROUND=$DO_BACKGROUND" >> $OUTPUTFILE_PATH
echo "export JVM_FLAGS=\"$JVM_FLAGS\"" >> $OUTPUTFILE_PATH