-
Notifications
You must be signed in to change notification settings - Fork 8
/
build
executable file
·116 lines (97 loc) · 2.31 KB
/
build
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
#!/bin/bash -e
basename=`basename $0`
dirname=`dirname $0`
dirname=`cd "$dirname" && pwd`
cd "$dirname"
source build.config
# load optional config
if [ -f ./build.rc ]; then
source ./build.rc
fi
# show message and exit
function die {
echo "$1"
exit 1
}
# show usage and exit
function usage {
echo "usage: $basename <command> [options]"
exit 2
}
# run self
function self {
$0 $*
}
# run maven
function mvn {
./mvnw $*
}
command="$1"; shift
# complain if no command is given
if [ -z "$command" ]; then
usage
fi
case "$command" in
# change the version of the project
change-version)
newVersion="$1"
if [ -z "$newVersion" ]; then
usage "$command <version>"
fi
mvn org.eclipse.tycho:tycho-versions-plugin:0.25.0:set-version \
-Dtycho.mode=maven \
-Dartifacts=${project} \
-Dproperties=${project}.version \
-DnewVersion="$newVersion"
;;
# check license headers
license-check)
mvn -Plicense-check -N $*
;;
# format license headers
license-format)
mvn -Plicense-format -N $*
;;
# prepare CI build
ci-prepare)
self license-check $*
;;
# build for CI
ci-build)
if [ "$TRAVIS_PULL_REQUEST" != 'false' ]; then
goal=install
else
goal=deploy
fi
mvn clean ${goal} $*
;;
# release automation
release)
version="$1"
nextVersion="$2"
if [ -z "$version" -o -z "$nextVersion" ]; then
usage "$command <version> <next-version>"
fi
releaseTag="release-$version"
# update version and tag
self change-version "$version"
git commit -a -m "update version: $version"
git tag $releaseTag
# deploy release
mvn -Pbuildsupport-release clean deploy
# update to next version
self change-version "$nextVersion"
git commit -a -m "update version: $nextVersion"
;;
*)
# attempt to lookup command function
fn="command_$command"
if [ "$(type -t $fn)" = 'function' ]; then
$fn $*
else
# complain about missing command function
echo "Unknown command: $command"
usage
fi
;;
esac