-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbootstrap.sh
executable file
·142 lines (122 loc) · 2.91 KB
/
bootstrap.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
function help_text()
{
echo "
Usage:
bootstrap (default values)
or bootstrap OPTION(S) TARGET
or bootstrap TARGET OPTION(S)
Available OPTIONs:
-h, --help show this text
-sp, --skip-pull skip git pull --rebase
-sc, --skip-clean keep untracked files and directories
Available TARGETs:
SIMS, SKUMMET and DEFAULT
Examples:
bootstrap
bootstrap SIMS
bootstrap -sp DEFAULT
bootstrap --skip-clean SKUMMET
bootstrap -sp -sc SIMS
"
}
SKIP_PULL=false
SKIP_CLEAN=false
TARGET=DEFAULT
if [ -z "$1" ]
then
echo "Using default values"
fi
while [ "$1" != "" ]; do
PARAM=`echo $1 | awk -F= '{print $1}'`
case $PARAM in
-h | --help)
help_text
exit
;;
-sp | --skip-pull)
SKIP_PULL=true
;;
-sc | --skip-clean)
SKIP_CLEAN=true
;;
DEFAULT | SKUMMET | SIMS)
TARGET=$PARAM
;;
*)
echo "ERROR: unknown parameter \"$PARAM\""
help_text
exit 1
;;
esac
shift
done
echo "Checking for Java installation";
[ -z "$JAVA_HOME" ] && echo "JAVA_HOME cannot be empty" && exit 1;
echo "[OK] " $JAVA_HOME;
if [ "$SKIP_PULL" = true ];
then
echo "Skipping git pull"
else
echo "rebasing"
git pull --rebase || exit -1;
fi
if [ "$SKIP_CLEAN" = true ];
then
echo "Skipping git clean"
else
echo "cleanning"
git clean -d -x --force --quiet;
fi
echo "Force-removing Sneer jars"
rm -rf ~/.m2/repository/me/sneer/;
echo "Checking for correct Leiningen installation."
if command -v lein; then
CUR=$(lein version | awk '{print $2}' 2>&1)
echo "
Using Leiningen version $CUR.
";
else
echo "
You don't seem to have Leiningen on your PATH.
Please follow the instructions at http://leiningen.org/
";
exit 1;
fi
echo "Gradlew clean ckeck install"
./gradlew clean check install;
case $TARGET in
SIMS)
echo "Cleaning core"
rm -rf ~/.m2/repository/me/sneer/core;
;;
SKUMMET)
echo "Publishing Skummet jar"
./gradlew :core:publish || exit -1;
;;
DEFAULT)
echo "Removing Skummet artifacts"
rm -rf skummet-artifacts/;
;;
*)
echo "ERROR: unknown target \"$PARAM\""
exit 1
;;
esac
echo "Checking for Android SDK installation";
[ -z "$ANDROID_HOME" ] && echo "ANDROID_HOME cannot be empty" && exit 1;
echo "[OK] " $ANDROID_HOME;
echo "Cleaning Android build"
cd android && ./gradlew clean && cd .. || exit -1;
if command -v adb; then
adb devices | while read line
do
if [ ! "$line" = "" ] && [ `echo $line | awk '{print $2}'` = "device" ]
then
echo "Installing on available Android devices/emulators"
cd android && ./gradlew installDebug && cd .. || exit -1;
break;
fi
done
fi
echo "Reset environment successful"