Skip to content

Commit

Permalink
Merge pull request #184 from intercom/conor/support
Browse files Browse the repository at this point in the history
Prevent unsafe versions of the Support Library being used
  • Loading branch information
ronocod authored May 18, 2017
2 parents 9e4b50f + 0450a4a commit 01609be
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
Example/node_modules
4 changes: 2 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ dependencies:
override:
- npm install -g cordova
- if [ ! -e $ANDROID_HOME/platforms/android-25 ]; then echo y | android update sdk --no-ui --all --filter android-25; fi
- if [ ! -e $ANDROID_HOME/extras/android/m2repository/com/android/support/design/25.0.1 ]; then echo y | android update sdk --no-ui --all --filter extra-android-m2repository; fi
- if [ ! -e $ANDROID_HOME/extras/google/m2repository/com/google/firebase/firebase-messaging/9.8.0 ]; then echo y | android update sdk --no-ui --all --filter extra-google-m2repository; fi
- if [ ! -e $ANDROID_HOME/extras/android/m2repository/com/android/support/design/25.3.1 ]; then echo y | android update sdk --no-ui --all --filter extra-android-m2repository; fi
- if [ ! -e $ANDROID_HOME/extras/google/m2repository/com/google/firebase/firebase-messaging/10.2.1 ]; then echo y | android update sdk --no-ui --all --filter extra-google-m2repository; fi

cache_directories:
# Android SDK
Expand Down
25 changes: 25 additions & 0 deletions src/android/build-extras-intercom.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,28 @@
// @link https://issues.apache.org/jira/browse/CB-10014
def manifest = new XmlSlurper().parse(file("AndroidManifest.xml"))
android.defaultConfig.applicationId manifest.@package.text()

// some libraries depend on higher versions of our dependencies than we support
// we keep track of these dependencies here and override the version to a safe one
def safeVersions = [
"com.android.support:support-v4": "25.+"
]

def badVersionIndicators = [
'alpha',
'beta',
'preview',
',)'
]

configurations.all {
resolutionStrategy.eachDependency {
DependencyResolveDetails details ->
def safeVersion = safeVersions[details.requested.group + ":" + details.requested.name]
def requestedVersion = details.requested.version
if (safeVersion != null && badVersionIndicators.any { requestedVersion.contains(it) }) {
println "Intercom: Overriding dependency ${details.requested.group}:${details.requested.name} version ${details.requested.version} --> $safeVersion"
details.useVersion safeVersion
}
}
}

0 comments on commit 01609be

Please sign in to comment.