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
/
upload.sh
executable file
·118 lines (100 loc) · 2.74 KB
/
upload.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
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
117
118
#!/usr/bin/env bash
# determine the directory that this script is in
pushd `dirname $0` > /dev/null
SCRIPT_DIR=`pwd -P`
popd > /dev/null
## Default paths. Can be overriden by command line
## arg --output-dir
TMP_DIR="/tmp/exist-nightly-build/mvn"
OUTPUT_DIR="${TMP_DIR}/target"
## stop on first error!
set -e
## uncomment the line below for debugging this script!
#set -x
RELEASES_REPOSITORY_ID="exist-db"
RELEASES_REPOSITORY_URL="https://repo.evolvedbinary.com/repository/exist-db/"
SNAPSHOTS_REPOSITORY_ID="exist-db-snapshots"
SNAPSHOTS_REPOSITORY_URL="https://repo.evolvedbinary.com/repository/exist-db-snapshots/"
REPOSITORY_ID="${RELEASES_REPOSITORY_ID}"
REPOSITORY_URL="${RELEASES_REPOSITORY_URL}"
for i in "$@"
do
case $i in
-l|--local)
LOCAL=YES
shift # past argument with no value
;;
-3|--third-party)
THIRD_PARTY=YES
shift # past argument with no value
;;
-a|--artifact-version)
ARTIFACT_VERSION="$2"
shift
;;
-s|--snapshot)
SNAPSHOT="TRUE"
REPOSITORY_ID="${SNAPSHOTS_REPOSITORY_ID}"
REPOSITORY_URL="${SNAPSHOTS_REPOSITORY_URL}"
shift
;;
-o|--output-dir)
OUTPUT_DIR="$2"
shift
;;
-i|--output-in-place)
OUTPUT_DIR="${SCRIPT_DIR}"
shift
;;
*) # unknown option
shift
;;
esac
done
## sanity checks
if [ -z "${ARTIFACT_VERSION}" ]
then
echo "upload.sh [-l|--local -3|--third-party] -a|--artifact-version <version>"
exit 1
fi
# check that Maven 3.5.4 or later is available
if ! [ -x "$(command -v mvn)" ]; then
echo -e "Error: Maven mvn binary not found on the PATH\n"
exit 2
fi
REQUIRED_MVN_VERSION=354
MVN_VERSION="$(mvn --version | head -n 1 | sed 's|Apache Maven \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*|\1\2\3|')"
if [ ! "$MVN_VERSION" -ge $REQUIRED_MVN_VERSION ]; then
echo -e "Error: Building requires Maven 3.5.4 or newer\n"
echo -e "Found $(mvn --version | head -n 1)\n"
exit 2
fi
# Install to local repo or upload to remote
MAVEN_CMD=""
if [ -n "${LOCAL}" ]
then
MAVEN_CMD="mvn install:install-file"
else
MAVEN_CMD="mvn deploy:deploy-file -DrepositoryId=${REPOSITORY_ID} -Durl=${REPOSITORY_URL}"
fi
# Upload the Artifacts
for f in `find ${OUTPUT_DIR} -name "*${ARTIFACT_VERSION}.jar" -type f`
do
POM=${f/.jar/.pom}
CMD="${MAVEN_CMD} -DpomFile=${POM} -Dfile=${f}"
eval $CMD
done
# Upload the 3rd-party Artifacts
if [ -n "${THIRD_PARTY}" ]
then
for f in `find $OUTPUT_DIR/org/exist-db/thirdparty -name "*.jar" -type f`
do
POM=${f/.jar/.pom}
CMD="${MAVEN_CMD} -DpomFile=${POM} -Dfile=${f}"
eval $CMD
done
fi
# Upload the parent POM file
PARENT_POM="${OUTPUT_DIR}/org/exist-db/exist-parent/${ARTIFACT_VERSION}/exist-parent-${ARTIFACT_VERSION}.pom"
CMD="${MAVEN_CMD} -DpomFile=${PARENT_POM} -Dfile=${PARENT_POM}"
eval $CMD