Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for presence of project-wide gradle configuration properties #2047

Merged

Conversation

Projects
None yet
3 participants
@christocracy
Copy link
Contributor

christocracy commented Feb 28, 2018

As recommended by the Android Developer Document Gradle Tips & Tricks (See "Configure project-wide properties"), if the hosting application defines the following properties in their root build.gradle, peer modules (like react-native-maps) can align its dependencies as requested:

馃搨 android/build.gradle

buildscript {...}

allprojects {...}

/**
 * Project-wide gradle configuration properties for use by all modules
 */
+ext {
+    compileSdkVersion   = 26
+    targetSdkVersion    = 26
+    buildToolsVersion   = "26.0.2"
+    supportLibVersion   = "26.1.0"
+    googlePlayServicesVersion = "11.8.0"
+    androidMapsUtilsVersion = "0.5+"
+}

馃搨 android/app/build.gradle

android {
+    compileSdkVersion rootProject.compileSdkVersion
+    buildToolsVersion rootProject.buildToolsVersion

    defaultConfig {
+        targetSdkVersion rootProject.targetSdkVersion
    }
}
dependencies {
     compile fileTree(dir: "libs", include: ["*.jar"])
+    compile "com.android.support:appcompat-v7:$rootProject.supportLibVersion"
     compile "com.facebook.react:react-native:+"  // From node_modules

     compile project(':react-native-background-geolocation')
     compile project(':react-native-background-fetch')
     compile project(':react-native-device-info')
     compile project(':react-native-maps')
}

This provides a much better mechanism for aligning play-services version than all the nasty business of exclude group:

   ...
   dependencies {
       ...
       compile(project(':react-native-maps')){
           exclude group: 'com.google.android.gms', module: 'play-services-base'
           exclude group: 'com.google.android.gms', module: 'play-services-maps'
       }
       compile 'com.google.android.gms:play-services-base:10.0.1'
       compile 'com.google.android.gms:play-services-maps:10.0.1'
   }

Many other modules are beginning to implement this project-wide configuration properties mechansism, eg:

Check for presense of project-wide gradle configuration properties co鈥
鈥pileSdkVersion, buildToolsVersion, targetSdkVersion, androidMapsUtilsVersion. This provides a much better mechanism for aligning the module to the host project, particularly for play-services version
@rborn

This comment has been minimized.

Copy link
Collaborator

rborn commented Feb 28, 2018

LGTM
@christopherdro could you have a look at this please 馃惤?

@christocracy thanks for the PR 鉂わ笍

@alvelig

This comment has been minimized.

Copy link
Collaborator

alvelig commented Feb 28, 2018

Oh, I get it! Yes that's a great thing

@christocracy

This comment has been minimized.

Copy link
Contributor Author

christocracy commented Mar 22, 2018

Seems this was a timely addition with the big play-services 12.0.0 blow-up today ;)

jeaye added a commit to jeaye/react-native-send-intent that referenced this pull request Jul 20, 2018

jeaye added a commit to jeaye/react-native-send-intent that referenced this pull request Jul 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.