-
Notifications
You must be signed in to change notification settings - Fork 253
/
Copy pathprepare-android-vendor.sh
executable file
·111 lines (95 loc) · 2.81 KB
/
prepare-android-vendor.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
#!/usr/bin/env bash
set -xeuo pipefail
TEMP_DIR=
cleanup() {
if [ "$TEMP_DIR" != "" ]; then
rm -rf "$TEMP_DIR"
fi
}
trap cleanup EXIT
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
SCRIPT_NAME="${0##*/}"
CONFIG_FILE="$SCRIPT_DIR/prepare-android-vendor.config"
MODE=$(head -1 "$CONFIG_FILE")
ARG=$(tail -1 "$CONFIG_FILE")
MAVEN_REPO_DIR="$HOME/.m2/repository/com/bugsnag"
ARTIFACT_NAMES=(
bugsnag-android
bugsnag-android-core
bugsnag-android-ndk
bugsnag-plugin-android-ndk
bugsnag-plugin-android-anr
bugsnag-plugin-react-native
)
REPO_FILE_VARIANTS=(
'-sources.jar'
'-sources.jar.asc'
'.aar'
'.aar.asc'
'.module'
'.module.asc'
'.pom'
'.pom.asc'
)
revendor_from_dir() {
local src_dir="$(cd "$1" && pwd)"
if [ ! -f "$src_dir/gradlew" ]; then
echo "Source directory doesn't look like the bugsnag-android repo: $src_dir"
exit 1
fi
local dst_dir="$SCRIPT_DIR/android"
local com_dir="$dst_dir/com"
# artefact version needs to be unique to avoid clash with bugsnag-android artefacts
# deployed on mavenCentral/jcenter, append a 'react-native' suffix
local bugsnag_android_version=$(cat $src_dir/gradle.properties | grep VERSION_NAME)
local bugsnag_version_rn="${bugsnag_android_version#*=}-react-native"
echo "Clearing local maven repo $MAVEN_REPO_DIR"
rm -rf "$MAVEN_REPO_DIR"
echo "Building local copy of bugsnag-android $bugsnag_version_rn"
"$src_dir/gradlew" -p "$src_dir" clean assembleRelease publishToMavenLocal -PVERSION_NAME=$bugsnag_version_rn
echo "Rebuilding vendor dir $dst_dir"
rm -rf "$com_dir"
mkdir -p "$com_dir"
cp -r "$MAVEN_REPO_DIR" "$com_dir/"
}
use_bugsnag_version() {
local version=$1
local dst_dir="$SCRIPT_DIR/android"
local bugsnag_dir="$dst_dir/com/bugsnag"
rm -rf "$bugsnag_dir"
for name in ${ARTIFACT_NAMES[@]}; do
local dstdir="$bugsnag_dir/$name"
mkdir -p "$dstdir"
pushd "$dstdir"
for variant in ${REPO_FILE_VARIANTS[@]}; do
curl https://repo1.maven.org/maven2/com/bugsnag/$name/$version/$name-$version$variant >>$name-$version$variant
done
done
}
revendor_from_sha() {
local tag=$1
echo "Checking out https://github.com/bugsnag/bugsnag-android.git with tag $tag"
TEMP_DIR="$(mktemp -d)"
pushd "$TEMP_DIR" >/dev/null
git clone https://github.com/bugsnag/bugsnag-android.git
cd bugsnag-android
git checkout $tag
git submodule update --init --recursive
popd >/dev/null
revendor_from_dir "$TEMP_DIR/bugsnag-android"
}
case $MODE in
version)
use_bugsnag_version $ARG
;;
sha)
revendor_from_sha $ARG
;;
local)
revendor_from_dir "$ARG"
;;
*)
echo "$MODE: Unknown mode in $CONFIG_FILE"
exit 1
;;
esac;