forked from GoogleContainerTools/jib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·104 lines (92 loc) · 3.03 KB
/
build.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
#!/bin/sh
# Build Jib
quickMode=false
mavenOptions=""
gradleOptions=""
dryRun=""
usage()
{
eval 1>&2
echo "Simple builder for Jib for jib-core, jib-plugins-common, jib-maven-plugin, and jib-gradle-plugin"
echo "use: $0 [-qe] [clean | core | plugins | maven | gradle | it | format]"
echo " providing no target is the same as 'core plugins gradle maven'"
echo " -q quick mode: skip tests, formatting"
echo " -e show error information (mvn: -e, gradle: --stacktrace --info)"
echo " -n dry run: show what will be performed"
exit 1
}
# doBuild: Run a command in a directory
# $1 = directory
# $2... = build command
doBuild() {
(directory="$1"; shift; echo ">>> (cd $directory; $*)"; [ -z "$dryRun" ] && cd "$directory" && eval '"$@"')
}
while getopts qen c; do
case $c in
q) quickMode=true;;
e) mavenOptions="$mavenOptions -e"
gradleOptions="$gradleOptions --stacktrace --info"
;;
n) dryRun=true;;
\?) usage;;
esac
done
shift $( expr $OPTIND - 1 )
if [ $# -eq 0 ]; then
set -- core plugins gradle maven
fi
set -o errexit # exit on error
for target in "$@"; do
case "$target" in
clean)
doBuild jib-core ./gradlew $gradleOptions clean
doBuild jib-plugins-common ./gradlew $gradleOptions clean
doBuild jib-gradle-plugin ./gradlew $gradleOptions clean
doBuild jib-maven-plugin ./mvnw $mavenOptions clean
;;
core)
if [ "$quickMode" = false ]; then
doBuild jib-core ./gradlew $gradleOptions googleJavaFormat build
else
doBuild jib-core ./gradlew $gradleOptions build \
--exclude-task test --exclude-task check
fi
;;
plugins)
if [ "$quickMode" = false ]; then
doBuild jib-plugins-common ./gradlew $gradleOptions googleJavaFormat build
else
doBuild jib-plugins-common ./gradlew $gradleOptions build \
--exclude-task test --exclude-task check
fi
;;
maven)
if [ "$quickMode" = false ]; then
doBuild jib-maven-plugin ./mvnw $mavenOptions fmt:format install -U
else
# jib-maven-plugin pulls in jib-core directly
doBuild jib-maven-plugin ./mvnw $mavenOptions -Dcheckstyle.skip -Dfmt.skip -DskipTests install -U
fi
;;
gradle)
if [ "$quickMode" = false ]; then
doBuild jib-gradle-plugin ./gradlew $gradleOptions googleJavaFormat build install
else
# jib-gradle-plugin pulls in jib-core directly
doBuild jib-gradle-plugin ./gradlew $gradleOptions build install \
--exclude-task test --exclude-task check
fi
;;
it)
doBuild jib-core ./gradlew $gradleOptions integrationTest
doBuild jib-maven-plugin ./mvnw $mavenOptions -PintegrationTest verify -U
doBuild jib-gradle-plugin ./gradlew $gradleOptions integrationTest
;;
format)
doBuild jib-core ./gradlew googleJavaFormat
doBuild jib-plugins-common ./gradlew googleJavaFormat
doBuild jib-gradle-plugin ./gradlew googleJavaFormat
doBuild jib-maven-plugin ./mvnw fmt:format
;;
esac
done