@@ -14,10 +14,10 @@ usage='''build-coatjava.sh [OPTIONS]... [MAVEN_OPTIONS]...
1414 --no-progress no download progress printouts
1515 --help show this message
1616
17- OPTIONS FOR MAGNETIC FIELD MAPS
18- --lfs use git-lfs for field maps and test data
19- --cvmfs use cvmfs to download field maps
20- --xrootd use xrootd to download field maps
17+ OPTIONS FOR MAGNETIC FIELD MAPS, NEURAL NETWORK MODELS, etc.
18+ --lfs use Git Large File Storage (requires `git-lfs`)
19+ --cvmfs use CernVM-FS (requires `/cvfms`)
20+ --xrootd use XRootD (requires `xrootd`)
2121 --nomaps do not download field maps
2222
2323 OPTIONS FOR TESTING
@@ -31,6 +31,10 @@ usage='''build-coatjava.sh [OPTIONS]... [MAVEN_OPTIONS]...
3131 -T4 will build with 4 parallel threads
3232' ' '
3333
34+ # ###############################################################################
35+ # parse arguments
36+ # ###############################################################################
37+
3438cleanBuild=" no"
3539anaDepends=" no"
3640runSpotBugs=" no"
@@ -85,6 +89,10 @@ if ! [[ $(hostname) == *.jlab.org ]]; then
8589 useLfs=true
8690fi
8791
92+ # ###############################################################################
93+ # setup
94+ # ###############################################################################
95+
8896src_dir=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd) "
8997prefix_dir=$src_dir /coatjava
9098clara_home=$src_dir /clara
@@ -97,26 +105,31 @@ wgetArgs+=(--timestamping --no-check-certificate) # `--timestamping` only redown
97105mvn=" mvn ${mvnArgs[@]:- } "
98106wget=" wget ${wgetArgs[@]:- } "
99107
108+ # ###############################################################################
109+ # download field maps, NN models, etc.
110+ # ###############################################################################
111+
100112command_exists () {
101113 type " $1 " & > /dev/null
102114}
103- download () {
115+
116+ download_lfs () {
117+ if command_exists git-lfs ; then
118+ cd $src_dir > /dev/null
119+ git lfs install
120+ git submodule update --init $1
121+ cd - > /dev/null
122+ else
123+ echo ' ERROR: `git-lfs` not found; please install it, or use a different option other than `--lfs`' >&2
124+ exit 1
125+ fi
126+ }
127+
128+ download_map () {
104129 ret=0
105130 if $useXrootd ; then
106131 xrdcp $1 ./
107132 ret=$?
108- elif $useLfs ; then
109- if command_exists git-lfs ; then
110- cd $src_dir > /dev/null
111- git lfs install
112- git submodule update --init etc/data/magfield
113- git submodule update --init etc/data/nnet
114- if $downloadData ; then git submodule update --init validation/advanced-tests/data; fi
115- cd - > /dev/null
116- else
117- echo ' ERROR: `git-lfs` not found; please install it, or use a different option other than `--lfs`' >&2
118- ret=1
119- fi
120133 elif $useCvmfs ; then
121134 cp -v $1 ./
122135 ret=$?
@@ -141,26 +154,46 @@ source libexec/env.sh --no-classpath
141154magfield_dir=$src_dir /etc/data/magfield
142155if [ $cleanBuild == " no" ] && [ $downloadMaps == " yes" ]; then
143156 echo ' Retrieving field maps ...'
144- webDir=https://clasweb.jlab.org/clas12offline/magfield
145- if $useLfs ; then webDir=${magfield_dir## $src_dir } ; fi
146- if $useXrootd ; then webDir=xroot://sci-xrootd.jlab.org//osgpool/hallb/clas12/coatjava/magfield; fi
147- if $useCvmfs ; then webDir=/cvmfs/oasis.opensciencegrid.org/jlab/hallb/clas12/sw/noarch/data/magfield; fi
148- mkdir -p $magfield_dir
149- cd $magfield_dir
150- for map in $COAT_MAGFIELD_SOLENOIDMAP $COAT_MAGFIELD_TORUSMAP $COAT_MAGFIELD_TORUSSECONDARYMAP
151- do
152- download $webDir /$map
153- if [ $? -ne 0 ]; then
154- echo " ERROR::::::::::: Could not download field map:" >&2
155- echo " $webDir /$map " >&2
156- echo " One option is to download manually into etc/data/magfield and then run this build script with --nomaps" >&2
157- exit 1
158- fi
159- $useLfs && break
160- done
161- cd -
157+ if $useLfs ; then
158+ download_lfs etc/data/magfield
159+ else
160+ webDir=https://clasweb.jlab.org/clas12offline/magfield
161+ if $useXrootd ; then webDir=xroot://sci-xrootd.jlab.org//osgpool/hallb/clas12/coatjava/magfield; fi
162+ if $useCvmfs ; then webDir=/cvmfs/oasis.opensciencegrid.org/jlab/hallb/clas12/sw/noarch/data/magfield; fi
163+ mkdir -p $magfield_dir
164+ cd $magfield_dir
165+ for map in $COAT_MAGFIELD_SOLENOIDMAP $COAT_MAGFIELD_TORUSMAP $COAT_MAGFIELD_TORUSSECONDARYMAP
166+ do
167+ download_map $webDir /$map
168+ if [ $? -ne 0 ]; then
169+ echo " ERROR::::::::::: Could not download field map:" >&2
170+ echo " $webDir /$map " >&2
171+ echo " One option is to download manually into etc/data/magfield and then run this build script with --nomaps" >&2
172+ exit 1
173+ fi
174+ done
175+ cd -
176+ fi
177+ fi
178+
179+ # download neural networks
180+ if $useLfs ; then
181+ download_lfs etc/data/nnet
182+ elif $useCvmfs ; then
183+ cp -rv /cvmfs/oasis.opensciencegrid.org/jlab/hallb/clas12/sw/noarch/data/networks/* etc/data/nnet/
184+ else
185+ echo " WARNING: neural networks not downloaded" >&2
162186fi
163187
188+ # download validation data
189+ if $downloadData ; then
190+ download_lfs validation/advanced-tests/data
191+ fi
192+
193+ # ###############################################################################
194+ # cleaning
195+ # ###############################################################################
196+
164197# always clean the installation prefix
165198rm -rf $prefix_dir $clara_home
166199
@@ -171,13 +204,20 @@ if [ $cleanBuild == "yes" ]; then
171204 echo " WARNING: target directory '$target_dir ' was not removed! JAR files within may be accidentally installed!" >&2
172205 done
173206 echo " " " DONE CLEANING.
174- NOTE: if you want to remove locally downloaded magnetic field maps, run:
175- rm $magfield_dir /*.dat
207+ NOTE:
208+ - to remove local magnetic field maps:
209+ rm $magfield_dir /*.dat
210+ - to clear all LFS git submodules:
211+ git submodule deinit --all
176212
177213 Now re-run without \` --clean\` to build." " "
178214 exit
179215fi
180216
217+ # ###############################################################################
218+ # build
219+ # ###############################################################################
220+
181221# run dependency analysis and exit
182222if [ $anaDepends == " yes" ]; then
183223 libexec/dependency-analysis.sh
@@ -215,7 +255,10 @@ if [ $runSpotBugs == "yes" ]; then
215255 if [ $? != 0 ] ; then echo " spotbugs failure" >&2 ; exit 1 ; fi
216256fi
217257
218- # installation
258+ # ###############################################################################
259+ # install
260+ # ###############################################################################
261+
219262# NOTE: a maven plugin, such as `maven-assembly-plugin`, would be better, but it seems that they:
220263# - require significantly more repetition of the module names and/or generation of additional XML file(s)
221264# - seem to break thread safety of `mvn install`, i.e., we'd need to run `mvn package` first, then `mvn install`
0 commit comments