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

Convert gradle scripts to Kotlin #14

Closed
wants to merge 1 commit into from
Closed

Convert gradle scripts to Kotlin #14

wants to merge 1 commit into from

Conversation

dulmandakh
Copy link

No description provided.


This is not a breaking change because it affects only gradle scripts used to build RN for Android.

I converted build.gradle and settings.gradle in root directory, see at
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you link to specific files in the repo, so that they are easier to consume ?


## Detailed design

Convert only gradle scripts in ReactAndroid, and maybe RNTester, to Kotlin DSL, so we don't introduce breaking changes to RN based projects.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also consider scenarios where React Native is embedded into existing android apps. How will that work ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may also want to consider the changes coming in React Fabric and Turbo Modules. In both cases, there would be code-gen solutions, possible in JS. How would that integrate with the build system? These Code gen solutions are not finalized, so I may not yet have specific examples.

Also, we may need to run annotation processors, like ReactModuleInfoSpecProcessor that we don't run today. Should we address that also ?

* auto-completion and content assist
* quick documentation
* navigation to source
* refactoring and more
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to explicitly list all the advantages here, linking to the official reason that Gradle has given may be sufficient.


## Drawbacks

Currently, RN use Gradle 4.4 which has partial but enough support for Kotlin DSL. Until we have 4.10, which has stable Kotlin DSL, we have to make sure that gradle scripts works and might require changes to work with landed Gradle version.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, does it make sense to wait till Gradle 4.10 and then do the upgrade ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense to me.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dulmandakh - ping. What do you think about addressing this later when Gradle 4.10 comes around ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gradle 6.7.1 is already out now, so how is it going


## How we teach this

This change won't affect RN based projects and RN developers, but RN core contributors.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should still consider how we can get core contributors up to speed here.

* navigation to source
* refactoring and more

Also, nowadays there are more Android developers who knows Kotlin than Groovy.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this impacts only contributors, this would also require commitment from core contributors.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also impact all users of React Native with Android, as they also make changes to the gradle config in the template android project which is generated by RN.

@kelset kelset added the 💡 Proposal This label identifies a proposal label Aug 12, 2018
@dulmandakh
Copy link
Author

Thank you all for feedbacks, I'll try update my proposal ASAP to reflect the feedbacks and I'll do some research on questions.

date: 2018-08-11
---

# RFC0003: Use Kotlin DSL in gradle scripts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is RFC0004.

@cpojer
Copy link
Member

cpojer commented Feb 6, 2019

What's the status of this RFC? I think we use gradle 4.10+ now in RN so we can move ahead with this, no?

@Legion2
Copy link

Legion2 commented Sep 17, 2021

The usage of the old gradle script synctax such as buildscript and apply plugin is a huge blocker for us. Because RN dependencies are included as subprojects into the gradle project of tha apps, it forces the app developer(us) to also use the old syntax so that the gradle scripts are compatible.

We can not use the full kotlin dsl and features like pluginManagement and plugins dsl, because they do not work with the build.gradle files of react native projects.

There are no workarounds for the incompatibilities caused by the way react native uses gradle.

As a result react native is a blocker for the whole build tools ecosystem. No one can move forward without react native doing the first step to support the "new" gradle features and dropping the old syntax.

@cortinico
Copy link
Member

cortinico commented Sep 17, 2021

As a result react native is a blocker for the whole build tools ecosystem. No one can move forward without react native doing the first step to support the "new" gradle features and dropping the old syntax.

Thanks for raising this point @Legion2.

We're currently working on revamping how we integrate with Gradle. Some of the work is already available inside https://github.com/facebook/react-native/tree/main/packages/react-native-gradle-plugin

Once that is fully released, you won't need a buildscript{} or the apply from react.gradle block anymore. You will be able to use the plugins{} block out of the box. On top of it, we've also worked on using the Gradle Lazy APIs and other improvements that will make RN less of a stranger in the Android/Gradle ecosystem.

EDIT: A more wider explanation on the direction we're taking with Gradle is described in detail by @fkgozali here #273

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 Proposal This label identifies a proposal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants