-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckout_build_latest_otp.sh
More file actions
71 lines (54 loc) · 1.54 KB
/
checkout_build_latest_otp.sh
File metadata and controls
71 lines (54 loc) · 1.54 KB
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
#!/usr/bin/env bash
# Fail correctly on pipes
set -o pipefail
# Exit on error
set -o errexit
# FOR DEBUGGING!
# set -o xtrace
# Set variables for current FILE, & DIR
__DIR__="$(cd "$(dirname "${0}")"; echo $(pwd))"
__BASE__="$(basename "${0}")"
__FILE__="${__DIR__}/${__BASE__}"
__CURRENT_WORKING_DIR__=$(pwd)
# Exit when using undeclared variables
set -o nounset
command_exists () {
type "$1" &> /dev/null ;
}
#
#
#
# END OF BASH SCRIPT BOILERPLATE http://kvz.io/blog/2013/11/21/bash-best-practices/
#
#
#
# DEFAULTS
OTP_DIRECTORY_DEFAULT="openTripPlanner"
OTP_GIT_URL_DEFAULT="https://github.com/opentripplanner/OpenTripPlanner.git"
OTP_BRANCH_DEFAULT="master"
# INPUT ARGUMENTS
OTP_DIRECTORY="${1:-${OTP_DIRECTORY_DEFAULT}}"
OTP_GIT_URL="${2:-${OTP_GIT_URL_DEFAULT}}"
OTP_BRANCH="${3:-${OTP_BRANCH_DEFAULT}}"
OTP_DIRECTORY=$(cd "$OTP_DIRECTORY" && pwd)
CURRENT_WORKING_DIR=$(pwd)
# COMPUTED VARIABLES VALIDATION
if [ ! -d "${OTP_DIRECTORY}" ]; then echo "ERROR: NO DIRECTORY FOUND ON GIVE PATH: FIRST CREATE EMPTY DIRECTORY"; exit; fi
if (! command_exists mvn); then
echo "ERROR: MAVEN IS NOT INSTALLED!";
fi
# START ACTUAL SCRIPT
echo; echo "1 CLONING OTP FROM ${OTP_GIT_URL} IF NEEDED"; echo;
cd ${OTP_DIRECTORY}
if [ ! -d .git ]; then
# Never clone before
git clone ${OTP_GIT_URL} .
fi
echo; echo "2 FORCE CHECKOUT BRANCH: ${OTP_BRANCH}"; echo;
git checkout -f HEAD^
git checkout -f ${OTP_BRANCH}
git pull
echo; echo "3 BUILD OTP"; echo;
mvn clean verify # -DskipTests # Or skip tests if you don't want to
cd ${CURRENT_WORKING_DIR}
exit