Fetching contributors…
Cannot retrieve contributors at this time
executable file 142 lines (115 sloc) 3.54 KB
#!/bin/bash
# A script to do a complete build of all of Lift. Any additional command
# line arguments are passed directly to the underlying "liftsh" command
# calls.
SBT_DEFAULT="+clean-lib +update +clean +publish"
START_TIME=$(date +%s)
mod="build setup"
function AlertFail() {
echo =====================================================
echo Build failed in $mod! Duration = $(( $(date +%s) - $START_TIME )) seconds
echo =====================================================
}
# Automatically fail the script if any particular command fails
set -e
trap AlertFail ERR
# Locate our base directory (taken from http://blog.eitchnet.ch/?p=242)
SCRIPT_NAME="${0##*/}"
SCRIPT_DIR="${0%/*}"
# if the script was started from the base directory, then the
# expansion returns a period
if test "$SCRIPT_DIR" == "." ; then
SCRIPT_DIR="$PWD"
# if the script was not called with an absolute path, then we need to add the
# current working directory to the relative path of the script
elif test "${SCRIPT_DIR:0:1}" != "/" ; then
SCRIPT_DIR="$PWD/$SCRIPT_DIR"
fi
function Usage() {
cat <<HELPDONE
Usage: $0 [-d] [-p] [<additional SBT commands>]
-d : Perform a dry run (no build)
-p : Perform a git fetch + git rebase origin/master on each module
The normal SBT build command used is
./liftsh $SBT_DEFAULT
Additional SBT commands are prepended to the SBT build command, so
if you call this script as
buildall '+clean-cache'
the resulting command is
./liftsh '+clean-cache' $SBT_DEFAULT
HELPDONE
exit
}
# Argument processing
while getopts ":pdh" opt; do
case $opt in
p)
#echo "Executing Git pull on each module"
PULLGIT="true"
;;
d)
#echo "Dry run (no build)"
DRYRUN="true"
;;
h)
Usage
;;
\?)
echo "Invalid option: -$OPTARG"
Usage
;;
esac
done
function confirm()
{
echo -n "$@ "
read -e answer
for response in y Y yes YES Yes Sure sure SURE OK ok Ok
do
if [ "_$answer" == "_$response" ]
then
return 0
fi
done
# Any answer other than the list above is considerred a "no" answer
return 1
}
# Go ahead and confirm no pull if not set
if [ "x$PULLGIT" = "x" ]; then
if confirm "Would you like to do a fetch/rebase prior to building? (y/n)"; then
PULLGIT="true"
fi
fi
function DoBuild() {
if [ "x$PULLGIT" != "x" ]; then
echo "Executing Git pull/rebase on $mod"
git fetch
git rebase origin/master
fi
if [ "x$DRYRUN" != "x" ]; then
echo "Skipping build for $mod : " ./liftsh "$@" +clean-lib +update +clean +publish
else
./liftsh "$@" +clean-lib +update +clean +publish
fi
}
# First, we need to build and deploy the "superbuild" module, since it
# defines some dependencies and the sbt-lift-plugin. This is separate
# primarily because superbuild has a different directory structure than
# the other modules
echo "Building superbuild"
mod=superbuild
pushd ${SCRIPT_DIR}/../sbt > /dev/null
DoBuild
popd > /dev/null
# Next, for each of the three main modules clean/setup the SBT environment
# and then do a full build
for mod in framework modules examples
do
echo "Building $mod"
pushd ${SCRIPT_DIR}/../../${mod} > /dev/null
DoBuild
popd > /dev/null
done
echo =====================================================
echo Build succeeded! Duration = $(( $(date +%s) - $START_TIME )) seconds
echo =====================================================