Skip to content

Commit e8c5843

Browse files
committed
refactor: use booleans rather than yes/no strings
1 parent 9fa638c commit e8c5843

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

build-coatjava.sh

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ usage='''build-coatjava.sh [OPTIONS]... [MAVEN_OPTIONS]...
3535
# parse arguments
3636
################################################################################
3737

38-
cleanBuild="no"
39-
anaDepends="no"
40-
runSpotBugs="no"
41-
downloadMaps="yes"
42-
runUnitTests="no"
38+
cleanBuild=false
39+
anaDepends=false
40+
runSpotBugs=false
41+
downloadMaps=true
42+
runUnitTests=false
4343
useXrootd=false
4444
useCvmfs=false
4545
useLfs=false
@@ -50,12 +50,12 @@ wgetArgs=()
5050
for xx in $@
5151
do
5252
case $xx in
53-
--spotbugs) runSpotBugs="yes" ;;
54-
-n) runSpotBugs="no" ;;
55-
--nomaps) downloadMaps="no" ;;
56-
--unittests) runUnitTests="yes" ;;
57-
--clean) cleanBuild="yes" ;;
58-
--depana) anaDepends="yes" ;;
53+
--spotbugs) runSpotBugs=true ;;
54+
-n) runSpotBugs=false ;;
55+
--nomaps) downloadMaps=false ;;
56+
--unittests) runUnitTests=true ;;
57+
--clean) cleanBuild=true ;;
58+
--depana) anaDepends=true ;;
5959
--quiet)
6060
mvnArgs+=(--quiet --batch-mode)
6161
wgetArgs+=(--quiet)
@@ -152,7 +152,7 @@ download_map () {
152152
# (and duplicated in etc/services/reconstruction.yaml):
153153
source libexec/env.sh --no-classpath
154154
magfield_dir=$src_dir/etc/data/magfield
155-
if [ $cleanBuild == "no" ] && [ $downloadMaps == "yes" ]; then
155+
if ! $cleanBuild && $downloadMaps; then
156156
echo 'Retrieving field maps ...'
157157
if $useLfs; then
158158
download_lfs etc/data/magfield
@@ -182,7 +182,8 @@ if $useLfs; then
182182
elif $useCvmfs; then
183183
cp -rv /cvmfs/oasis.opensciencegrid.org/jlab/hallb/clas12/sw/noarch/data/networks/* etc/data/nnet/
184184
else
185-
echo "WARNING: neural networks not downloaded" >&2
185+
echo "WARNING: neural networks not downloaded; run with '--help' for guidance" >&2
186+
sleep 1
186187
fi
187188

188189
# download validation data
@@ -198,7 +199,7 @@ fi
198199
rm -rf $prefix_dir $clara_home
199200

200201
# clean up any cache copies
201-
if [ $cleanBuild == "yes" ]; then
202+
if $cleanBuild; then
202203
$mvn clean
203204
for target_dir in $(find $src_dir -type d -name target); do
204205
echo "WARNING: target directory '$target_dir' was not removed! JAR files within may be accidentally installed!" >&2
@@ -219,7 +220,7 @@ fi
219220
################################################################################
220221

221222
# run dependency analysis and exit
222-
if [ $anaDepends == "yes" ]; then
223+
if $anaDepends; then
223224
libexec/dependency-analysis.sh
224225
libexec/dependency-tree.sh
225226
exit 0
@@ -241,13 +242,13 @@ cp external-dependencies/jclara-4.3-SNAPSHOT.jar $prefix_dir/lib/utils
241242

242243
# spotbugs, unit tests
243244
unset CLAS12DIR
244-
if [ $runUnitTests == "yes" ]; then
245+
if $runUnitTests; then
245246
$mvn install # also runs unit tests
246247
else
247248
$mvn install -DskipTests
248249
fi
249250

250-
if [ $runSpotBugs == "yes" ]; then
251+
if $runSpotBugs; then
251252
# mvn com.github.spotbugs:spotbugs-maven-plugin:spotbugs # spotbugs goal produces a report target/spotbugsXml.xml for each module
252253
$mvn com.github.spotbugs:spotbugs-maven-plugin:check # check goal produces a report and produces build failed if bugs
253254
# the spotbugsXml.xml file is easiest read in a web browser

0 commit comments

Comments
 (0)