-
Notifications
You must be signed in to change notification settings - Fork 163
/
runLocally.sh
executable file
·55 lines (44 loc) · 1.5 KB
/
runLocally.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
#!/usr/bin/env bash
# Abort the script if any simple command outside an if, while, &&, ||, etc. exits with a non-zero status.
set -e
function confirm() {
declare answer
read -r -p "$1 [y/N]: " answer
[[ "$answer" == "y" ]]
}
function abort() {
echo "Aborted."
exit 0
}
function standalone_jar_or_maven() {
local -r standalone=optaweb-employee-rostering-standalone
# BEGIN: Distribution use case
#
# We're running a copy of the script in the project root that has been moved to distribution's bin directory during
# distribution assembly. The only difference is that the standalone JAR is in the same directory as the script (bin)
# and project.version is set using resource filtering during assembly.
# shellcheck disable=SC2154 #(project.version variable is not declared)
if [[ ! -f pom.xml && -f ${standalone}-${project.version}/quarkus-run.jar ]]
then
readonly jar=${standalone}-${project.version}/quarkus-run.jar
return 0
fi
# END: Distribution use case
readonly jar=${standalone}/target/quarkus-app/quarkus-run.jar
if [[ ! -f ${jar} ]]
then
confirm "Jarfile '$jar' does not exist. Run Maven build now?" || abort
if ! mvn clean install -DskipTests
then
echo >&2 "Maven build failed. Aborting the script."
exit 1
fi
fi
}
function run_optaweb() {
java "$@" -jar "$jar"
}
# Change dir to the project root (where the script is located).
cd -P "$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
standalone_jar_or_maven
run_optaweb "$@"