Skip to content

Commit 8fdaf38

Browse files
Run tests on Android!
1 parent 1af0722 commit 8fdaf38

17 files changed

+272
-75
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,6 @@ bin/
6969
# Scala build
7070
*.cache
7171
/.nb-gradle/private/
72+
73+
# Android build local properties
74+
local.properties

.travis.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
1-
language: java
2-
jdk:
3-
- oraclejdk7
4-
sudo: false
51
# as per http://blog.travis-ci.com/2014-12-17-faster-builds-with-container-based-infrastructure/
2+
sudo: false
3+
4+
language: android
65

7-
# script for build and release via Travis to Bintray
8-
script: gradle/buildViaTravis.sh
6+
android:
7+
components:
8+
- build-tools-23.0.1
9+
- android-23
10+
- extra-android-m2repository
11+
- sys-img-armeabi-v7a-android-18
12+
13+
jdk:
14+
- oraclejdk7
15+
16+
script: gradle/build.sh
917

1018
# cache between builds
1119
cache:
1220
directories:
1321
- $HOME/.m2
1422
- $HOME/.gradle
23+
1524
env:
25+
matrix:
26+
- TARGET_PLATFORM=jdk
27+
- TARGET_PLATFORM="android-18 --abi armeabi-v7a"
1628
global:
1729
- secure: YcLpYfNc/dyDON+oDvnJK5pFNhpPeJHxlAHV8JBt42e51prAl6njqrg1Qlfdp0pvBiskTPQHUxbFy9DOB1Z+43lPj5vlqz6qBgtS3vtBnsrczr+5Xx7NTdVKq6oZGl45VjfNPT7zdM6GQ5ifdzOid6kJIFu34g9JZkCzOY3BWGM=
1830
- secure: WVmfSeW1UMNdem7+X4cVDjkEkqdeNavYH4udn3bFN1IFaWdliWFp4FYVBVi+p1T/IgkRSqzoW9Bm43DABe1UMFoErFCbfd7B0Ofgb4NZAsxFgokHGVLCe6k5+rQyASseiO7k0itSj3Kq9TrDueKPhv+g+IG0w1A8yZTnXdhXHvY=

android-tests/build.gradle

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
buildscript {
2+
repositories {
3+
jcenter()
4+
}
5+
6+
dependencies {
7+
// Android Gradle plugin
8+
classpath 'com.android.tools.build:gradle:1.3.1'
9+
10+
// Resolves android-sdk dependencies
11+
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
12+
13+
// NOTE: Do not place your application dependencies here; they belong
14+
// in the individual module build.gradle files
15+
}
16+
}
17+
18+
apply plugin: 'android-sdk-manager'
19+
apply plugin: 'com.android.library'
20+
21+
android {
22+
compileSdkVersion 23
23+
buildToolsVersion '23.0.1'
24+
25+
defaultConfig {
26+
minSdkVersion 14
27+
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
28+
}
29+
30+
sourceSets {
31+
androidTest {
32+
java.srcDir '../src/test/java'
33+
}
34+
}
35+
36+
compileOptions {
37+
sourceCompatibility JavaVersion.VERSION_1_7
38+
targetCompatibility JavaVersion.VERSION_1_7
39+
}
40+
}
41+
42+
dependencies {
43+
compile libraries.rxJava
44+
45+
androidTestCompile libraries.mockitoCore
46+
androidTestCompile libraries.dexMaker
47+
androidTestCompile libraries.dexMakerDx
48+
androidTestCompile libraries.dexMakerMockito
49+
androidTestCompile libraries.androidSupportTestRunner
50+
}
51+
52+
afterEvaluate {
53+
tasks.withType(com.android.build.gradle.internal.tasks.AndroidTestTask) { task ->
54+
task.doFirst {
55+
logging.level = LogLevel.INFO
56+
}
57+
task.doLast {
58+
logging.level = LogLevel.LIFECYCLE
59+
}
60+
}
61+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest package="io.reactivex.rxjava.android_tests">
3+
4+
</manifest>

build.gradle

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,23 @@
11
buildscript {
2-
repositories { jcenter() }
3-
dependencies { classpath 'com.netflix.nebula:gradle-rxjava-project-plugin:2.2.3' }
2+
repositories { jcenter() }
3+
dependencies { classpath 'com.netflix.nebula:gradle-rxjava-project-plugin:2.2.3' }
44
}
55

6-
description = 'RxJava: Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.'
6+
allprojects {
7+
repositories {
8+
jcenter()
9+
}
710

8-
apply plugin: 'rxjava-project'
9-
apply plugin: 'java'
10-
11-
dependencies {
12-
testCompile 'junit:junit-dep:4.10'
13-
testCompile 'org.mockito:mockito-core:1.8.5'
14-
}
15-
16-
javadoc {
17-
exclude "**/rx/internal/**"
11+
apply plugin: 'rxjava-project'
1812
}
1913

20-
// support for snapshot/final releases with the various branches RxJava uses
21-
nebulaRelease {
22-
addReleaseBranchPattern(/\d+\.\d+\.\d+/)
23-
addReleaseBranchPattern('HEAD')
24-
}
14+
ext.libraries = [
15+
rxJava : project(':rxjava'),
2516

26-
if (project.hasProperty('release.useLastTag')) {
27-
tasks.prepare.enabled = false
28-
}
29-
30-
test{
31-
maxHeapSize = "2g"
32-
}
17+
junit : 'junit:junit-dep:4.10',
18+
mockitoCore : 'org.mockito:mockito-core:1.10.19',
19+
dexMaker : 'com.crittercism.dexmaker:dexmaker:1.4',
20+
dexMakerDx : 'com.crittercism.dexmaker:dexmaker-dx:1.4',
21+
dexMakerMockito : 'com.crittercism.dexmaker:dexmaker-mockito:1.4',
22+
androidSupportTestRunner: 'com.android.support.test:runner:0.4'
23+
]

gradle/build.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
5+
if [ "$TARGET_PLATFORM" == "jdk" ]; then
6+
sh "${SCRIPTS_DIR}/buildViaTravis.sh"
7+
elif [[ "$TARGET_PLATFORM" == android-* ]]; then
8+
sh "${SCRIPTS_DIR}/runTestsOnAndroid.sh"
9+
fi

gradle/buildViaTravis.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
55
echo -e "Build Pull Request #$TRAVIS_PULL_REQUEST => Branch [$TRAVIS_BRANCH]"
6-
./gradlew -Prelease.useLastTag=true build
6+
./gradlew -Prelease.useLastTag=true :rxjava:build
77
elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" == "" ]; then
88
echo -e 'Build Branch with Snapshot => Branch ['$TRAVIS_BRANCH']'
9-
./gradlew -Prelease.travisci=true -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" -PsonatypeUsername="${sonatypeUsername}" -PsonatypePassword="${sonatypePassword}" build snapshot --stacktrace
9+
./gradlew -Prelease.travisci=true -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" -PsonatypeUsername="${sonatypeUsername}" -PsonatypePassword="${sonatypePassword}" :rxjava:build :rxjava:snapshot --stacktrace
1010
elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" != "" ]; then
1111
echo -e 'Build Branch for Release => Branch ['$TRAVIS_BRANCH'] Tag ['$TRAVIS_TAG']'
12-
./gradlew -Prelease.travisci=true -Prelease.useLastTag=true -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" -PsonatypeUsername="${sonatypeUsername}" -PsonatypePassword="${sonatypePassword}" final --stacktrace
12+
./gradlew -Prelease.travisci=true -Prelease.useLastTag=true -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" -PsonatypeUsername="${sonatypeUsername}" -PsonatypePassword="${sonatypePassword}" :rxjava:final --stacktrace
1313
else
1414
echo -e 'WARN: Should not be here => Branch ['$TRAVIS_BRANCH'] Tag ['$TRAVIS_TAG'] Pull Request ['$TRAVIS_PULL_REQUEST']'
15-
./gradlew -Prelease.useLastTag=true build
15+
./gradlew -Prelease.useLastTag=true :rxjava:build
1616
fi

gradle/runTestsOnAndroid.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
echo no | eval "android create avd --force -n test -t $TARGET_PLATFORM"
3+
emulator -avd test -no-skin -no-audio -no-window &
4+
android-wait-for-emulator
5+
adb shell input keyevent 82
6+
./gradlew connectedAndroidTest

rxjava/build.gradle

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
description = 'RxJava: Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.'
2+
3+
apply plugin: 'java'
4+
5+
sourceCompatibility = 1.7
6+
targetCompatibility = 1.7
7+
8+
sourceSets {
9+
main {
10+
java {
11+
srcDir '../src/main/java'
12+
}
13+
}
14+
15+
test {
16+
java {
17+
srcDir '../src/test/java'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
testCompile libraries.junit
24+
testCompile libraries.mockitoCore
25+
}
26+
27+
javadoc {
28+
exclude '**/rx/internal/**'
29+
}
30+
31+
// support for snapshot/final releases with the various branches RxJava uses
32+
nebulaRelease {
33+
addReleaseBranchPattern(/\d+\.\d+\.\d+/)
34+
addReleaseBranchPattern('HEAD')
35+
}
36+
37+
if (project.hasProperty('release.useLastTag')) {
38+
tasks.prepare.enabled = false
39+
}
40+
41+
test {
42+
maxHeapSize = '2g'
43+
}

settings.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
rootProject.name='rxjava'
1+
include ':rxjava'
2+
include ':android-tests'

0 commit comments

Comments
 (0)