-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfullBuild.sh
More file actions
executable file
·145 lines (126 loc) · 4.31 KB
/
Copy pathfullBuild.sh
File metadata and controls
executable file
·145 lines (126 loc) · 4.31 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
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
143
144
145
#!/usr/bin/env bash
set -e
arg_len=$#
all_args="$@"
args=""
skip_tools=n
remove_shadow="-x shadowJar"
shadow=${shadow:-$remove_shadow}
main_args="-Dxapi.composite=true -Pxapi.changing=true --parallel --build-cache --stacktrace -Pxapi.debug=false $shadow"
while (( arg_len > 0 )); do
arg_ind=$(( 1 + $# - arg_len ))
arg="${!arg_ind}"
case "$arg" in
--forcePublish|-fP)
echo "Forcing publishing"
all_args="${all_args/$arg}"
main_args="$main_args -PxapiForcePublish=true"
;;
--shadow|-s)
echo "Allowing shadow jar"
all_args="${all_args/$arg}"
main_args="${main_args/$remove_shadow}"
;;
--debug|-d)
set -o xtrace
;;
--main|-m)
if (( arg_ind == $# )); then
echo "Must provide an argument after --main"
exit 123
fi
next_arg=$(( arg_ind + 1 ))
to_main="${!next_arg}"
echo "Adding $to_main to main_args"
main_args="$main_args $to_main"
arg_len=$(( arg_len - 1 ))
;;
--fast|-f|--no-tool|-nT)
echo "Fast mode: skipping prerequisite tool builds"
skip_tools=y
;;
--java11|--jdk11|-j11)
echo "Java11 requested, skipping select incompatible groovy tasks"
main_args="$main_args -x :xapi-lang-test:compileTestGroovy -x :xapi-lang-test:compileGroovy"
# Hm... should really make this something portable
if [ -d /usr/lib/jvm/adoptopenjdk-11-hotspot-amd64 ]; then
export JAVA_HOME=/usr/lib/jvm/adoptopenjdk-11-hotspot-amd64
export PATH="$JAVA_HOME/bin:$(echo "$PATH" | sed -e "s/[^:]*adoptopenjdk[^:]*://g")"
fi
;;
*)
echo "Found pass-thru argument $arg"
args="$args $arg"
# Some special flags will cause us to erase some main_args
[[ "--no-build-cache" == "$arg" ]] && main_args="${main_args/ --build-cache}" || true
[[ "-Dxapi.composite=false" == "$arg" ]] && main_args="${main_args/-Dxapi.composite=true/-Dxapi.composite=false}" || true
;;
esac
arg_len=$(( arg_len - 1 ))
done
# Check if there are any more user-supplied arguments that we didn't handle, and insert default task list:
function has_args() {
if [[ -z "$args" ]]; then
return 1
fi
return 0
}
has_args || args="build xapiPublish testClasses -x test -x check -x javadoc"
echo "Running all builds' gradlew $args"
echo "Running main build w/ arguments: $main_args $args"
function is_java8_home() {
local candidate="$1"
local version_output
[[ -n "$candidate" && -x "$candidate/bin/java" ]] || return 1
version_output="$("$candidate/bin/java" -version 2>&1)" || return 1
[[ "$version_output" =~ version\ \"(1\.8|8)([\._\"]|$) ]]
}
function find_java8_home() {
local candidate
for candidate in \
"${XAPI_JAVA8_HOME:-}" \
"${JAVA8_HOME:-}" \
"${JDK8_HOME:-}" \
"${JAVA_HOME_8_X64:-}" \
"${JAVA_HOME:-}" \
/opt/jvm/jdk8u322-b06 \
/usr/lib/jvm/java-8-openjdk-amd64
do
if is_java8_home "$candidate"; then
printf '%s\n' "$candidate"
return 0
fi
done
return 1
}
function do_it() {
if [ "$skip_tools" == n ]; then
local java8_home
if ! java8_home="$(find_java8_home)"; then
echo "A Java 8 JDK is required for the two legacy Gradle stages." >&2
echo "Set XAPI_JAVA8_HOME to its installation directory and rerun." >&2
return 2
fi
echo "Using Java 8 from $java8_home for legacy Gradle stages"
pushd net.wti.core > /dev/null
echo "invoking ./gradlew $args in $(pwd)"
./gradlew $args
popd > /dev/null
pushd net.wti.gradle.modern > /dev/null
echo "invoking ./gradlew $args in $(pwd)"
./gradlew $args -x functionalTest
popd > /dev/null
pushd net.wti.gradle.tools > /dev/null
# the tools will install themselves to local repo whenever we build them.
echo "invoking ./gradlew $args in $(pwd)"
JAVA_HOME="$java8_home" PATH="$java8_home/bin:$PATH" ./gradlew $args
popd > /dev/null
pushd net.wti.gradle > /dev/null
echo "invoking ./gradlew $args in $(pwd)"
JAVA_HOME="$java8_home" PATH="$java8_home/bin:$PATH" ./gradlew $args
popd > /dev/null
fi
./gradlew $main_args $args
}
TIMEFORMAT='Full build time: %3Rs'
time do_it