Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

Commit

Permalink
Updated firebase-messaging when firebase-iid is
Browse files Browse the repository at this point in the history
* Updating firebase-iid to to new of a version can cause runtime crashes with firebase-messaging
* Added a list of minimum versions firebase-messaging needs when updating to certain versions of firebase-iid
* Fixes #69
  • Loading branch information
jkasten2 committed Oct 11, 2018
1 parent 6058962 commit a1f8c40
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class GradleProjectPlugin implements Plugin<Project> {
]
]

// Similar to MODULE_DEPENDENCY_MINIMUMS but applied at the group level.
static final def UPDATE_PARENT_ON_DEPENDENCY_UPGRADE = [
(GROUP_ANDROID_SUPPORT): [
'27.0.0': [
Expand All @@ -143,11 +144,28 @@ class GradleProjectPlugin implements Plugin<Project> {
]
]

// Summary: Map of modules with a map of versions if are at or higher then update the list of modules.
// Solves: Issue where a sub dependency of a module can be updated to a version that is incompatible
// to a parent modules.
// Example: firebase-iid:16.2.0 and firebase-messaging:17.0.0 causes a runtime crash of
// class not found. While scanning dependencies when we find firebase-iid:16.2.0
// we will update firebase-messaging to 17.1.0 to fix this issue.
static final Map<String, Map<String, Map<String, String>>> MODULE_DEPENDENCY_MINIMUMS = [
'com.google.firebase:firebase-core': [
'16.0.0': [
'com.google.firebase:firebase-messaging': '17.0.0'
]
],
'com.google.firebase:firebase-iid': [
'16.2.0': [
'com.google.firebase:firebase-messaging': '17.1.0'
],
'17.0.0': [
'com.google.firebase:firebase-messaging': '17.3.0'
],
'17.0.1': [
'com.google.firebase:firebase-messaging': '17.3.1'
]
]
]

Expand All @@ -162,7 +180,7 @@ class GradleProjectPlugin implements Plugin<Project> {
}
}

static Map<String, Object> versionModuleAligns = [:]
static Map<String, Object> versionModuleAligns

static def versionGroupAligns
static Project project
Expand Down Expand Up @@ -193,6 +211,7 @@ class GradleProjectPlugin implements Plugin<Project> {
versionGroupAligns = InternalUtils.deepcopy(VERSION_GROUP_ALIGNS)
copiedModules = [:]
shownWarnings = [:]
versionModuleAligns = [:]

generateMinModulesToTrackStatic()

Expand Down
26 changes: 25 additions & 1 deletion src/test/groovy/com/onesignal/androidsdk/MainTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MainTest extends Specification {

then:
results.each {
assert it.value.contains('com.onesignal:OneSignal:[3.8.3, 3.99.99] -> 3.10.1')
assert it.value.contains('com.onesignal:OneSignal:[3.8.3, 3.99.99] -> 3.10.2')
}
}

Expand Down Expand Up @@ -731,6 +731,30 @@ class MainTest extends Specification {
}
}

// TODO:*: Future, should step through all versions to discover limits automatically
// This also covers case when firebase-core:16.0.4, as it depends on firebase-iid:17.0.3
def 'when firebase-core:16.0.4 and firebase-messaging:15.0.2 upgrade to firebase-messaging:17.3.1'() {
def compileLines = """\
compile 'com.google.firebase:firebase-messaging:15.0.2'
compile 'com.google.firebase:firebase-iid:17.0.3'
"""

// Can enable the following to do a build with proguard to find minimum versions
// GradleTestTemplate.buildArgumentSets[GRADLE_LATEST_VERSION] = [['build']] // , '--info']]

when:
def results = runGradleProject([
skipGradleVersion: GRADLE_OLDEST_VERSION,
compileLines : compileLines
])

then:
assert results // Asserting existence and contains 1+ entries
results.each {
assert it.value.contains('com.google.firebase:firebase-messaging:15.0.2 -> 17.3.1')
}
}

def 'when firebase-core:16 and firebase-messaging:12.0.0 upgrade to firebase-messaging:17.0.0'() {
def compileLines = """\
compile 'com.google.firebase:firebase-messaging:12.0.0'
Expand Down

0 comments on commit a1f8c40

Please sign in to comment.