forked from scala/community-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·196 lines (169 loc) · 5.78 KB
/
run.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/usr/bin/env bash
# This script is suitable for local use.
# It is also invoked by Jenkins (from scripts/jobs/integrate/community-build).
set -e
set -o pipefail
# redundant to delete both at start and end, but just in case
# these were left lying around...
echo "removing temporary files..."
rm -rf target-*/project-builds || true
export LANG="en_US.UTF-8"
export HOME="$(pwd)"
# Defaults
scala_version_default="2.12.9-bin-d28a129" # May 17
scala_version="$scala_version_default"
root_dir=$(pwd)
config_dir="configs"
dbuild_file="$config_dir/community.dbuild"
project_refs_conf="$config_dir/project-refs.conf"
resolvers_file_default="$config_dir/resolvers.conf"
resolvers_file=$resolvers_file_default
debug="false"
jvm_props=""
local_mode="false"
notify="false"
dbuild_args=""
Usage(){
ex=$1
shift
echo >&2 "Usage: `basename $0` [<options>] [projects...]
Function: Downloads dbuild if not already installed locally and runs dbuild with defined options.
Options:
-c <dir> directory for the configuration
This resets -f, -p and -r options so specify this first: default $config_dir
-d print more debugging information
-D <key=value>... one or more Java-style properties: default $jvm_props
-f <file> dbuild file: default $dbuild_file
-h prints this help message and exits
-l local mode, equivalent to '-r none': default $local_mode
-n enable notifications defined in the configuration files: default $notify
-p <file> project refs file: default $project_refs_conf
-r <file> resolvers file, if 'none' then disable parsing: default $resolvers_file
-v <version> scala version, can be overridden by 'version=2.12.1 ./run.sh' : default latest nightly
Examples:
./run.sh
./run.sh -c configs-tls
version=2.12 ./run.sh
version=2.12.1-bin-933bab2 ./run.sh project1
version=2.12.1-bin-933bab2 ./run.sh project1,project2,project3
If no Scala version is specified, we use whatever's hardcoded in run.sh.
"
echo >&2 "$@"
exit $ex
}
while getopts c:dD:f:hlnp:r:s:v: c; do
case $c in
c) config_dir="$OPTARG"
dbuild_file="$config_dir/community.dbuild"
project_refs_conf="$config_dir/project-refs.conf"
resolvers_file_default="$config_dir/resolvers.conf"
resolvers_file=$resolvers_file_default
;;
d) debug="true"
;;
D) jvm_props="$OPTARG"
;;
f) dbuild_file="$OPTARG"
;;
h) Usage 0
;;
l) local_mode="true"
;;
n) notify="true"
;;
p) project_refs_conf="$OPTARG"
;;
r) resolvers_file="$OPTARG"
;;
v) scala_version="$OPTARG"
;;
esac
done
shift `expr $OPTIND - 1`
if [ "$debug" = "true" ]; then
echo "
cbuild settings:
config directory: $config_dir
debug: $debug
dbuild file: $dbuild_file
dbuild_args: ${@}
jvm_props: $jvm_props
local_mode: $local_mode
notify: $notify
project refs conf: $project_refs_conf
resolvers_file_default: $resolvers_file_default
resolvers_file $resolvers_file
root directory: $root_dir
scala_version_default: $scala_version_default
scala_version: $scala_version
"
fi
export version=${version-$scala_version}
if [ "$version" = "$scala_version_default" ]; then
>&2 echo "No Scala version specified. Using latest nightly."
fi
echo "re-run as:"
echo version=$version ./run.sh ${@}
# In a config, we cannot use a variable in an include statement, so have a workaround
# whereby we copy the contents of the real file to a temporary file of known name.
mkdir -p .dbuild
if [ "$resolvers_file" = "none" ]; then
cat $resolvers_file_default > .dbuild/resolvers.conf
else
cat $resolvers_file > .dbuild/resolvers.conf
fi
cat $project_refs_conf > .dbuild/project-refs.conf
# Set dbuild version and config file
DBUILDVERSION=0.9.16
echo "dbuild version: $DBUILDVERSION"
DBUILDCONFIG=$dbuild_file
echo "dbuild config file: $DBUILDCONFIG"
if [ ! -f "$DBUILDCONFIG" ]
then
echo "File not found: $DBUILDCONFIG"
exit 1
fi
# Download and extract dbuild if we haven't already got it
if [ ! -d "dbuild-${DBUILDVERSION}" ]
then
wget "http://repo.lightbend.com/typesafe/ivy-releases/com.typesafe.dbuild/dbuild/${DBUILDVERSION}/tgzs/dbuild-${DBUILDVERSION}.tgz"
tar xfz "dbuild-${DBUILDVERSION}.tgz"
rm "dbuild-${DBUILDVERSION}.tgz"
fi
# sigh, Ubuntu has nodejs but OS X has node
if hash nodejs 2>/dev/null; then
export NODE=nodejs
else
export NODE=node
fi
# Set the options we want to pass into dbuild
if [ "$debug" = "true" ];then
dbuild_args="$dbuild_args -d"
fi
if [ -n "$jvm_props" ];then
dbuild_args="$dbuild_args -Dkey=\"$jvm_props\""
fi
if [ "$local_mode" = "true" ];then
dbuild_args="$dbuild_args -l"
else
if [ "$resolvers_file" = "none" ]; then
dbuild_args="$dbuild_args -r"
fi
# use -n by default since running locally you don't want notifications sent,
# and on our Jenkins setup it doesn't actually work (for now anyway)
if [ "$notify" = "false" ];then
dbuild_args="$dbuild_args -n"
fi
fi
# And finally, call dbuild
echo "dbuild-${DBUILDVERSION}/bin/dbuild" "$dbuild_args" "$DBUILDCONFIG" "${@}"
("dbuild-${DBUILDVERSION}/bin/dbuild" "$dbuild_args" "$DBUILDCONFIG" "${@}" 2>&1 | tee "dbuild-${DBUILDVERSION}/dbuild.out") || STATUS="$?"
BUILD_ID="$(grep '^\[info\] uuid = ' "dbuild-${DBUILDVERSION}/dbuild.out" | sed -e 's/\[info\] uuid = //')"
echo "The repeatable UUID of this build was: ${BUILD_ID}"
# we may have run out of disk, so make space ASAP
echo "removing temporary files..."
rm -rf target-*/project-builds
# report summary information (line counts, green project counts, ...?)
cd report
sbt -Dsbt.supershell=false -error "run ../dbuild-${DBUILDVERSION}/dbuild.out"
exit $STATUS