2010-02-07 06:25:44 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
##########################################################
|
|
|
|
# Gridworks Control System #
|
|
|
|
##########################################################
|
|
|
|
|
2010-04-05 09:15:16 +02:00
|
|
|
# -------------- utility functions ----------------------
|
2010-03-30 23:24:04 +02:00
|
|
|
|
2010-02-09 21:21:10 +01:00
|
|
|
fail () {
|
|
|
|
cat <<EOF
|
2010-02-07 06:25:44 +01:00
|
|
|
ERROR: $1
|
2010-02-09 21:21:10 +01:00
|
|
|
Type '$0 -h' for usage information.
|
2010-02-07 06:25:44 +01:00
|
|
|
EOF
|
2010-02-09 21:21:10 +01:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
error() {
|
|
|
|
echo "$1"
|
2010-02-08 00:15:50 +01:00
|
|
|
exit 1
|
2010-02-07 06:25:44 +01:00
|
|
|
}
|
|
|
|
|
2010-04-07 10:28:53 +02:00
|
|
|
warn() {
|
|
|
|
echo "$1"
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2010-02-07 06:25:44 +01:00
|
|
|
usage() {
|
2010-02-08 00:15:50 +01:00
|
|
|
cat <<EOF
|
2010-02-07 06:25:44 +01:00
|
|
|
Usage: $0 [options] <action>
|
|
|
|
where [options] include:
|
|
|
|
|
|
|
|
-h print this message and exit
|
|
|
|
|
2010-02-07 06:32:07 +01:00
|
|
|
-p <port> the port that gridworks will listen to
|
2010-02-07 06:25:44 +01:00
|
|
|
default: 3333
|
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
-i <interface> the host interface gridworks should bind to
|
|
|
|
default: 127.0.0.1
|
|
|
|
|
|
|
|
-w <path> path to the webapp
|
|
|
|
default: src/main/webapp
|
2010-03-03 03:53:07 +01:00
|
|
|
|
|
|
|
-d <path> path to the data directory
|
|
|
|
default: OS dependent
|
2010-03-30 23:24:04 +02:00
|
|
|
|
|
|
|
-m <memory> max memory heap size to use
|
|
|
|
default: 1024M
|
2010-04-03 03:28:54 +02:00
|
|
|
|
2010-03-03 03:53:07 +01:00
|
|
|
--debug enable JVM debugging (on port 8000)
|
2010-02-08 00:15:50 +01:00
|
|
|
|
2010-03-30 23:24:04 +02:00
|
|
|
--jmx enable JMX monitoring (for jconsole and jvisualvm)
|
2010-02-07 06:25:44 +01:00
|
|
|
|
|
|
|
and <action> is one of
|
|
|
|
|
2010-02-09 21:21:10 +01:00
|
|
|
build ..................... Build Gridworks
|
2010-04-07 19:31:25 +02:00
|
|
|
run ....................... Run Gridworks [default]
|
2010-03-09 09:08:35 +01:00
|
|
|
|
2010-04-07 19:31:25 +02:00
|
|
|
test ...................... Run all Gridworks tests
|
|
|
|
server_test ............... Run only the server tests
|
|
|
|
ui_test ................... Run only the UI tests
|
|
|
|
|
2010-04-05 09:15:16 +02:00
|
|
|
findbugs .................. Run Findbugs against Gridworks
|
2010-04-07 19:31:25 +02:00
|
|
|
pmd ....................... Run PMD against Gridworks
|
|
|
|
cpd ....................... Run Copy/Paste Detection against Gridworks
|
2010-02-09 21:21:10 +01:00
|
|
|
|
2010-03-31 04:11:53 +02:00
|
|
|
mac_dist <version> ........ Make MacOSX binary distribution
|
|
|
|
windows_dist <version> .... Make Windows binary distribution
|
|
|
|
linux_dist <version> ...... Make Linux binary distribution
|
2010-03-30 23:24:04 +02:00
|
|
|
dist <version> ............ Make all distributions
|
2010-03-04 09:46:33 +01:00
|
|
|
|
2010-02-09 21:21:10 +01:00
|
|
|
clean ..................... Clean compiled classes
|
|
|
|
distclean ................. Remove all generated files
|
2010-02-08 00:15:50 +01:00
|
|
|
|
2010-02-07 06:25:44 +01:00
|
|
|
EOF
|
2010-02-09 21:21:10 +01:00
|
|
|
exit 1
|
2010-02-07 06:25:44 +01:00
|
|
|
}
|
2010-03-30 23:24:04 +02:00
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
add_option() {
|
2010-04-05 09:15:16 +02:00
|
|
|
OPTS="$OPTS $1"
|
2010-02-07 06:25:44 +01:00
|
|
|
}
|
2010-03-30 23:24:04 +02:00
|
|
|
|
|
|
|
load_configs() {
|
|
|
|
cat $1 | egrep "^[A-Z]" | sed 's/^\(.*\)$/export \1/' > .$1
|
|
|
|
. ./.$1
|
|
|
|
rm ./.$1
|
|
|
|
}
|
|
|
|
|
2010-02-09 21:21:10 +01:00
|
|
|
check_macosx() {
|
|
|
|
if [ "$SYSTEM" != 'Darwin' ] ; then
|
|
|
|
error "This action can only run on MacOSX"
|
|
|
|
fi
|
|
|
|
}
|
2010-04-05 09:15:16 +02:00
|
|
|
|
2010-04-07 10:28:53 +02:00
|
|
|
check_downloaders() {
|
|
|
|
CURL="`which curl`"
|
|
|
|
WGET="`which wget`"
|
|
|
|
|
|
|
|
if [ "$CURL" == "" ] && [ "$WGET" == "" ]; then
|
|
|
|
error "We need either 'curl' or 'wget' present in PATH to download external dependencies."
|
|
|
|
fi
|
|
|
|
}
|
2010-04-07 19:31:25 +02:00
|
|
|
|
|
|
|
check_unzip() {
|
|
|
|
UNZIP="`which unzip`"
|
|
|
|
|
|
|
|
if [ "$UNZIP" == "" ] ; then
|
|
|
|
error "We need 'unzip' present in PATH to expand external dependencies."
|
|
|
|
fi
|
|
|
|
}
|
2010-04-07 10:28:53 +02:00
|
|
|
|
|
|
|
check_python() {
|
|
|
|
PYTHON="`which python`"
|
|
|
|
if [ "$PYTHON" == "" ] ; then
|
|
|
|
error "This action requires you to have 'python' installed. You can download it for free at http://www.python.org/"
|
|
|
|
fi
|
|
|
|
PYTHON_VERSION="`python --version 2>&1 | cut -f 2 -d ' ' | cut -f 1,2 -d .`"
|
|
|
|
if [ "$PYTHON_VERSION" != "2.5" ] && [ "$PYTHON_VERSION" != "2.6" ] ; then
|
|
|
|
error "This action requires python version 2.5.x or 2.6.x. You can download it for free at http://www.python.org/"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
check_running() {
|
|
|
|
check_downloaders
|
|
|
|
URL="http://${GRIDWORKS_HOST}:${GRIDWORKS_PORT}/"
|
|
|
|
|
|
|
|
if [ "$CURL" != "" ] ; then
|
|
|
|
NOT_RUNNING=`curl -s $URL > /dev/null || echo not_running`
|
|
|
|
elif [ "$WGET" != "" ] ; then
|
|
|
|
NOT_RUNNING=`wget -q -O - $URL > /dev/null || echo not_running`
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2010-04-05 09:15:16 +02:00
|
|
|
get_version() {
|
|
|
|
VERSION=$1
|
2010-02-09 21:21:10 +01:00
|
|
|
|
2010-04-05 09:15:16 +02:00
|
|
|
if [ "$VERSION" == "" ] ; then
|
|
|
|
fail "Must specify a version number"
|
2010-02-08 00:15:50 +01:00
|
|
|
fi
|
|
|
|
|
2010-04-05 09:15:16 +02:00
|
|
|
NUM_VERSION=`echo $VERSION | sed 's/[a-zA-Z]//g'`
|
|
|
|
}
|
|
|
|
|
|
|
|
get_revision() {
|
|
|
|
if [ -d ".svn" ]; then
|
|
|
|
INFO=`svn info`
|
|
|
|
elif [ -d ".git" ]; then
|
|
|
|
INFO=`git svn info`
|
|
|
|
else
|
|
|
|
error "cannot obtain revision, exiting!"
|
2010-02-08 00:15:50 +01:00
|
|
|
fi
|
2010-04-05 09:15:16 +02:00
|
|
|
|
|
|
|
REVISION=`echo $INFO | sed 's/.*Revision: /r/' | sed 's/ .*//'`
|
2010-02-09 21:21:10 +01:00
|
|
|
}
|
2010-04-05 09:15:16 +02:00
|
|
|
|
|
|
|
download() {
|
|
|
|
URL=$1
|
|
|
|
DEST=$2
|
|
|
|
|
2010-04-07 10:28:53 +02:00
|
|
|
check_downloaders
|
2010-04-05 09:15:16 +02:00
|
|
|
|
2010-04-07 01:13:09 +02:00
|
|
|
if [ "$CURL" != "" ] ; then
|
2010-04-07 10:28:53 +02:00
|
|
|
curl -L -o $DEST $URL || exit "Error while downloading $URL"
|
2010-04-07 01:42:57 +02:00
|
|
|
elif [ "$WGET" != "" ] ; then
|
2010-04-07 10:28:53 +02:00
|
|
|
wget -O $DEST $URL || error "Error while downloading $URL"
|
2010-04-05 09:15:16 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2010-04-07 01:28:52 +02:00
|
|
|
tool_download() {
|
|
|
|
URL=$1
|
|
|
|
FILE=$2
|
|
|
|
DIR=$3
|
|
|
|
|
|
|
|
cd $GRIDWORKS_TOOLS_DIR
|
|
|
|
if [ ! -f "$FILE" ] ; then
|
|
|
|
download $URL $FILE
|
|
|
|
fi
|
|
|
|
if [ ! -d "$DIR" ] ; then
|
2010-04-07 20:51:16 +02:00
|
|
|
if [ "`echo $FILE | sed 's@.*.tar.gz$@@' | sed 's@.*.tgz$@@'`" == "" ] ; then
|
2010-04-07 19:31:25 +02:00
|
|
|
tar xzf $FILE || error "Error while expanding $FILE"
|
2010-04-07 19:40:55 +02:00
|
|
|
fi
|
|
|
|
if [ "`echo $FILE | sed 's@.*.zip$@@'`" == "" ] ; then
|
2010-04-07 19:31:25 +02:00
|
|
|
check_unzip
|
2010-04-07 19:40:55 +02:00
|
|
|
$UNZIP -q $FILE || error "Error while expanding $FILE"
|
2010-04-07 19:31:25 +02:00
|
|
|
fi
|
2010-04-07 01:28:52 +02:00
|
|
|
fi
|
|
|
|
cd ..
|
|
|
|
}
|
|
|
|
|
2010-04-07 10:28:53 +02:00
|
|
|
load_data() {
|
|
|
|
FILE=$1
|
|
|
|
NAME=$2
|
|
|
|
URL="http://${GRIDWORKS_HOST}:${GRIDWORKS_PORT}/command/create-project-from-upload"
|
|
|
|
CURL="`which curl`"
|
|
|
|
|
|
|
|
if [ "$CURL" == "" ] ; then
|
|
|
|
error "We need 'curl' present in PATH to upload data to gridworks."
|
|
|
|
else
|
|
|
|
curl -s -F "project-file=@$FILE" -F "project-name=$NAME" $URL > /dev/null || error "Error while uploading $FILE to Gridworks"
|
|
|
|
echo "Loaded $FILE as $NAME"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2010-04-05 09:15:16 +02:00
|
|
|
# ----------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
build_prepare() {
|
|
|
|
if [ ! -d $GRIDWORKS_BUILD_DIR ] ; then
|
2010-04-07 10:28:53 +02:00
|
|
|
mkdir $GRIDWORKS_BUILD_DIR || error "Error while making directory $GRIDWORKS_BUILD_DIR"
|
2010-04-05 09:15:16 +02:00
|
|
|
fi
|
2010-02-09 21:21:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
dist_prepare() {
|
|
|
|
if [ ! -d $GRIDWORKS_DIST_DIR ] ; then
|
2010-04-07 10:28:53 +02:00
|
|
|
mkdir $GRIDWORKS_DIST_DIR || error "Error while making directory $GRIDWORKS_DIST_DIR"
|
2010-02-09 21:21:10 +01:00
|
|
|
fi
|
|
|
|
}
|
2010-04-05 09:15:16 +02:00
|
|
|
|
|
|
|
tools_prepare() {
|
|
|
|
if [ ! -d $GRIDWORKS_TOOLS_DIR ] ; then
|
2010-04-07 10:28:53 +02:00
|
|
|
mkdir $GRIDWORKS_TOOLS_DIR || error "Error while making directory $GRIDWORKS_TOOLS_DIR"
|
2010-04-05 09:15:16 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
ant_prepare() {
|
|
|
|
ANT_URL="http://www.apache.org/dist/ant/binaries/apache-ant-1.8.0-bin.tar.gz"
|
|
|
|
ANT_FILE=`echo $ANT_URL | sed 's|.*/||'`
|
|
|
|
ANT_DIR="apache-ant-1.8.0"
|
|
|
|
|
|
|
|
ANT=`which ant`
|
|
|
|
if [ $ANT == "" ] ; then
|
|
|
|
if [ $ANT_HOME == "" ] ; then
|
|
|
|
cd $GRIDWORKS_TOOLS_DIR
|
|
|
|
if [ ! -f $ANT_FILE ] ; then
|
|
|
|
download $ANT_URL $ANT_FILE
|
|
|
|
fi
|
|
|
|
if [ ! -d $ANT_DIR ] ; then
|
2010-04-07 10:28:53 +02:00
|
|
|
tar xzf $ANT_FILE -C . || error "Error while expanding $ANT_FILE"
|
2010-04-05 09:15:16 +02:00
|
|
|
fi
|
|
|
|
export ANT_HOME="`pwd`/$ANT_DIR"
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
ANT="$ANT_HOME/bin/ant"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2010-02-10 08:30:16 +01:00
|
|
|
launch4j_prepare() {
|
2010-04-07 00:41:33 +02:00
|
|
|
tools_prepare
|
|
|
|
|
2010-04-05 09:15:16 +02:00
|
|
|
LAUNCH4J_URL="http://downloads.sourceforge.net/project/launch4j/launch4j-3/3.0.1/launch4j-3.0.1-macosx.tgz"
|
|
|
|
LAUNCH4J_FILE=`echo $LAUNCH4J_URL | sed 's|.*/||'`
|
2010-03-09 21:16:04 +01:00
|
|
|
LAUNCH4J_DIR="launch4j"
|
2010-04-05 09:15:16 +02:00
|
|
|
|
2010-04-07 01:28:52 +02:00
|
|
|
tool_download $LAUNCH4J_URL $LAUNCH4J_FILE $LAUNCH4J_DIR
|
2010-03-04 09:46:33 +01:00
|
|
|
}
|
2010-02-10 08:30:16 +01:00
|
|
|
|
2010-04-05 09:15:16 +02:00
|
|
|
jarbundler_prepare() {
|
2010-04-07 00:41:33 +02:00
|
|
|
tools_prepare
|
|
|
|
|
2010-04-05 09:15:16 +02:00
|
|
|
JARBUNDLER_URL="http://www.informagen.com/JarBundler/dist/jarbundler.tar.gz"
|
|
|
|
JARBUNDLER_FILE=`echo $JARBUNDLER_URL | sed 's|.*/||'`
|
|
|
|
JARBUNDLER_DIR="jarbundler-2.1.0"
|
|
|
|
|
2010-04-07 01:28:52 +02:00
|
|
|
tool_download $JARBUNDLER_URL $JARBUNDLER_FILE $JARBUNDLER_DIR
|
2010-02-25 00:52:20 +01:00
|
|
|
}
|
2010-04-05 09:15:16 +02:00
|
|
|
|
2010-04-07 01:28:52 +02:00
|
|
|
windmill_prepare() {
|
2010-04-07 10:28:53 +02:00
|
|
|
WINDMILL="`which windmill`"
|
|
|
|
if [ "$WINDMILL" == "" ] ; then
|
|
|
|
check_python
|
|
|
|
tools_prepare
|
|
|
|
|
|
|
|
WINDMILL_URL="http://github.com/windmill/windmill/tarball/1.3beta2"
|
|
|
|
WINDMILL_FILE="windmill-1.3beta2.tar.gz"
|
|
|
|
WINDMILL_DIR="windmill-1.3beta2"
|
|
|
|
|
|
|
|
tool_download $WINDMILL_URL $WINDMILL_FILE $WINDMILL_DIR
|
|
|
|
|
|
|
|
WINDMILL="$GRIDWORKS_TOOLS_DIR/windmill"
|
|
|
|
if [ ! -f $WINDMILL ] ; then
|
|
|
|
cd $GRIDWORKS_TOOLS_DIR
|
|
|
|
WINDMILL_SRC=`find . -type d -depth 1 | grep windmill`
|
|
|
|
cd $WINDMILL_SRC
|
|
|
|
echo "About to install Windmill with 'sudo', you might be asked to input your admin password"
|
|
|
|
WINDMILL=`sudo python setup.py develop | grep 'Installing windmill script to' | sed 's|.* /|/|'`/windmill
|
|
|
|
cd ..
|
|
|
|
ln -s $WINDMILL windmill
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
fi
|
2010-04-07 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
2010-04-05 09:15:16 +02:00
|
|
|
findbugs_prepare() {
|
2010-04-07 00:41:33 +02:00
|
|
|
tools_prepare
|
|
|
|
|
2010-04-05 09:15:16 +02:00
|
|
|
FINDBUGS_URL="http://downloads.sourceforge.net/project/findbugs/findbugs/1.3.9/findbugs-1.3.9.tar.gz"
|
|
|
|
FINDBUGS_FILE=`echo $FINDBUGS_URL | sed 's|.*/||'`
|
|
|
|
FINDBUGS_DIR="findbugs-1.3.9"
|
|
|
|
|
2010-04-07 02:12:40 +02:00
|
|
|
tool_download $FINDBUGS_URL $FINDBUGS_FILE $FINDBUGS_DIR
|
2010-04-05 09:15:16 +02:00
|
|
|
}
|
2010-04-07 19:31:25 +02:00
|
|
|
|
|
|
|
pmd_prepare() {
|
|
|
|
tools_prepare
|
|
|
|
|
|
|
|
PMD_URL="http://downloads.sourceforge.net/project/pmd/pmd/4.2.5/pmd-bin-4.2.5.zip"
|
|
|
|
PMD_FILE="pmd-bin-4.2.5.zip"
|
|
|
|
PMD_DIR="pmd-4.2.5"
|
|
|
|
|
|
|
|
tool_download $PMD_URL $PMD_FILE $PMD_DIR
|
|
|
|
}
|
|
|
|
|
2010-04-05 09:15:16 +02:00
|
|
|
# ----------------------------------------------------------------------------------------------
|
2010-03-30 23:24:04 +02:00
|
|
|
|
2010-04-05 09:15:16 +02:00
|
|
|
ant() {
|
|
|
|
ant_prepare
|
2010-04-07 00:41:33 +02:00
|
|
|
|
2010-04-05 09:15:16 +02:00
|
|
|
#export ANT_OPTS="-Xmx1024M"
|
2010-04-07 00:41:33 +02:00
|
|
|
|
2010-04-07 10:28:53 +02:00
|
|
|
$ANT -f build.xml $ANT_PARAMS -Dbuild.dir="$GRIDWORKS_BUILD_DIR" -Ddist.dir="$GRIDWORKS_DIST_DIR" -Dversion="$VERSION" -Dnum_version="$NUM_VERSION" -Drevision="$REVISION" $1 || error "Error while running ant task '$1'"
|
2010-03-30 23:24:04 +02:00
|
|
|
}
|
|
|
|
|
2010-04-05 09:15:16 +02:00
|
|
|
# ----------------------------------------------------------------------------------------------
|
|
|
|
|
2010-03-30 23:24:04 +02:00
|
|
|
dist() {
|
2010-03-31 04:11:53 +02:00
|
|
|
mac_dist $1
|
|
|
|
windows_dist $1
|
|
|
|
linux_dist $1
|
2010-03-31 02:17:40 +02:00
|
|
|
|
2010-03-31 04:11:53 +02:00
|
|
|
echo "All distributions were built and are located at $GRIDWORKS_DIST_DIR"
|
2010-03-31 02:17:40 +02:00
|
|
|
echo
|
2010-03-31 04:11:53 +02:00
|
|
|
echo "Upload them to the distibution site, then prepend the GridworksReleases array at"
|
2010-03-31 02:17:40 +02:00
|
|
|
echo
|
|
|
|
echo " http://acre.freebase.com/#app=/user/dfhuynh/labs-site&file=gridworks.js"
|
|
|
|
echo
|
|
|
|
echo "with"
|
|
|
|
echo
|
|
|
|
echo " {"
|
2010-03-31 03:07:52 +02:00
|
|
|
echo " description: \"Gridworks ${VERSION}\","
|
2010-03-31 02:17:40 +02:00
|
|
|
echo " version: \"${VERSION}\","
|
|
|
|
echo " revision: \"${REVISION}\""
|
|
|
|
echo " },"
|
|
|
|
echo
|
2010-03-17 23:30:16 +01:00
|
|
|
}
|
|
|
|
|
2010-03-31 04:11:53 +02:00
|
|
|
windows_dist() {
|
2010-02-25 00:52:20 +01:00
|
|
|
check_macosx
|
|
|
|
dist_prepare
|
|
|
|
get_version $1
|
2010-03-30 23:24:04 +02:00
|
|
|
get_revision
|
2010-04-07 20:51:16 +02:00
|
|
|
|
|
|
|
launch4j_prepare
|
2010-02-25 00:52:20 +01:00
|
|
|
|
2010-04-05 09:15:16 +02:00
|
|
|
ANT_PARAMS="-Dlaunch4j.dir=${GRIDWORKS_TOOLS_DIR}/${LAUNCH4J_DIR}"
|
2010-03-31 04:11:53 +02:00
|
|
|
ant windows
|
2010-02-10 08:30:16 +01:00
|
|
|
}
|
2010-03-17 23:30:16 +01:00
|
|
|
|
2010-03-31 04:11:53 +02:00
|
|
|
linux_dist() {
|
2010-03-17 23:30:16 +01:00
|
|
|
dist_prepare
|
|
|
|
get_version $1
|
2010-03-30 23:24:04 +02:00
|
|
|
get_revision
|
2010-03-17 23:30:16 +01:00
|
|
|
|
2010-03-31 04:11:53 +02:00
|
|
|
ant linux
|
2010-03-17 23:30:16 +01:00
|
|
|
}
|
2010-02-10 08:30:16 +01:00
|
|
|
|
2010-03-31 04:11:53 +02:00
|
|
|
mac_dist() {
|
2010-02-09 21:21:10 +01:00
|
|
|
check_macosx
|
|
|
|
dist_prepare
|
2010-02-25 00:52:20 +01:00
|
|
|
get_version $1
|
2010-03-30 23:24:04 +02:00
|
|
|
get_revision
|
2010-04-07 20:51:16 +02:00
|
|
|
|
|
|
|
jarbundler_prepare
|
2010-02-09 21:21:10 +01:00
|
|
|
|
2010-04-05 09:15:16 +02:00
|
|
|
ANT_PARAMS="-Djarbundler.dir=${GRIDWORKS_TOOLS_DIR}/${JARBUNDLER_DIR}"
|
2010-04-07 10:28:53 +02:00
|
|
|
ant mac
|
2010-02-09 21:21:10 +01:00
|
|
|
|
2010-03-31 04:11:53 +02:00
|
|
|
mkdir -p "$GRIDWORKS_BUILD_DIR/mac/.background"
|
|
|
|
cp src/graphics/dmg_background/dmg_background.png "$GRIDWORKS_BUILD_DIR/mac/.background/dmg_background.png"
|
2010-02-09 21:21:10 +01:00
|
|
|
|
|
|
|
SIZE=30
|
|
|
|
|
2010-04-07 02:12:40 +02:00
|
|
|
if [ -f "$GRIDWORKS_BUILD_DIR/temp_gridworks.dmg" ] ; then
|
|
|
|
rm "$GRIDWORKS_BUILD_DIR/temp_gridworks.dmg"
|
|
|
|
fi
|
|
|
|
|
2010-02-09 21:21:10 +01:00
|
|
|
TITLE="Gridworks $VERSION"
|
|
|
|
echo "Building MacOSX DMG for $TITLE"
|
2010-04-07 02:12:40 +02:00
|
|
|
hdiutil create -srcfolder "$GRIDWORKS_BUILD_DIR/mac" -volname "$TITLE" -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW -size ${SIZE}m "$GRIDWORKS_BUILD_DIR/temp_gridworks.dmg" || error "can't create empty DMG"
|
|
|
|
DEVICE=`hdiutil attach -readwrite -noverify -noautoopen "$GRIDWORKS_BUILD_DIR/temp_gridworks.dmg" | egrep '^/dev/' | sed 1q | awk '{print $1}'`
|
2010-04-07 10:28:53 +02:00
|
|
|
hdiutil attach "$GRIDWORKS_BUILD_DIR/temp_gridworks.dmg" || error "Can't attach temp DMG"
|
2010-02-08 00:15:50 +01:00
|
|
|
|
2010-02-09 21:21:10 +01:00
|
|
|
echo '
|
|
|
|
tell application "Finder"
|
|
|
|
tell disk "'$TITLE'"
|
|
|
|
open
|
|
|
|
set current view of container window to icon view
|
|
|
|
set toolbar visible of container window to false
|
|
|
|
set statusbar visible of container window to false
|
2010-02-25 00:28:24 +01:00
|
|
|
set the bounds of container window to {200, 100, 760, 460}
|
2010-02-09 21:21:10 +01:00
|
|
|
set theViewOptions to the icon view options of container window
|
|
|
|
set arrangement of theViewOptions to not arranged
|
|
|
|
set icon size of theViewOptions to 100
|
|
|
|
set background picture of theViewOptions to file ".background:'dmg_background.png'"
|
|
|
|
make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
|
2010-02-25 00:28:24 +01:00
|
|
|
set position of item "'Gridworks'" of container window to {170, 175}
|
|
|
|
set position of item "Applications" of container window to {380, 175}
|
2010-02-09 21:21:10 +01:00
|
|
|
close
|
|
|
|
open
|
|
|
|
update without registering applications
|
2010-04-07 02:12:40 +02:00
|
|
|
delay 2
|
2010-02-09 21:21:10 +01:00
|
|
|
eject
|
|
|
|
end tell
|
|
|
|
end tell
|
2010-04-07 10:28:53 +02:00
|
|
|
' | osascript || error "Error running applescript"
|
2010-02-09 21:21:10 +01:00
|
|
|
|
|
|
|
sync
|
|
|
|
sync
|
2010-04-07 20:40:50 +02:00
|
|
|
hdiutil detach $DEVICE
|
2010-04-07 02:18:26 +02:00
|
|
|
|
|
|
|
if [ -f "$GRIDWORKS_DIST_DIR/gridworks-$VERSION-$REVISION.dmg" ] ; then
|
|
|
|
rm "$GRIDWORKS_DIST_DIR/gridworks-$VERSION-$REVISION.dmg"
|
|
|
|
fi
|
|
|
|
|
2010-04-07 02:12:40 +02:00
|
|
|
hdiutil convert "$GRIDWORKS_BUILD_DIR/temp_gridworks.dmg" -format UDZO -imagekey zlib-level=9 -o "$GRIDWORKS_DIST_DIR/gridworks-$VERSION-$REVISION.dmg" || error "Error compressing DMG"
|
|
|
|
hdiutil internet-enable -yes "$GRIDWORKS_DIST_DIR/gridworks-$VERSION-$REVISION.dmg" || error "Error internet-enabling DMG"
|
2010-04-07 02:18:26 +02:00
|
|
|
|
2010-02-09 21:21:10 +01:00
|
|
|
rm -f "$GRIDWORKS_BUILD_DIR/temp_gridworks.dmg"
|
2010-02-07 06:25:44 +01:00
|
|
|
}
|
|
|
|
|
2010-03-09 09:08:35 +01:00
|
|
|
test() {
|
2010-04-07 02:12:40 +02:00
|
|
|
server_test $1
|
2010-04-07 10:28:53 +02:00
|
|
|
ui_test $1
|
2010-04-07 02:12:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ui_test() {
|
|
|
|
windmill_prepare
|
2010-04-07 10:28:53 +02:00
|
|
|
|
|
|
|
GRIDWORKS_DATA_DIR="${GRIDWORKS_TEST_DIR}/temp"
|
|
|
|
|
|
|
|
add_option "-Dgridworks.headless=true"
|
|
|
|
|
|
|
|
run fork
|
|
|
|
|
|
|
|
echo "Waiting for Gridworks to load..."
|
|
|
|
sleep 5
|
|
|
|
echo "... proceed with the tests."
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
load_data "$GRIDWORKS_TEST_DIR/data/food.csv" "Food"
|
|
|
|
sleep 3
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
echo "Starting Windmill..."
|
|
|
|
$WINDMILL firefox http://${GRIDWORKS_HOST}:${GRIDWORKS_PORT}/ test=$GRIDWORKS_TEST_DIR/windmill exit > /dev/null
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "Killing Gridworks"
|
|
|
|
kill -9 $GRIDWORKS_PID
|
|
|
|
echo "Cleaning up"
|
|
|
|
rm -rf $GRIDWORKS_DATA_DIR
|
2010-04-07 02:12:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
server_test() {
|
2010-04-07 03:17:14 +02:00
|
|
|
if [ ! -d $GRIDWORKS_TEST_DIR/java/classes ] ; then
|
2010-03-09 09:08:35 +01:00
|
|
|
ant build_tests
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
|
2010-04-07 03:17:14 +02:00
|
|
|
CLASSPATH="$GRIDWORKS_BUILD_DIR/classes:$GRIDWORKS_WEBAPP/WEB-INF/classes:$GRIDWORKS_TEST_DIR/java/classes:$GRIDWORKS_TEST_DIR/java/lib/*:$GRIDWORKS_LIB_DIR/*:$GRIDWORKS_WEBAPP/WEB-INF/lib/*"
|
2010-03-09 09:08:35 +01:00
|
|
|
|
|
|
|
if [ "$1" == "" ] ; then
|
2010-04-07 03:17:14 +02:00
|
|
|
cd $GRIDWORKS_TEST_DIR/java/classes
|
2010-03-09 09:08:35 +01:00
|
|
|
TESTS=`find . -name '*.class' | sed s@/@.@g | sed s@.class@@ | sed s@..@@`
|
2010-04-07 03:17:14 +02:00
|
|
|
cd ../../..
|
2010-03-09 09:08:35 +01:00
|
|
|
else
|
|
|
|
TESTS=$1
|
|
|
|
fi
|
|
|
|
|
|
|
|
RUN_CMD="$JAVA -cp $CLASSPATH $OPTS org.junit.runner.JUnitCore $TESTS"
|
|
|
|
|
2010-04-07 10:28:53 +02:00
|
|
|
#echo "$RUN_CMD"
|
|
|
|
#echo ""
|
2010-03-09 09:08:35 +01:00
|
|
|
|
2010-04-07 10:28:53 +02:00
|
|
|
$RUN_CMD || error "Failed passing server tests"
|
2010-03-09 09:08:35 +01:00
|
|
|
}
|
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
run() {
|
2010-04-07 10:28:53 +02:00
|
|
|
FORK=$1
|
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
if [ ! -d $GRIDWORKS_BUILD_DIR/classes ] ; then
|
2010-03-31 03:07:52 +02:00
|
|
|
is_jar=`ls $GRIDWORKS_LIB_DIR | grep gridworks`
|
|
|
|
if [ "$is_jar" == "" ] ; then
|
2010-03-30 23:24:04 +02:00
|
|
|
ant build
|
|
|
|
echo ""
|
|
|
|
fi
|
2010-02-08 00:15:50 +01:00
|
|
|
fi
|
2010-04-03 03:28:54 +02:00
|
|
|
|
2010-04-07 10:28:53 +02:00
|
|
|
check_running
|
|
|
|
|
|
|
|
if [ "$NOT_RUNNING" == "" ] ; then
|
|
|
|
warn "Gridworks is already running."
|
|
|
|
fi
|
|
|
|
|
2010-04-03 03:28:54 +02:00
|
|
|
if [ -d $GRIDWORKS_BUILD_DIR/classes ] ; then
|
|
|
|
add_option "-Dgridworks.autoreloading=true"
|
|
|
|
fi
|
2010-03-03 03:53:07 +01:00
|
|
|
|
|
|
|
if [ "$SYSTEM" == 'Darwin' ] ; then
|
2010-04-03 03:28:54 +02:00
|
|
|
add_option "-Xdock:name=Gridworks -Xdock:icon=src/graphics/icon/gridworks.icns"
|
2010-03-03 03:53:07 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$GRIDWORKS_DATA_DIR" != "" ] ; then
|
2010-04-03 03:28:54 +02:00
|
|
|
add_option "-Dgridworks.data_dir=$GRIDWORKS_DATA_DIR"
|
2010-03-03 03:53:07 +01:00
|
|
|
fi
|
2010-04-05 09:15:16 +02:00
|
|
|
|
2010-02-08 20:48:28 +01:00
|
|
|
CLASSPATH="$GRIDWORKS_BUILD_DIR/classes:$GRIDWORKS_LIB_DIR/*"
|
2010-02-08 00:15:50 +01:00
|
|
|
|
2010-03-03 03:53:07 +01:00
|
|
|
RUN_CMD="$JAVA -cp $CLASSPATH $OPTS com.metaweb.gridworks.Gridworks"
|
2010-04-07 10:28:53 +02:00
|
|
|
|
|
|
|
#echo "$RUN_CMD"
|
|
|
|
#echo ""
|
2010-02-08 00:15:50 +01:00
|
|
|
|
|
|
|
echo "Starting Gridworks at 'http://${GRIDWORKS_HOST}:${GRIDWORKS_PORT}/'"
|
|
|
|
echo ""
|
|
|
|
|
2010-04-07 10:28:53 +02:00
|
|
|
if [ "$FORK" == "" ] ; then
|
2010-04-07 19:31:25 +02:00
|
|
|
exec $RUN_CMD
|
2010-04-07 10:28:53 +02:00
|
|
|
else
|
|
|
|
sh -c "$RUN_CMD" &
|
|
|
|
GRIDWORKS_PID="$!"
|
|
|
|
fi
|
2010-02-08 00:15:50 +01:00
|
|
|
}
|
2010-03-12 08:37:37 +01:00
|
|
|
|
|
|
|
execute() {
|
|
|
|
if [ ! -d $GRIDWORKS_BUILD_DIR/classes ] ; then
|
|
|
|
ant build
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
|
|
|
|
CLASSPATH="$GRIDWORKS_BUILD_DIR/classes:$GRIDWORKS_LIB_DIR/*"
|
|
|
|
|
|
|
|
RUN_CMD="$JAVA -cp $CLASSPATH $OPTS $*"
|
|
|
|
|
2010-04-07 10:28:53 +02:00
|
|
|
#echo "$RUN_CMD"
|
|
|
|
#echo ""
|
2010-03-12 08:37:37 +01:00
|
|
|
|
|
|
|
exec $RUN_CMD $*
|
|
|
|
}
|
2010-02-08 00:15:50 +01:00
|
|
|
|
2010-04-05 09:15:16 +02:00
|
|
|
findbugs() {
|
|
|
|
findbugs_prepare
|
|
|
|
|
|
|
|
ANT_PARAMS="-Dfindbugs.dir=${GRIDWORKS_TOOLS_DIR}/${FINDBUGS_DIR}"
|
|
|
|
ant findbugs
|
|
|
|
}
|
|
|
|
|
2010-04-07 19:31:25 +02:00
|
|
|
pmd() {
|
|
|
|
pmd_prepare
|
|
|
|
|
|
|
|
ANT_PARAMS="-Dpmd.dir=${GRIDWORKS_TOOLS_DIR}/${PMD_DIR}"
|
|
|
|
ant pmd
|
|
|
|
}
|
|
|
|
|
|
|
|
cpd() {
|
|
|
|
pmd_prepare
|
|
|
|
|
|
|
|
ANT_PARAMS="-Dpmd.dir=${GRIDWORKS_TOOLS_DIR}/${PMD_DIR}"
|
|
|
|
ant cpd
|
|
|
|
}
|
|
|
|
|
2010-03-30 23:24:04 +02:00
|
|
|
# -------------------------- script -----------------------------
|
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
# ----- Normalize the current directory -------------------------
|
|
|
|
|
|
|
|
cd `dirname $0`
|
|
|
|
|
2010-03-30 23:24:04 +02:00
|
|
|
# ----- Default values ------------------------------------------
|
|
|
|
|
|
|
|
OPTS=""
|
|
|
|
|
|
|
|
SYSTEM=`uname`
|
|
|
|
|
|
|
|
if [ "$SYSTEM" == "Darwin" ] && [ "$JAVA_HOME" == "" ] ; then
|
|
|
|
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# ----- Load configurations -------------------------------------
|
|
|
|
|
|
|
|
load_configs gridworks.ini
|
|
|
|
|
|
|
|
# ----- Make sure there is an appropriate java environment is available -------------
|
2010-02-08 00:15:50 +01:00
|
|
|
|
|
|
|
if [ ! -z "$JAVA_HOME" ] ; then
|
|
|
|
JAVA="$JAVA_HOME/bin/java"
|
|
|
|
else
|
|
|
|
JAVA=`which java`
|
|
|
|
if [ -z "$JAVA" ] ; then
|
2010-04-05 09:15:16 +02:00
|
|
|
if [ "$SYSTEM" == 'Darwin' ] ; then
|
2010-02-08 00:15:50 +01:00
|
|
|
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
|
|
|
|
else
|
2010-02-09 21:21:10 +01:00
|
|
|
error "The 'java' command should be in your path or the 'JAVA_HOME' environment variable should be set"
|
2010-02-08 00:15:50 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2010-02-08 20:48:28 +01:00
|
|
|
JAVA_VERSION=`java -version 2>&1 | grep version | cut -d ' ' -f 3 | egrep ^\"1.6`
|
|
|
|
if [ -z "$JAVA_VERSION" ] ; then
|
2010-02-09 21:21:10 +01:00
|
|
|
error "Gridworks requires java version 6 or later."
|
2010-02-08 20:48:28 +01:00
|
|
|
fi
|
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
# ----- Parse the command line args ------------------------------------------
|
2010-02-07 06:25:44 +01:00
|
|
|
|
|
|
|
while [ $# -ne 0 ] ; do
|
2010-02-08 00:15:50 +01:00
|
|
|
case "$1" in
|
2010-03-17 02:51:29 +01:00
|
|
|
-h) usage;;
|
2010-02-08 00:15:50 +01:00
|
|
|
-p) shift; GRIDWORKS_PORT="$1"; shift; continue;;
|
|
|
|
-i) shift; GRIDWORKS_HOST="$1"; shift; continue;;
|
|
|
|
-w) shift; GRIDWORKS_WEBAPP="$1"; shift; continue;;
|
2010-03-03 03:53:07 +01:00
|
|
|
-d) shift; GRIDWORKS_DATA_DIR="$1"; shift; continue;;
|
2010-03-30 23:24:04 +02:00
|
|
|
-m) shift; GRIDWORKS_MEMORY="$1"; shift; continue;;
|
2010-03-03 03:53:07 +01:00
|
|
|
--debug) shift; add_option '-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n'; continue;;
|
|
|
|
--jmx) shift; add_option '-Dcom.sun.management.jmxremote'; continue;;
|
2010-02-08 00:15:50 +01:00
|
|
|
-*) fail "Invalid option: $1";;
|
|
|
|
*) break;;
|
2010-02-07 06:25:44 +01:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
ACTION=$1; shift
|
|
|
|
|
2010-03-31 04:11:53 +02:00
|
|
|
if [ "$ACTION" == "" ]; then
|
|
|
|
ACTION="run"
|
|
|
|
fi
|
|
|
|
|
2010-02-07 06:25:44 +01:00
|
|
|
# ----- Verify and Set Required Environment Variables -------------------------
|
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
if [ "$JAVA_OPTIONS" == "" ] ; then
|
2010-03-30 23:24:04 +02:00
|
|
|
JAVA_OPTIONS=""
|
2010-02-07 06:25:44 +01:00
|
|
|
fi
|
|
|
|
add_option "$JAVA_OPTIONS"
|
|
|
|
|
2010-03-30 23:24:04 +02:00
|
|
|
if [ "$GRIDWORKS_MEMORY" == "" ] ; then
|
2010-04-05 23:09:34 +02:00
|
|
|
GRIDWORKS_MEMORY="1024M"
|
2010-03-30 23:24:04 +02:00
|
|
|
fi
|
|
|
|
add_option "-Xms256M -Xmx$GRIDWORKS_MEMORY"
|
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
if [ "$GRIDWORKS_PORT" == "" ] ; then
|
2010-02-07 06:25:44 +01:00
|
|
|
GRIDWORKS_PORT="3333"
|
|
|
|
fi
|
2010-02-08 00:15:50 +01:00
|
|
|
add_option "-Dgridworks.port=$GRIDWORKS_PORT"
|
2010-02-07 06:25:44 +01:00
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
if [ "$GRIDWORKS_HOST" == "" ] ; then
|
|
|
|
GRIDWORKS_HOST="127.0.0.1"
|
|
|
|
fi
|
|
|
|
add_option "-Dgridworks.host=$GRIDWORKS_HOST"
|
2010-02-07 06:25:44 +01:00
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
if [ "$GRIDWORKS_WEBAPP" == "" ] ; then
|
|
|
|
GRIDWORKS_WEBAPP="src/main/webapp"
|
2010-02-07 06:25:44 +01:00
|
|
|
fi
|
2010-02-08 00:15:50 +01:00
|
|
|
add_option "-Dgridworks.webapp=$GRIDWORKS_WEBAPP"
|
|
|
|
|
2010-03-09 09:08:35 +01:00
|
|
|
if [ "$GRIDWORKS_TEST_DIR" == "" ] ; then
|
|
|
|
GRIDWORKS_TEST_DIR="tests"
|
|
|
|
fi
|
|
|
|
|
2010-02-08 00:15:50 +01:00
|
|
|
if [ "$GRIDWORKS_BUILD_DIR" == "" ] ; then
|
|
|
|
GRIDWORKS_BUILD_DIR="build"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$GRIDWORKS_LIB_DIR" == "" ] ; then
|
|
|
|
GRIDWORKS_LIB_DIR="lib"
|
|
|
|
fi
|
|
|
|
|
2010-04-05 09:15:16 +02:00
|
|
|
if [ "$GRIDWORKS_TOOLS_DIR" == "" ] ; then
|
|
|
|
GRIDWORKS_TOOLS_DIR="tools"
|
|
|
|
fi
|
|
|
|
|
2010-02-09 21:21:10 +01:00
|
|
|
if [ "$GRIDWORKS_DIST_DIR" == "" ] ; then
|
|
|
|
GRIDWORKS_DIST_DIR="dist"
|
|
|
|
fi
|
2010-02-08 00:15:50 +01:00
|
|
|
|
|
|
|
# ----- Respond to the action given --------------------------------------------
|
2010-02-07 06:25:44 +01:00
|
|
|
|
|
|
|
case "$ACTION" in
|
2010-04-05 09:15:16 +02:00
|
|
|
build) build_prepare; ant build;;
|
|
|
|
clean) ant clean;;
|
|
|
|
distclean) ant distclean;;
|
|
|
|
test) test $1;;
|
2010-04-07 02:12:40 +02:00
|
|
|
ui_test) ui_test $1;;
|
|
|
|
server_test) server_test $1;;
|
2010-04-05 09:15:16 +02:00
|
|
|
findbugs) findbugs;;
|
2010-04-07 19:31:25 +02:00
|
|
|
pmd) pmd;;
|
|
|
|
cpd) cpd;;
|
2010-04-05 09:15:16 +02:00
|
|
|
run) run;;
|
|
|
|
execute) execute $*;;
|
|
|
|
mac_dist) mac_dist $1;;
|
|
|
|
windows_dist) windows_dist $1;;
|
|
|
|
linux_dist) linux_dist $1;;
|
|
|
|
dist) dist $1;;
|
|
|
|
*) usage; ;;
|
2010-02-07 06:25:44 +01:00
|
|
|
esac
|