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’ll 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
merged 1 commit into from
Mar 5, 2018
Merged

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

merged 1 commit into from
Mar 5, 2018

Conversation

christocracy
Copy link
Contributor

@christocracy 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:

…mpileSdkVersion, buildToolsVersion, targetSdkVersion, androidMapsUtilsVersion. This provides a much better mechanism for aligning the module to the host project, particularly for play-services version
@rborn
Copy link
Collaborator

rborn commented Feb 28, 2018

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

@christocracy thanks for the PR ❤️

@alvelig
Copy link
Contributor

alvelig commented Feb 28, 2018

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

@christocracy
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants