-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
fix: react android kotlin plugin version conflict #34255
Conversation
Base commit: 4899f8c |
LGTM, working on my big project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sending this over @hurali97 🙏 really appreciate.
Are we able to iterate on this a bit?
buildscript { | ||
dependencies { | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.hasProperty("kotlinVersion") ? rootProject.ext.kotlinVersion : KOTLIN_VERSION}" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will have unwanted side effects. Specifically mixing buildscript{}
and plugins{}
in Gradle is not advised.
It seems like a workaround that we could live with 🤔 But I would look for a solution that uses only plugins{}
if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I looked, having dynamic version in plugins isn't quite possible. Since, we require to use the kotlinVersion from root level if that's present.
See here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a note on why this is needed otherwise we'll forget about it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the reason to go with this approach is:
use the kotlinVersion defined in top level build.gradle. If it's not defined, we use the default(1.6.10 as of now) defined in gradle.properties. We couldn't add dynamic version using the plugins DSL because of the constrained syntax, so we had to introduce the buildScript for this. See here
Should I add it as a comment in the build.gradle or are we good here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're good here 👍
I'm looking into cleaning this up a bit in the future so this will hopefully go.
Plus can we make the CI green? |
So CI is failing at:
and
It would be great if you can help me out in this, as I don't think this might be related to the changes in this PR. |
This is actually related. |
Whoa, okay. I will update once I test it on local. |
@cortinico I updated the build.gradle and kotlin compilation issue is resolved. But test_android on CI is failing because of the following:
Also build_hermes_macos fails because:
Any leads here? |
IMHO a you should be find with a rebase this time |
Base commit: 051a677 |
@cortinico Thanks for your help 🙂 All is 🟢 |
@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
This pull request was successfully merged by @hurali97 in be35c6d. When will my fix make it into a release? | Upcoming Releases |
Summary: Fixes #34229 Basically, the react android conflicts with the kotlin version that's defined in the top level build.gradle. To resolve it, the approach was to get the `kotlinVersion` defined in top level build.gradle and use it. If it's not defined, we use the default(1.6.10 as of now). The reason behind not using the DSL is that it doesn't allow us to use the variables due to it's constrained syntax. See [here](https://docs.gradle.org/current/userguide/plugins.html#sec:constrained_syntax) So the idea was to use the build script to resolve the kotlin plugin and it works 👍 . Kindly asking for review cortinico :) ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [Android] [Changed] - refactored usage of kotlin plugin Pull Request resolved: #34255 Test Plan: Ran the node ./scripts/run-ci-e2e-tests.js --js --android --ios to verify it doesn't introduce any unexpected issues. Reviewed By: dmitryrykun Differential Revision: D38468567 Pulled By: cortinico fbshipit-source-id: f9ab635fcf033f1d337ed90793ba1667957b8e01
Summary: Fixes facebook#34229 Basically, the react android conflicts with the kotlin version that's defined in the top level build.gradle. To resolve it, the approach was to get the `kotlinVersion` defined in top level build.gradle and use it. If it's not defined, we use the default(1.6.10 as of now). The reason behind not using the DSL is that it doesn't allow us to use the variables due to it's constrained syntax. See [here](https://docs.gradle.org/current/userguide/plugins.html#sec:constrained_syntax) So the idea was to use the build script to resolve the kotlin plugin and it works 👍 . Kindly asking for review cortinico :) ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [Android] [Changed] - refactored usage of kotlin plugin Pull Request resolved: facebook#34255 Test Plan: Ran the node ./scripts/run-ci-e2e-tests.js --js --android --ios to verify it doesn't introduce any unexpected issues. Reviewed By: dmitryrykun Differential Revision: D38468567 Pulled By: cortinico fbshipit-source-id: f9ab635fcf033f1d337ed90793ba1667957b8e01
Summary: Fixes facebook#34229 Basically, the react android conflicts with the kotlin version that's defined in the top level build.gradle. To resolve it, the approach was to get the `kotlinVersion` defined in top level build.gradle and use it. If it's not defined, we use the default(1.6.10 as of now). The reason behind not using the DSL is that it doesn't allow us to use the variables due to it's constrained syntax. See [here](https://docs.gradle.org/current/userguide/plugins.html#sec:constrained_syntax) So the idea was to use the build script to resolve the kotlin plugin and it works 👍 . Kindly asking for review cortinico :) ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [Android] [Changed] - refactored usage of kotlin plugin Pull Request resolved: facebook#34255 Test Plan: Ran the node ./scripts/run-ci-e2e-tests.js --js --android --ios to verify it doesn't introduce any unexpected issues. Reviewed By: dmitryrykun Differential Revision: D38468567 Pulled By: cortinico fbshipit-source-id: f9ab635fcf033f1d337ed90793ba1667957b8e01
Included in v0.70.0-rc.3 |
Summary
Fixes #34229
Basically, the react android conflicts with the kotlin version that's defined in the top level build.gradle. To resolve it, the approach was to get the
kotlinVersion
defined in top level build.gradle and use it. If it's not defined, we use the default(1.6.10 as of now).The reason behind not using the DSL is that it doesn't allow us to use the variables due to it's constrained syntax.
See here
So the idea was to use the build script to resolve the kotlin plugin and it works 👍 .
Kindly asking for review @cortinico :)
Changelog
[Android] [Changed] - refactored usage of kotlin plugin
Test Plan
Ran the node ./scripts/run-ci-e2e-tests.js --js --android --ios to verify it doesn't introduce any unexpected issues.