Skip to content

refactor(android): compile files shared with the Android library from one source - #1184

Draft
jnowakow wants to merge 1 commit into
mainfrom
refactor/android-shared-sources-pilot
Draft

jnowakow wants to merge 1 commit into
mainfrom
refactor/android-shared-sources-pilot

Conversation

@jnowakow

Copy link
Copy Markdown
Collaborator

What/Why?

The React Native Android module and packages/enriched-markdown-android keep separate copies of the same Kotlin files, so every fix has to land twice. This is a pilot for sharing them: the 28 files that were byte-identical are deleted from the RN tree and compiled from the library instead. No behavior change.

  • android/shared-sources.txt lists the shared files. Sharing another file is one line there plus deleting the RN copy.
  • android/build.gradle copies exactly the listed files into a generated source dir before compiling. Only listed files are taken, because the rest of the library still has different same-named counterparts in the RN tree.
  • scripts/prepare-npm-publish.sh copies the listed files into android/shared-sources/ at prepack and removes them at postpack, as it already does for cpp/. The build resolves that folder first, then the monorepo path.
  • Library sources are now inputs of the RN Android turbo tasks and CI jobs.

Not covered yet: a build on the module's default toolchain (AGP 8.7, Kotlin 2.0.21) and a full prepack/postpack run.

Testing

Nothing changes on screen, so there is no Playground document for this. Build and run both example apps and check that they look the same as on main:

  • apps/react-native-example: yarn android
  • apps/android-example: ./gradlew installDebug

The Text screen of both apps was captured top to bottom on main and on this branch. 45 of 49 screenshots are byte-identical; the other four differ only around the animated spoiler particles.

To check the published layout, run scripts/prepare-npm-publish.sh prepack, build the RN example (it should compile from android/shared-sources/), then run postpack.

PR Checklist

  • Code compiles and runs on iOS (not touched)
  • Code compiles and runs on Android
  • Updated documentation/README if applicable
  • Ran example app to verify changes
  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

… one source

The React Native Android module kept its own copy of Kotlin files that
also live in packages/enriched-markdown-android. The 28 files that were
byte-identical are now deleted from the RN tree and compiled from the
library instead.

android/shared-sources.txt lists the shared files. build.gradle copies
exactly those into a generated source dir before compiling; the rest of
the library still has different same-named counterparts in the RN tree.
For npm, prepack copies the listed files into android/shared-sources and
postpack removes them, as it already does for cpp/.

Library sources are now inputs of the RN Android turbo tasks and CI jobs.

This branch has not been deployed

No deployments
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.

1 participant