Skip to content

Commit

Permalink
android: add build & test to travis.
Browse files Browse the repository at this point in the history
I change the .gitignore and add gradle-wrapper.jar, because it is needed
for the [./gradlew
command](http://developer.android.com/tools/building/building-cmdline.html)
to work. [Gradle
says](https://docs.gradle.org/current/userguide/gradle_wrapper.html)
this file *should* be in version control.
  • Loading branch information
tswast committed Feb 25, 2016
1 parent e99c63f commit fa2d531
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 38 deletions.
16 changes: 0 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,2 @@

### Java ###
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear
target/

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Service account JSON key, used in Travis
client-secret.json
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,18 @@ env:
global:
- GOOGLE_APPLICATION_CREDENTIALS=${TRAVIS_BUILD_DIR}/client-secret.json
matrix:
- CONFIG=android_jdk8
- CONFIG=android_oracle8
- CONFIG=java_jdk8
- CONFIG=java_oracle8
matrix:
exclude:
# It's nontrivial to programmatically install a new JDK from the command
# line on OS X, so we rely on testing on Linux for Java code.
- os: osx
env: CONFIG=android_jdk8
- os: osx
env: CONFIG=android_oracle8
- os: osx
env: CONFIG=java_jdk8
- os: osx
Expand All @@ -54,5 +60,8 @@ matrix:
env: CONFIG=objectivec_ios
- os: osx
env: CONFIG=swift_ios
branches:
only:
- master
notifications:
email: false
11 changes: 11 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.gradle
build/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Cache of project
.gradletasknamecache
Binary file not shown.
2 changes: 1 addition & 1 deletion android/CloudVision/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ echo location of your Java installation.
goto fail

:init
@rem Get command-line arguments, handling Windowz variants
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
Expand Down
15 changes: 15 additions & 0 deletions java/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
### Java ###
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear
target/

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

99 changes: 78 additions & 21 deletions travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ use_java() {
version=$1
case "$version" in
jdk8)
sudo apt-get update
sudo apt-get -y install openjdk-8-jdk
sudo apt-get -qq update
sudo apt-get -qqy install openjdk-8-jdk
export PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH
;;
oracle8)
sudo apt-get install python-software-properties # for apt-add-repository
sudo apt-get -qqy install python-software-properties # for apt-add-repository
echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | \
sudo debconf-set-selections
yes | sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get -y install oracle-java8-installer
sudo apt-add-repository -y ppa:webupd8team/java
sudo apt-get -qqy update
sudo apt-get -qqy install oracle-java8-installer
export PATH=/usr/lib/jvm/java-8-oracle/bin:$PATH
;;
esac
Expand All @@ -46,14 +46,15 @@ use_java() {

build_java() {
for jdir in $(ls -d java/*/); do
(
cd "${jdir}" && mvn clean compile assembly:single
if [ -z "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then
echo "Secrets not available, skipping tests."
mvn clean verify -DskipTests
else
mvn clean verify
fi
cd ../..
)
done
}

Expand All @@ -67,6 +68,60 @@ build_java_oracle8() {
build_java
}

build_android() {
# Set up Gradle, then update to latest version.
# http://www.tothenew.com/blog/gradle-installation-in-ubuntu/
sudo apt-get -qqy install python-software-properties # for apt-add-repository
sudo add-apt-repository -y ppa:cwchien/gradle
sudo apt-get -qqy update
sudo apt-get -qqy install gradle-2.11
gradle -v
# Set up the Android SDK.
# https://gist.github.com/wenzhixin/43cf3ce909c24948c6e7
# We can't use the default Android Travis runtime, because we are a
# multi-language project.
# Need 32-bit versions of the libraries.
# http://stackoverflow.com/a/19524010/101923
sudo dpkg --add-architecture i386
sudo apt-get -qqy update
# adb
sudo apt-get -qqy install libc6:i386 libstdc++6:i386
# aapt
sudo apt-get -qqy install zlib1g:i386
wget http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
tar xzf android-sdk_r24.4.1-linux.tgz
export ANDROID_HOME=$PWD/android-sdk-linux
export PATH="${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools"
# Accept the license.
# http://stackoverflow.com/a/17863931/101923
sudo apt-get -qqy install expect
expect -c '
set timeout 600 ;
spawn android update sdk --filter platform-tools,tools,build-tools-23.0.2,android-23,extra-android-support,extra-android-m2repository,extra-google-m2repository --no-ui --force;
expect {
"Do you accept the license" { exp_send "y\r" ; exp_continue }
eof
}
'
# Build and test the app!
(
cd android/CloudVision
./gradlew --console=plain assembleDebug && \
./gradlew --console=plain lintDebug && \
./gradlew --console=plain testDebugUnitTest
)
}

build_android_jdk8() {
use_java jdk8
build_android
}

build_android_oracle8() {
use_java oracle8
build_android
}

internal_ios_common () {
# Make sure xctool is up to date. Adapted from
# http://docs.travis-ci.com/user/osx-ci-environment/
Expand Down Expand Up @@ -94,12 +149,12 @@ build_objectivec_ios() {
-sdk iphonesimulator \
build
# TODO: build-tests, when we have tests
IOS_DESTINATIONS=(
"platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
"platform=iOS Simulator,name=iPhone 6,OS=9.2" # 64bit
"platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit
"platform=iOS Simulator,name=iPad Air,OS=9.2" # 64bit
)
# IOS_DESTINATIONS=(
# "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
# "platform=iOS Simulator,name=iPhone 6,OS=9.2" # 64bit
# "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit
# "platform=iOS Simulator,name=iPad Air,OS=9.2" # 64bit
# )
# TODO: run-tests, when we have tests
# for i in "${IOS_DESTINATIONS[@]}" ; do
# internal_xctool_debug_and_release \
Expand All @@ -125,12 +180,12 @@ build_swift_ios() {
-sdk iphonesimulator \
build
# TODO: build-tests, when we have tests
IOS_DESTINATIONS=(
"platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
"platform=iOS Simulator,name=iPhone 6,OS=9.2" # 64bit
"platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit
"platform=iOS Simulator,name=iPad Air,OS=9.2" # 64bit
)
# IOS_DESTINATIONS=(
# "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
# "platform=iOS Simulator,name=iPhone 6,OS=9.2" # 64bit
# "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit
# "platform=iOS Simulator,name=iPad Air,OS=9.2" # 64bit
# )
# TODO: run-tests, when we have tests
# for i in "${IOS_DESTINATIONS[@]}" ; do
# internal_xctool_debug_and_release \
Expand All @@ -146,8 +201,10 @@ build_swift_ios() {

if [ "$#" -ne 1 ]; then
echo "
Usage: $0 { java_jdk7 |
java_oracle7 |
Usage: $0 { android_jdk8 |
android_oracle8 |
java_jdk8 |
java_oracle8 |
objectivec_ios |
swift_ios }
"
Expand Down

0 comments on commit fa2d531

Please sign in to comment.