Skip to content

Commit

Permalink
finalizing working linux install for maven to local ./build/apache-ma…
Browse files Browse the repository at this point in the history
…ven folder
  • Loading branch information
Brennon York committed Dec 9, 2014
1 parent cbfcc68 commit 4a1609c
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 11 deletions.
47 changes: 38 additions & 9 deletions build/mvn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

# Determine the current working directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Called before any binaries are installed for any unknown operating system.
# Current checks are as follows:
Expand Down Expand Up @@ -50,16 +50,21 @@ prep_install_for_osx() {
# forced installation,
## Arg1 - application name
check_and_install_app() {
# create the local environment variable in uppercase
APP_BIN="`echo $1 | awk '{print toupper(\$0)}'`_BIN"
# some black magic to set the generated app variable (i.e. MVN_BIN) into the
# environment
eval "${APP_BIN}=`which $1 2>/dev/null`"
if [ -z "`which $1 2>/dev/null`" ]; then
# attempt to force install if flagged
if [ -n "${FORCE_INSTALL}" ]; then
local resource="${DIR}/packages/$1.sh"
local resource="${_DIR}/packages/$1.sh"
if [ -f "$resource" ]; then
source "${DIR}/packages/$1.sh"
source "${_DIR}/packages/$1.sh"
prep_install_for_${_OSTYPE}
install_$1_for_${_OSTYPE}
else
echo "ERROR: Cannot find the $1.sh build file from within ${DIR}/packages."
echo "ERROR: Cannot find the $1.sh build file from within ${_DIR}/packages."
echo " Ensure the file exists and is accesible."
exit 1
fi
Expand All @@ -71,6 +76,23 @@ check_and_install_app() {
fi
}

# Prints the help and usage for this script
print_help() {
echo "Spark Build Suite for Maven" && echo
echo "Usage: ./build/mvn <options> -- <mvn-parameters>" && echo
echo " Options:"
echo -e " -p=<port>\t\tSets the port for a local Zinc instance"
echo -e " -f\t\t\tForces install of necessary packages"
echo -e " -h\t\t\tPrints this help message" && echo
echo " Maven Parameters:"
echo " All parameters after the double-dash (--) will be pushed to the Maven"
echo " call. If none are provided the default of 'clean package -DskipTests'"
echo " will be executed." && echo
echo " Examples:"
echo " ./build/mvn -f -- clean package"
echo " ./build/mvn -p=3031 -- clean"
}

# Set a cleaned OS type string based on the $OSTYPE bash variable
case "$OSTYPE" in
solaris*)
Expand Down Expand Up @@ -102,6 +124,10 @@ while [ ! "$OPT" = "--" -a ! $# -eq 0 ]; do
ZINC_PORT=${OPT/-p=/}
shift
;;
-h)
print_help
exit 0
;;
*)
echo "Unknown option: $OPT"
shift
Expand All @@ -119,16 +145,19 @@ check_and_install_app "mvn"
check_and_install_app "zinc"
check_and_install_app "scala"

# Now that zinc is ensured to be installed, check its status and, if not
# running, start it
# Reset the current working directory
cd "${_DIR}/.."

# Now that zinc is ensured to be installed, check its status and, if its
# not running, start it
if [ -z "`zinc -status`" ]; then
zinc -start -port ${ZINC_PORT}
${ZINC_BIN} -start -port ${ZINC_PORT}
fi

# Determine the parameters pushed in from the command line and, if any are
# present, use those within the maven
if [ $# -gt 0 ]; then
mvn "$@"
${MVN_BIN} "$@"
else
mvn clean package -DskipTests
${MVN_BIN} clean package -DskipTests
fi
20 changes: 19 additions & 1 deletion build/packages/mvn.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
#!/usr/bin/env bash

# Determine the current working directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

MVN_URL="http://apache.claz.org/maven/maven-3/3.2.3/binaries/apache-maven-3.2.3-bin.tar.gz"
MVN_LOC="${DIR}/../apache-maven-3.2.3-bin.tar.gz"

install_mvn_for_linux() {
echo
local mvn_bin="${DIR}/../apache-maven-3.2.3/bin/mvn"

if [ ! -f "${mvn_bin}" ]; then
# first check if we have curl installed and, if so, download Leiningen
[ -n "`which curl 2>/dev/null`" ] && curl "${MVN_URL}" > "${MVN_LOC}"
# if the `lein` file still doesn't exist, lets try `wget` and cross our fingers
[ ! -f "${MVN_LOC}" ] && [ -n "`which wget 2>/dev/null`" ] && wget -O "${MVN_LOC}" "${MVN_URL}"
# if both weren't successful, exit
[ ! -f "${MVN_LOC}" ] && \
echo "ERROR: Cannot find or download a version of Maven, please install manually and try again." && \
exit 2
cd "${DIR}/.." && tar -xzf "${MVN_LOC}"
fi
export MVN_BIN="${mvn_bin}"
}

install_mvn_for_osx() {
brew install maven
export MVN_BIN=`which mvn`
}

14 changes: 13 additions & 1 deletion build/packages/scala.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
#!/usr/bin/env bash

# Determine the current working directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

SCALA_URL="http://downloads.typesafe.com/scala/2.11.4/scala-2.11.4.tgz"
SCALA_LOC="${DIR}/../scala/scala-2.11.4.tgz"

install_scala_for_linux() {
echo
# first check if we have curl installed and, if so, download Leiningen
[ -n "`which curl 2>/dev/null`" ] && curl "${SCALA_URL}" > "${SCALA_LOC}"
# if the `lein` file still doesn't exist, lets try `wget` and cross our fingers
[ ! -f "${SCALA_LOC}" ] && [ -n "`which wget 2>/dev/null`" ] && wget -O "${SCALA_LOC}" "${SCALA_URL}"
# if both weren't successful, exit
[ ! -f "${SCALA_LOC}" ] && \
echo "ERROR: Cannot find or download a version of Scala, please install manually and try again." && \
exit 2
}

install_scala_for_osx() {
brew install scala
export SCALA_BIN=`which scala`
}
1 change: 1 addition & 0 deletions build/packages/zinc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ install_zinc_for_linux() {

install_zinc_for_osx() {
brew install zinc
export ZINC_BIN=`which zinc`
}

0 comments on commit 4a1609c

Please sign in to comment.