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

Adding android gradle plugin as an extra property of project template #25145

Closed
SaeedZhiany opened this issue Jun 4, 2019 · 2 comments
Closed
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.

Comments

@SaeedZhiany
Copy link
Contributor

SaeedZhiany commented Jun 4, 2019

React Native version:
0.58.8

Steps To Reproduce

This is an enhancement (or feature request)

Describe what you expected to happen:
having an extra property in ext that specify android gradle plugin version, so libraries developer can read and set the main project android gradle plugin version to their library and so whole project build with the same gradle plugin. this is an important and useful property when users using CI server with code repository for building their product. for example, I use a docker with previous installed all necessary resources for building an android app in my CI server, but some of libraries I used have different gradle plugin version, so my docker has to download the different version of gradle plugins to build a final product.

I mean something like this:

I wanted to submit a pull request but I'm not expert in gradle build system and not familiar with this repository and I couldn't find android gradle template file, So I suggest my changes in here

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
        gradlePluginVersion = "3.4.1" <----- add this property to react native android template
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:$ext.gradlePluginVersion'
    }
}

By adding the property other library developers can do something like this in their library's gradle file:

def safeExtGet(prop, fallback) {
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

buildscript {
  repositories {
    ...
  }

  dependencies {
    classpath 'com.android.tools.build:gradle:${safeExtGet('gradlePluginVersion', '3.4.0')}'
  }
}

I don't familiar with gradle syntax, so it might be wrong in the syntax of what I wrote, I just want to suggest my idea.

Also, it would be great if make a standard mechanism that libraries could read version of gradle wrapper version of main project from gradle-wrapper.properties , because I have seen some libraries that have gradle-wrapper.properties file in their directory. for example, you can take a look at react-native-keychain library. I have no idea right now how can we add this feature, but I think it's worth discussing about it

@SaeedZhiany SaeedZhiany added the Bug label Jun 4, 2019
@react-native-bot react-native-bot added the Platform: Android Android applications. label Jun 4, 2019
@dulmandakh
Copy link
Contributor

It looks like not a RN issue, please file an issue to third-party modules you use. Thank you

@SaeedZhiany
Copy link
Contributor Author

@dulmandakh
I understand this is not an issue but I didn't know where I must suggest my opinion.
Actually, I suggested a convention, third-party libraries must know how the key gradlePluginVersion and its value will be defined in the main project's build gradle, else some developers assume that it has been defined like below:

gradlePluginVersion = "3.4.1"

and some others may assume like below:

gradlePluginVersion = "com.android.tools.build:gradle:3.4.1"

Also, there is no convention on the name of the key. what is better: ( gradlePluginVersion, gradlePlugin, ...).

Making a unique convention from react-native community seems a better solution than the libraries developers use their own convention.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants