This repository has been archived by the owner on Dec 30, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmigrate-pom-versions.sh
executable file
·82 lines (72 loc) · 1.78 KB
/
migrate-pom-versions.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
#!/usr/bin/env bash
## Default paths. Can be overriden by command line
## args --build-dir and/or --output-dir
TMP_DIR="/tmp/exist-nightly-build/mvn"
BUILD_DIR="${TMP_DIR}/source"
OUTPUT_DIR="${TMP_DIR}/target"
## stop on first error!
set -e
## uncomment the line below for debugging this script!
#set -x
# determine the directory that this script is in
pushd `dirname $0` > /dev/null
SCRIPT_DIR=`pwd -P`
popd > /dev/null
# parse command line args
for i in "$@"
do
case $i in
-d|--build-dir)
BUILD_DIR="$2"
shift
;;
--build-in-place)
BUILD_DIR="${SCRIPT_DIR}"
shift
;;
-o|--output-dir)
OUTPUT_DIR="$2"
shift
;;
-i|--output-in-place)
OUTPUT_DIR="${SCRIPT_DIR}"
shift
;;
-f|--from-version)
FROM_VERSION="$2"
shift
;;
-t|--to-version)
TO_VERSION="$2"
shift
;;
*) # unknown option
shift
;;
esac
done
FROM_GROUP_DIR="${BUILD_DIR}/org/exist-db"
TO_GROUP_DIR="${OUTPUT_DIR}/org/exist-db"
echo -e "Migrating ${FROM_VERSION} to ${TO_VERSION}...\n"
# Make sure a folder for the parent POM exists
mkdir -p "${TO_GROUP_DIR}/exist-parent/${TO_VERSION}"
# POMS
for f in `find $FROM_GROUP_DIR -name "*-${FROM_VERSION}.pom" -type f`
do
if [[ ${f} != *"avalon"* ]] && [[ ${f} != *"modules"* ]]; then
DEST=${f//$FROM_VERSION/$TO_VERSION}
DEST=${DEST//$FROM_GROUP_DIR/$TO_GROUP_DIR}
DEST_PARENT="$(dirname "$DEST")"
if [[ ! -d $DEST_PARENT ]]; then
echo "Parent dir for $f does not exist, skippping..."
else
cp -v $f $DEST
sed -i -e "s#<version>${FROM_VERSION}</version>#<version>${TO_VERSION}</version>#g" $DEST
openssl sha1 -r "${DEST}" | sed 's/\([a-f0-9]*\).*/\1/' > "${DEST}.sha1"
fi
else
echo "Skipping $f"
fi
done
# cleanup -e files
find . -name \*.pom-e -exec rm {} \;