Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Commit 8d8b0b1

Browse files
authored
Merge pull request #123 from firebase/v11_SDK_support
Added support of Google Play Services v11 SDK.
2 parents d3623ae + 73754cf commit 8d8b0b1

32 files changed

+827
-316
lines changed

.travis.yml

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,56 @@ jdk: oraclejdk8
55
# killed, so pretend sudo is required so we don't use the container infra.
66
# See: https://github.com/travis-ci/travis-ci/issues/5582
77
sudo: required
8+
9+
env:
10+
matrix:
11+
- ANDROID_TARGET=android-16 ANDROID_ABI=armeabi-v7a
12+
- ANDROID_TARGET=android-17 ANDROID_ABI=armeabi-v7a
13+
- ANDROID_TARGET=android-18 ANDROID_ABI=armeabi-v7a
14+
- ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a
15+
- ANDROID_TARGET=android-21 ANDROID_ABI=armeabi-v7a
16+
global:
17+
- ADB_INSTALL_TIMEOUT=10 # Default is 2 minutes, bump to 10
18+
819
android:
920
components:
1021
- tools
1122
- platform-tools
12-
- build-tools-25.0.0
1323
- android-25
24+
- build-tools-25.0.0
25+
1426
- extra-android-m2repository
1527
- extra-google-m2repository
1628

29+
- sys-img-armeabi-v7a-android-16
30+
- sys-img-armeabi-v7a-android-17
31+
- sys-img-armeabi-v7a-android-18
32+
- sys-img-armeabi-v7a-android-19
33+
- sys-img-armeabi-v7a-android-21
34+
1735
# "avoid uploading the cache after every build"
1836
before_cache:
1937
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
2038
- rm -rf $HOME/.gradle/caches/*/plugin-resolution/
39+
2140
cache:
2241
directories:
2342
- $HOME/.gradle/caches/
2443
- $HOME/.gradle/wrapper/
44+
- $HOME/.android/build-cache
45+
46+
before_script:
47+
# Print the list of available targets to aid in debugging CI issues
48+
- android list targets
49+
# Create the AVD (name "test")
50+
- echo no | android create avd --force --name test --target $ANDROID_TARGET --abi $ANDROID_ABI
51+
# Start the emulator in the background
52+
- emulator -avd test -no-skin -no-audio -no-window &
2553

26-
script: ./gradlew jobdispatcher:build testapp:assemble
54+
script:
55+
- android-wait-for-emulator
56+
- adb devices
57+
# Simulate hitting the menu button
58+
- adb shell input keyevent 82 &
59+
# Build the library + run unit tests, run device tests, build the test app
60+
- ./gradlew jobdispatcher:build testapp:assemble

README.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,12 @@ Play services is unavailable.<br>
7676

7777
### Installation
7878

79-
If you **don't** have a dependency on
80-
[`com.google.android.gms:play-services-gcm`][gcm], add the following to your
81-
`build.gradle`'s dependencies section:
79+
Add the following to your `build.gradle`'s dependencies section:
8280

8381
```
84-
compile 'com.firebase:firebase-jobdispatcher:0.6.0'
82+
compile 'com.firebase:firebase-jobdispatcher:0.7.0'
8583
```
8684

87-
Otherwise add the following:
88-
89-
```
90-
compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.6.0'
91-
```
92-
93-
NOTE: These variants are a temporary requirement. Work is ongoing to consolidate
94-
them into the same bulid.
95-
9685
### Usage
9786

9887
#### Writing a new JobService

common/constants.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
project.ext {
33
projectName = "firebase-jobdispatcher-android"
44
group = "com.firebase"
5-
version = "0.6.0"
5+
version = "0.7.0"
66
buildtools = "25.0.0"
77
supportLibraryVersion = "25.0.0"
88
compileSdk = 25

gcm_defs/build.gradle

Lines changed: 0 additions & 25 deletions
This file was deleted.

gcm_defs/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
This file was deleted.

jobdispatcher/build.gradle

Lines changed: 46 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ android {
1313
targetSdkVersion project.ext.compileSdk
1414
versionCode 1
1515
versionName project.ext.version
16+
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
1617
}
1718

18-
defaultPublishConfig "noDepRelease"
19+
defaultPublishConfig "release"
1920
publishNonDefault true
2021

2122
buildTypes {
@@ -28,34 +29,32 @@ android {
2829
}
2930
}
3031

31-
productFlavors {
32-
withGcmDep
33-
noDep
32+
sourceSets {
33+
// A set of testing helpers that are shared across test types
34+
testLib { java.srcDir("src/main") }
35+
test { java.srcDir("src/testLib") } // Robolectric tests
36+
androidTest { java.srcDir("src/testLib") } // Android (e2e) tests
3437
}
3538
}
3639

3740
dependencies {
38-
testCompile 'junit:junit:4.12'
39-
testCompile 'org.robolectric:robolectric:3.1.2'
40-
testCompile 'org.mockito:mockito-core:2.2.5'
41+
// The main library only depends on the Android support lib
4142
compile "com.android.support:support-v4:${project.ext.supportLibraryVersion}"
42-
// In a perfect world we'd have these dependencies totally handled by the
43-
// Android plugin using a combination of "provided" (compile-time only) and
44-
// "package" (runtime only) rules:
45-
//
46-
// noDepCompile project(":gcm_defs")
47-
// withGcmDepProvided project(":gcm_defs")
48-
//
49-
// Unfortunately this doesn't work. We can't import the same project with
50-
// different visibility settings because the Android plugin reuses the
51-
// same identifier when it creates the necessary backing rules, so we get a
52-
// dupe rule error.
53-
//
54-
// So, instead we mark the gcm_defs as provided (compile-time only) and
55-
// manually copy the required classes into the noDep flavor (below).
56-
provided project(':gcm_defs')
57-
// the withGcmDep version has an explicit dependency on the GCM library.
58-
withGcmDepCompile "com.google.android.gms:play-services-gcm:10.0.1"
43+
44+
def junit = 'junit:junit:4.12'
45+
def robolectric = 'org.robolectric:robolectric:3.3.2'
46+
47+
// The common test library uses JUnit
48+
testLibCompile junit
49+
50+
// The unit tests are written using JUnit, Robolectric, and Mockito
51+
testCompile junit
52+
testCompile robolectric
53+
testCompile 'org.mockito:mockito-core:2.2.5'
54+
55+
// The Android (e2e) tests are written using JUnit and the test support lib
56+
androidTestCompile junit
57+
androidTestCompile 'com.android.support.test:runner:0.5'
5958
}
6059

6160
task javadocs(type: Javadoc) {
@@ -84,22 +83,8 @@ task aar(dependsOn: "assembleRelease") {
8483
}
8584

8685
// Artifact descriptions (surfaced in JCenter / Maven)
87-
def noDepDesc = "The Firebase JobDispatcher is a library that provides a common" +
86+
def artifactDesc = "The Firebase JobDispatcher is a library that provides a common" +
8887
" interface to scheduling engines on Android."
89-
def withGcmDepDesc = noDepDesc + " This version should be used by anyone with a" +
90-
" dependency on the legacy GCM library (com.google.android.gms:play-services-gcm)."
91-
92-
// Maps flavors to descriptions + artifacts
93-
def flavorsToPublicationsMap = [
94-
noDep: [
95-
description: noDepDesc,
96-
artifactId: "firebase-jobdispatcher",
97-
],
98-
withGcmDep: [
99-
description: withGcmDepDesc,
100-
artifactId: "firebase-jobdispatcher-with-gcm-dep",
101-
],
102-
]
10388

10489
publishing {
10590
repositories {
@@ -111,18 +96,28 @@ publishing {
11196
}
11297

11398
publications {
114-
// Create a new MavenPublication for each of the flavors (noDep, withGcmDep)
115-
android.productFlavors.each { flavor ->
116-
"dispatcher${flavor.name.capitalize()}Library"(MavenPublication) {
117-
artifactId flavorsToPublicationsMap[flavor.name].artifactId
99+
// The initial FJD releases had two artifacts; one for users that
100+
// already had a dependency on the gcm client library and one for users
101+
// that didn't. There's no longer a need for these two variants, but we
102+
// continue to produce the -with-gcm-dep version (identical to the
103+
// standard artifact) to prevent breaking clients.
104+
//
105+
// TODO(ciarandowney): add a deprecation notice pointing users to the
106+
// regular version
107+
[
108+
standardArtifact: "firebase-jobdispatcher",
109+
legacyArtifact: "firebase-jobdispatcher-with-gcm-dep",
110+
].each { key, value ->
111+
"dispatcherLibrary${key.capitalize()}"(MavenPublication) {
112+
artifactId value
118113
groupId project.ext.group
119114
version project.ext.version
120115

121116
// Add the AAR artifact
122-
artifact("${buildDir}/outputs/aar/jobdispatcher-${flavor.name}-release.aar") {
117+
artifact("${buildDir}/outputs/aar/jobdispatcher-release.aar") {
123118
// wrap in a closure because this task isn't defined 'till
124119
// the android plugin finishes
125-
builtBy { tasks["bundle${flavor.name.capitalize()}Release"] }
120+
builtBy { tasks["bundleRelease"] }
126121
}
127122
// Add the sources and javadoc JARs
128123
artifact sourcesJar
@@ -132,7 +127,7 @@ publishing {
132127
pom.withXml {
133128
def n = asNode()
134129

135-
n.appendNode("description", flavorsToPublicationsMap[flavor.name].description)
130+
n.appendNode("description", artifactDesc)
136131
n.appendNode("inceptionYear", 2016)
137132

138133
def licensesNode = n.appendNode("licenses")
@@ -168,76 +163,27 @@ publishing {
168163
dependencyNode.appendNode('groupId', it.group)
169164
dependencyNode.appendNode('artifactId', it.name)
170165
dependencyNode.appendNode('version', it.version)
166+
dependencyNode.appendNode('type', 'aar')
171167
}
172168

173169
// add deps that everyone has
174170
configurations.compile.allDependencies.each addDep
175171
// add config specific deps
176-
configurations["${flavor.name}Compile"].allDependencies.each addDep
172+
configurations["releaseCompile"].allDependencies.each addDep
177173
}
178174
}
179175
}
180176
}
181177
}
182178

183-
// Merges required classes into the resulting AAR (UberJAR style). Without
184-
// this, the classes from gcm_defs wouldn't be packed into the AAR. We also
185-
// need to make sure that the withGcmDeps flavor doesn't include the GCM
186-
// parcelables.
187179
afterEvaluate {
188-
android.productFlavors.each { flavor ->
189-
android.buildTypes.each { bt ->
190-
def artifactName = "gcm_defs-release"
191-
def jarDestDir = "${buildDir}/intermediates/libs/${flavor.name}/${bt.name}/libs"
192-
def unpackedDestDir = "${buildDir}/unpacked/${artifactName}"
193-
194-
def copyLibs = task("copy${flavor.name.capitalize()}${bt.name.capitalize()}Libs",
195-
type: Copy) {
196-
description "Copies gcm_defs aar into the build dir"
197-
198-
from configurations.provided
199-
include "${artifactName}.aar"
200-
into jarDestDir
201-
}
202-
203-
def unzipClasses = task("unzip${flavor.name.capitalize()}${bt.name.capitalize()}Libs",
204-
type: Copy, dependsOn: copyLibs) {
205-
description "Unzips the copied gcm_defs aar contents"
206-
207-
from zipTree("${jarDestDir}/${artifactName}.aar")
208-
into unpackedDestDir
209-
}
210-
211-
def syncClasses = task("sync${flavor.name.capitalize()}${bt.name.capitalize()}Libs",
212-
type: Copy, dependsOn: unzipClasses) {
213-
description "Merges the copied gcm_defs classes with the aar classes"
214-
215-
from(zipTree("${unpackedDestDir}/classes.jar")) {
216-
exclude "**/BuildConfig.class"
217-
218-
if (flavor.name == "withGcmDep") {
219-
// Parcelable included unobfuscated in the GCM lib
220-
exclude "**/com/google/android/gms/gcm/PendingCallback*.class"
221-
222-
// AIDL-derived IBinder that's obfuscated in the GCM
223-
// lib, so we don't have to (and shouldn't) strip our
224-
// copy because it doesn't conflict.
225-
// exclude "**/com/google/android/gms/gcm/INetworkTaskCallback*.class"
226-
}
227-
}
228-
into "${buildDir}/intermediates/classes/${flavor.name}/${bt.name}"
229-
}
230-
231-
def jarTask = tasks["process${flavor.name.capitalize()}${bt.name.capitalize()}JavaRes"]
232-
jarTask.dependsOn syncClasses
233-
}
234-
}
235-
236180
bintray {
237181
user = findProperty("BINTRAY_USER") ?: System.getenv("BINTRAY_USER")
238182
key = findProperty("BINTRAY_KEY") ?: System.getenv("BINTRAY_KEY")
239183

240-
publications = ["dispatcherNoDepLibrary", "dispatcherWithGcmDepLibrary"]
184+
publications = [
185+
"dispatcherLibraryStandardArtifact",
186+
"dispatcherLibraryLegacyArtifact"]
241187

242188
pkg {
243189
userOrg = "firebase"

jobdispatcher/coverage.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ android {
2121
// ignore these when generating coverage
2222
def ignoredPrefixes = ['R$', 'R.class', 'BuildConfig.class']
2323

24-
task coverage(type: JacocoReport, dependsOn: ["testNoDepDebugUnitTest"]) {
24+
task coverage(type: JacocoReport, dependsOn: ["testDebugUnitTest"]) {
2525
group = "Reports"
2626
description = "Generate a coverage report"
2727

2828
classDirectories = fileTree(
29-
dir: "${project.buildDir}/intermediates/classes/noDep/debug/com/firebase/",
29+
dir: "${project.buildDir}/intermediates/classes/debug/com/firebase/",
3030
exclude: { d -> ignoredPrefixes.any { p -> d.file.name.startsWith(p) } }
3131
)
3232
sourceDirectories = files(["src/main/java/com/firebase/"])
33-
executionData = files("${project.buildDir}/jacoco/testNoDepDebugUnitTest.exec")
33+
executionData = files("${project.buildDir}/jacoco/testDebugUnitTest.exec")
3434

3535
reports {
3636
xml.enabled = true
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2017 Google Inc.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<manifest
18+
xmlns:android="http://schemas.android.com/apk/res/android"
19+
package="com.firebase.jobdispatcher">
20+
21+
<uses-sdk android:minSdkVersion="14" />
22+
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
23+
24+
<instrumentation
25+
android:targetPackage="com.firebase.jobdispatcher"
26+
android:name="android.test.InstrumentationTestRunner" />
27+
28+
<application>
29+
<service android:exported="false" android:name=".TestJobService">
30+
<intent-filter>
31+
<action android:name="com.firebase.jobdispatcher.ACTION_EXECUTE"/>
32+
</intent-filter>
33+
</service>
34+
</application>
35+
</manifest>

0 commit comments

Comments
 (0)