Skip to content

Commit cbfcc68

Browse files
author
Brennon York
committed
Changed the default sbt/sbt to build/sbt and added a build/mvn which will automatically download, install, and execute maven with zinc for easier build capability
1 parent 8817fc7 commit cbfcc68

File tree

7 files changed

+169
-1
lines changed

7 files changed

+169
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
sbt/*.jar
1212
.settings
1313
.cache
14+
cache
1415
.generated-mima*
15-
/build/
1616
work/
1717
out/
1818
.DS_Store

build/mvn

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
#!/usr/bin/env bash
2+
3+
# Determine the current working directory
4+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5+
6+
# Called before any binaries are installed for any unknown operating system.
7+
# Current checks are as follows:
8+
# - NA
9+
prep_install_for_unknown() {
10+
echo "ERROR: Forced installation is not available at this time for an"
11+
echo "Operating System of type $OSTYPE"
12+
exit 1
13+
}
14+
15+
# Called before any binaries are installed for the Solaris operating system.
16+
# Current checks are as follows:
17+
# - NA
18+
prep_install_for_solaris() {
19+
echo "ERROR: Forced installation is not available at this time for"
20+
echo "Solaris-based systems."
21+
exit 1
22+
}
23+
24+
# Called before any binaries are installed for the BSD operating system.
25+
# Current checks are as follows:
26+
# - NA
27+
prep_install_for_bsd() {
28+
echo "ERROR: Forced installation is not available at this time for BSD-based systems."
29+
exit 1
30+
}
31+
32+
# Called before any binaries are installed for the Linux operating system.
33+
# Current checks are as follows:
34+
# - NA
35+
prep_install_for_linux() {
36+
echo
37+
}
38+
39+
# Called before any binaries are installed for the OS X operating system.
40+
# Current checks are as follows:
41+
# - 'brew' must be installed
42+
prep_install_for_osx() {
43+
[ -z "`which brew 2>/dev/null`" ] && \
44+
echo "ERROR: Must have 'brew' installed for forced installation on OSX." && \
45+
echo " - You can download 'brew' at: http://brew.sh/" && \
46+
exit 1
47+
}
48+
49+
# Determine if a given application is already installed and, if not, check for
50+
# forced installation,
51+
## Arg1 - application name
52+
check_and_install_app() {
53+
if [ -z "`which $1 2>/dev/null`" ]; then
54+
# attempt to force install if flagged
55+
if [ -n "${FORCE_INSTALL}" ]; then
56+
local resource="${DIR}/packages/$1.sh"
57+
if [ -f "$resource" ]; then
58+
source "${DIR}/packages/$1.sh"
59+
prep_install_for_${_OSTYPE}
60+
install_$1_for_${_OSTYPE}
61+
else
62+
echo "ERROR: Cannot find the $1.sh build file from within ${DIR}/packages."
63+
echo " Ensure the file exists and is accesible."
64+
exit 1
65+
fi
66+
# else exit with error message
67+
else
68+
echo "ERROR: $1 isn't installed; please install or automatically force install (-f)."
69+
exit 2
70+
fi
71+
fi
72+
}
73+
74+
# Set a cleaned OS type string based on the $OSTYPE bash variable
75+
case "$OSTYPE" in
76+
solaris*)
77+
_OSTYPE="solaris"
78+
;;
79+
darwin*)
80+
_OSTYPE="osx"
81+
;;
82+
linux*)
83+
_OSTYPE="linux"
84+
;;
85+
bsd*)
86+
_OSTYPE="bsd"
87+
;;
88+
*)
89+
_OSTYPE="unknown"
90+
;;
91+
esac
92+
93+
# Here we build our own CLI event loop with the '--' as the stop
94+
OPT="$1"
95+
while [ ! "$OPT" = "--" -a ! $# -eq 0 ]; do
96+
case $OPT in
97+
-f)
98+
FORCE_INSTALL=1
99+
shift
100+
;;
101+
-p=*)
102+
ZINC_PORT=${OPT/-p=/}
103+
shift
104+
;;
105+
*)
106+
echo "Unknown option: $OPT"
107+
shift
108+
;;
109+
esac
110+
OPT="$1"
111+
done
112+
shift
113+
114+
# Setup healthy defaults for the Zinc port if none were provided
115+
ZINC_PORT=${ZINC_PORT:-"3030"}
116+
117+
# Check and install all applications necessary to fully build Spark
118+
check_and_install_app "mvn"
119+
check_and_install_app "zinc"
120+
check_and_install_app "scala"
121+
122+
# Now that zinc is ensured to be installed, check its status and, if not
123+
# running, start it
124+
if [ -z "`zinc -status`" ]; then
125+
zinc -start -port ${ZINC_PORT}
126+
fi
127+
128+
# Determine the parameters pushed in from the command line and, if any are
129+
# present, use those within the maven
130+
if [ $# -gt 0 ]; then
131+
mvn "$@"
132+
else
133+
mvn clean package -DskipTests
134+
fi

build/packages/mvn.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
MVN_URL="http://apache.claz.org/maven/maven-3/3.2.3/binaries/apache-maven-3.2.3-bin.tar.gz"
4+
5+
install_mvn_for_linux() {
6+
echo
7+
}
8+
9+
install_mvn_for_osx() {
10+
brew install maven
11+
}
12+

build/packages/scala.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
SCALA_URL="http://downloads.typesafe.com/scala/2.11.4/scala-2.11.4.tgz"
4+
5+
install_scala_for_linux() {
6+
echo
7+
}
8+
9+
install_scala_for_osx() {
10+
brew install scala
11+
}

build/packages/zinc.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
ZINC_URL="http://downloads.typesafe.com/zinc/0.3.5.3/zinc-0.3.5.3.tgz"
4+
5+
install_zinc_for_linux() {
6+
echo
7+
}
8+
9+
install_zinc_for_osx() {
10+
brew install zinc
11+
}

sbt/sbt renamed to build/sbt

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)