Skip to content

Commit 0f17ea6

Browse files
committed
build(build): add build script
1 parent 9b037ac commit 0f17ea6

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,7 @@ captures/
156156
# Keystore files
157157
*.jks
158158

159+
160+
## CUSTOM
161+
162+
Release/

build.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
#
3+
# LPM | Author: Ben Marten
4+
# Copyright (c) 2017 Leanplum Inc. All rights reserved.
5+
#
6+
set -eo pipefail; [[ $DEBUG ]] && set -x
7+
8+
# Check for Jenkins build number, otherwise default to curent time in seconds.
9+
if [[ -z "${BUILD_NUMBER+x}" ]]; then
10+
BUILD_NUMBER=$(date "+%s")
11+
fi
12+
export ANDROID_VERSION_STRING="$ANDROID_VERSION.$BUILD_NUMBER"
13+
14+
for i in "$@"; do
15+
case $i in
16+
--upload)
17+
upload=true
18+
shift # past argument=value
19+
;;
20+
esac
21+
done
22+
23+
LEANPLUM_SDK_ROOT=${LEANPLUM_SDK_ROOT:-"$(pwd)/."}
24+
configuration="Release"
25+
default="${LEANPLUM_SDK_ROOT}"
26+
android_dir=${android_dir:-$default}
27+
default="${android_dir}/AndroidSDK"
28+
sdk_dir=${sdk_dir:-$default}
29+
release_dir="${android_dir}/Release"
30+
31+
mkdir -p "$release_dir"
32+
33+
# Build the AndroidSDK using gradle.
34+
rm -rf "${sdk_dir}/build"
35+
rm -rf "${sdk_dir}/javadoc"
36+
if [[ -z ${upload+x} ]]; then
37+
GRADLE_TASK="assemble${configuration} makeJar generateJavadoc"
38+
else
39+
GRADLE_TASK="assemble${configuration} makeJar generateJavadoc artifactoryPublish"
40+
fi
41+
42+
cd "${sdk_dir}"
43+
# shellcheck disable=SC2086
44+
gradle $GRADLE_TASK
45+
46+
mv "${sdk_dir}/javadoc" "${release_dir}/."
47+
cp "${sdk_dir}/build/intermediates/bundles/release/classes.jar" "${release_dir}/Leanplum.jar"
48+
49+
echo "${GREEN} Done.${NORMAL}"

0 commit comments

Comments
 (0)