-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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 regression in Android unlink command #21043
Fix regression in Android unlink command #21043
Conversation
Commit 4dfdec9 introduced a regression in the `unlink` command for Android projects: native modules previously linked with the now-deprecated `compile` configuration will not be detected anymore and by extension will not be unlinked. `unlink` should be aware of both new and deprecated options to ensure functionality also in existing projects that previously linked modules with the old convention. This commit fixes the regression by: - first, `makeDeprecatedNativeModule` is added so to have the deprecated patch line that could be present in the Gradle build file. - updating the Android `isInstalled` to check, for a given package name, for both `compile` and `implementation` dependencies records in `build.gradle`. - Android `unregisterNativeModule` will proceed to revoke both possible patch lines from `build.gradle`.
Summary: Motivation: -------------- PR #20767 bumped the version of the Android Gradle Plugin to v3 which uses the newer Gradle dependency configurations `implementation` and `api` which make `compile` obsolete. While the PR updated the template Gradle configuration, it did not cover the `link` command which will still link native modules using `compile` resulting in a warning message beeing displayed during an app build. Since `compile` will be eventually removed by Gradle, this commit updates the `link` command to attach native modules using `implementation`. Pull Request resolved: #20853 Differential Revision: D9733888 Pulled By: hramos fbshipit-source-id: 22853480d7ba7be65e3387effda2fd6c72b6906a
@grabbou since your proposal passed (congrats 🎉), shall we postpone this until we separate the CLI or proceed as always? |
Thank you for your PR. We just moved this code to https://github.com/react-native-community/react-native-cli so please submit your PR there. |
Hey @matt-block! Thanks for submitting this PR! Apologies for not getting back, but the whole CLI extraction process got me super busy with other notifications. We ended up fixing this bug in the CLI with this PR: react-native-community/cli#81 which takes a slightly different approach compared to your take. Would love to hear your opinion about that take - please feel free to comment on the PR or message me! |
Motivation:
Commit 4dfdec9 introduced a regression in the
unlink
command for Android projects: native modules previously linked with the now-deprecatedcompile
configuration will not be detected anymore and by extension will not be unlinked.unlink
should be aware of both new and deprecated options to ensure functionality also in existing projects that previously linked modules with the old convention.This PR fixes the regression by:
makeDeprecatedNativeModule
is added so to have the deprecated patch line that could be present in the Gradle build file.isInstalled
to check, for a given package name, for bothcompile
(using the function introduced in step 1) andimplementation
dependency records inbuild.gradle
.unregisterNativeModule
will proceed to revoke both possible patch lines frombuild.gradle
.This PR together with commit 4dfdec9 provide the following behaviour:
link
will continue to work as intended usingimplementation
. This works without issues even with older packages that still usecompile
internally for their own dependencies.link
will detect previously linked packages withcompile
and will not proceed with a new linkage. Instead, it will log thatPlatform 'android' module X is already linked
.unlink
will detect dependencies with bothcompile
andimplementation
and proceed to unlink as expected.Test Plan:
compile
and the described behaviour listed above was matched.Related PRs:
Release Notes:
[CLI] [BUGFIX] [local-cli/link] - Fixed regression in Android
unlink
.