-
Notifications
You must be signed in to change notification settings - Fork 21
/
build
executable file
·116 lines (97 loc) · 2.35 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 {
if [[ -z "$1" ]]; then
echo "usage: $basename <command> [options]"
else
echo "usage: $basename $1"
fi
exit 2
}
# run self
function self {
$0 "$@"
}
if [[ -z "$mvn_options" ]]; then
mvn_options=""
fi
# run maven
function mvn {
./mvnw ${mvn_options} "$@"
}
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:1.2.0:set-version \
-Dartifacts=${project} \
-Dproperties=${project}.version \
-DnewVersion="$newVersion"
;;
# check license headers
license-check)
mvn -f ./pom.xml -N -P -include-private com.mycila:license-maven-plugin:check
if [ -f "private/pom.xml" ]; then
mvn -f private/pom.xml -N com.mycila:license-maven-plugin:check "$@"
fi
;;
# format license headers
license-format)
mvn -f ./pom.xml -N -P -include-private com.mycila:license-maven-plugin:format
if [ -f "private/pom.xml" ]; then
mvn -f private/pom.xml -N com.mycila:license-maven-plugin:format "$@"
fi
;;
# 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 -Dbuild.notes="t:release"
# update to next version
self change-version "$nextVersion"
git commit -a -m "update version: $nextVersion"
# TODO: push origin (branch + tag)
;;
*)
# 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