-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmvn-version.sh
More file actions
executable file
·96 lines (83 loc) · 1.95 KB
/
mvn-version.sh
File metadata and controls
executable file
·96 lines (83 loc) · 1.95 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
#!/bin/zsh
# -*- coding: utf-8; tab-width: 2; indent-tabs-mode: nil; sh-basic-offset: 2; sh-indentation: 2; -*- vim:fenc=utf-8:et:sw=2:ts=2:sts=2
#
# Copyright (c) 2016 Enrico M. Crisostomo
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
#
setopt localoptions
setopt localtraps
unsetopt glob_subst
set -o errexit
set -o nounset
REQUIRED_PROGS=( xmlstarlet )
PROGNAME=$0
check_programs()
{
for p in ${REQUIRED_PROGS}
do
command -v ${p} > /dev/null 2>&1 || {
>&2 print -- Cannot find ${p}
exit 1
}
done
}
print_usage()
{
print -- "${PROGNAME}"
print
print -- "Usage:"
print -- "${PROGNAME} repository"
print
print -- "Report bugs to <>."
}
# main
check_programs
while getopts ":h" opt
do
case $opt in
h)
print_usage
exit 0
;;
\?)
>&2 print -- Invalid option -${OPTARG}.
exit 1
;;
:)
>&2 print -- Missing argument to -${OPTARG}.
exit 1
;;
esac
done
shift $((OPTIND-1))
(( $# == 1 )) || {
>&2 print -- Invalid number of arguments
exit 2
}
POM=${1}
if [[ -d ${POM} ]]
then
POM=${POM}/pom.xml
fi
if [[ ! -e ${POM} ]]
then
>&2 No such file or directory: ${POM}
continue
fi
PARENT=$(xmlstarlet sel \
-N x=http://maven.apache.org/POM/4.0.0 \
-t -m "/x:project/x:version" \
-v . \
${POM} || true)
printf "%s\n" ${PARENT}