-
Notifications
You must be signed in to change notification settings - Fork 4
/
zanata-artifact-m2repo
executable file
·68 lines (64 loc) · 1.88 KB
/
zanata-artifact-m2repo
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
#!/bin/bash -eu
### NAME
### zanata-artifact-m2repo - Get artifact list from m2 repo
###
### SYNOPSIS
### zanata-artifact-m2repo [options] <dir>
### zanata-artifact-m2repo -l
### zanata-artifact-m2repo -t
###
### DESCRIPTION
### This program produces artifact list from m2 repo
###
ScriptDir=$(dirname $(readlink -q -f $0))
FunctionScriptFile=${ScriptDir}/zanata-functions
source "$FunctionScriptFile"
trap exit_print_error EXIT
##=== parsing Start ===
print_status -t parsing -s "Start"
M2Repo=
###
### OPTIONS
while getopts "hlt" opt;do
case $opt in
###
### -h: Show this help
h )
zanata_script_help $0
exit $EXIT_OK
;;
###
### -l: Use maven default m2 repository directory, i.e.
### $HOME/.m2/repository
l )
M2Repo=$HOME/.m2/repository
;;
###
### -t: Use repository dir dump from zanata-maven-release
### zanata-maven-release will download the artifacts
### to $REPO_LOCAL_DIR, by default, it is
### /tmp/zanata/maven-central-release-repo
t )
M2Repo=$REPO_LOCAL_DIR
;;
* )
failed $EXIT_FATAL_INVALID_OPTIONS "$opt"
;;
esac
done
shift $((OPTIND-1))
[[ -z $M2Repo ]] && failed $EXIT_FATAL_INVALID_OPTIONS "Please either specify m2 directory, or use option -l or -t"
[[ ! -r $M2Repo ]] && failed $EXIT_FATAL_MISSING_DEPENDENCY "Directory $M2Repo is not readable"
for d in $(find $M2Repo -name '*.pom' -printf "%h\n");do
groupPre=$(sed -e "s|$M2Repo/\(.*\)/\([^/]*\)/\([^/]*\)|\1|" <<<$d)
group=$(sed -e "s|/|.|g" <<< $groupPre)
artifact=$(sed -e "s|$M2Repo/\(.*\)/\([^/]*\)/\([^/]*\)|\2|" <<<$d)
version=$(sed -e "s|$M2Repo/\(.*\)/\([^/]*\)/\([^/]*\)|\3|" <<<$d)
if [[ -z $(find $d -name '*.jar') ]];then
## pom only
echo "$group:$artifact:pom:$version"
else
## pom and jar
echo "$group:$artifact:jar:$version"
fi
done