Fix android build and enable snapshots
Summary: Fix some long-standing issues with the android build on Travis (and elsewhere) and enable automatic publishing of snapshots. Reviewed By: emilsjolander Differential Revision: D5044001 fbshipit-source-id: f00be07f33c8018573af0b98233068ebd93360b4
This commit is contained in:
committed by
Facebook Github Bot
parent
181101c92d
commit
ffcd2cfc8a
14
.travis.yml
14
.travis.yml
@@ -9,6 +9,9 @@ os: osx
|
||||
osx_image: xcode8.2
|
||||
language: cpp
|
||||
compiler: clang
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/Library/Caches/Homebrew
|
||||
|
||||
env:
|
||||
- TARGET=c
|
||||
@@ -63,12 +66,8 @@ before_install:
|
||||
brew cask install java;
|
||||
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8);
|
||||
export PATH=$JAVA_HOME/bin:$PATH;
|
||||
brew install caskroom/cask/android-sdk;
|
||||
export ANDROID_SDK=/usr/local/Cellar/android-sdk/24.4.1_1;
|
||||
export ANDROID_HOME=/usr/local/Cellar/android-sdk/24.4.1_1;
|
||||
brew install lib32stdc++6 lib32z1;
|
||||
echo y | $ANDROID_SDK/tools/android update sdk --filter android-19,addon-google_apis-google-19,build-tools-19.1.0 --no-ui;
|
||||
echo y | $ANDROID_SDK/tools/android update sdk -u;
|
||||
source scripts/android-setup.sh && installAndroidSDK
|
||||
export ANDROID_SDK=$ANDROID_HOME
|
||||
fi
|
||||
|
||||
# JavaScript
|
||||
@@ -114,7 +113,8 @@ script:
|
||||
# Android
|
||||
- |
|
||||
if [[ $TARGET = "android" ]]; then
|
||||
buck build --verbose 0 //android/sample:sample
|
||||
buck build --verbose 0 //android/sample:sample &&
|
||||
scripts/publish-snapshot.sh
|
||||
fi
|
||||
|
||||
# JavaScript
|
||||
|
37
scripts/android-setup.sh
Normal file
37
scripts/android-setup.sh
Normal file
@@ -0,0 +1,37 @@
|
||||
function download() {
|
||||
if hash curl 2>/dev/null; then
|
||||
curl -L -o $2 $1
|
||||
elif hash wget 2>/dev/null; then
|
||||
wget -O $2 $1
|
||||
else
|
||||
echo >&2 "No supported download tool installed. Please get either wget or curl."
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
function installsdk() {
|
||||
PROXY_ARGS=""
|
||||
if [[ ! -z "$https_proxy" ]]; then
|
||||
PROXY_HOST="$(cut -d : "$https_proxy" -f 1,1)"
|
||||
PROXY_PORT="$(cut -d : "$https_proxy" -f 2,2)"
|
||||
PROXY_ARGS="--proxy=http --proxy_host=$PROXY_HOST --proxy_port=$PROXY_PORT"
|
||||
fi
|
||||
|
||||
yes | $ANDROID_HOME/tools/bin/sdkmanager $PROXY_ARGS $@
|
||||
}
|
||||
|
||||
function installAndroidSDK {
|
||||
TMP=/tmp/sdk$$.zip
|
||||
download 'https://dl.google.com/android/repository/tools_r25.2.3-linux.zip' $TMP
|
||||
unzip -d $HOME/android-sdk $TMP
|
||||
rm $TMP
|
||||
|
||||
export ANDROID_HOME=$HOME/android-sdk
|
||||
export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$PATH"
|
||||
|
||||
mkdir -p $ANDROID_HOME/licenses/
|
||||
echo > $ANDROID_HOME/licenses/android-sdk-license
|
||||
echo -n 8933bad161af4178b1185d1a37fbf41ea5269c55 > $ANDROID_HOME/licenses/android-sdk-license
|
||||
|
||||
installsdk 'build-tools;23.0.2' 'build-tools;25.0.2' 'build-tools;25.0.1' 'platforms;android-23' 'platforms;android-25' 'ndk-bundle' 'extras;android;m2repository'
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Deploy a SNAPSHOT JAR after every successful Circle CI To Sonatype.
|
||||
# See https://circleci.com/docs/1.0/environment-variables/
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
BASEDIR="$(readlink -m "$(dirname "$0")/..")"
|
||||
IS_SNAPSHOT="$(grep 'VERSION_NAME=[0-9\.]\+-SNAPSHOT' "$BASEDIR/gradle.properties")"
|
||||
|
||||
if [ "$TRAVIS_REPO_SLUG" != "facebook/yoga" ]; then
|
||||
echo "Skipping repository. Expected project to be 'facebook/yoga', but was '$TRAVIS_REPO_SLUG'."
|
||||
exit
|
||||
elif [ "$TRAVIS_BRANCH" != "master" ]; then
|
||||
echo "Skipping build. Expected branch name to be 'master', but was '$TRAVIS_BRANCH'."
|
||||
exit
|
||||
elif [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
||||
echo "Skipping build. Only considering non-PR builds, but URL was '$TRAVIS_PULL_REQUEST'."
|
||||
exit
|
||||
elif [ "$IS_SNAPSHOT" == "" ]; then
|
||||
echo "Skipping build. Given build doesn't appear to be a SNAPSHOT release."
|
||||
else
|
||||
"$BASEDIR/gradlew" uploadArchives
|
||||
fi
|
24
scripts/publish-snapshot.sh
Executable file
24
scripts/publish-snapshot.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Deploy a SNAPSHOT JAR after every successful CI run To Sonatype.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
|
||||
IS_SNAPSHOT="$(grep 'VERSION_NAME=[0-9\.]\+-SNAPSHOT' "$BASEDIR/gradle.properties")"
|
||||
|
||||
if [ "$TRAVIS_REPO_SLUG" != "facebook/yoga" ]; then
|
||||
echo >&2 "Skipping repository. Expected project to be 'facebook/yoga', but was '$TRAVIS_REPO_SLUG'."
|
||||
exit
|
||||
elif [ "$TRAVIS_BRANCH" != "master" ]; then
|
||||
echo >&2 "Skipping build. Expected branch name to be 'master', but was '$TRAVIS_BRANCH'."
|
||||
exit
|
||||
elif [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
||||
echo >&2 "Skipping build. Only considering non-PR builds, but URL was '$TRAVIS_PULL_REQUEST'."
|
||||
exit
|
||||
elif [ "$IS_SNAPSHOT" == "" ]; then
|
||||
echo >&2 "Skipping build. Given build doesn't appear to be a SNAPSHOT release."
|
||||
else
|
||||
env TERMINAL=dumb "$BASEDIR/gradlew" uploadArchives
|
||||
fi
|
Reference in New Issue
Block a user