Commit 622e8c3
authored
fix: stop an app's codegenConfig from hijacking this library's codegen (#201)
## Problem
When an app adds a TurboModule of its own and puts `codegenConfig` in
its root package.json, that config is applied to this library's codegen
instead of the library's own. `NativeCodePushSpec` is never generated,
the app's spec is written into the library's build directory, and
compilation fails:
```
node_modules/@bravemobile/react-native-code-push/android/app/src/main/java/
com/microsoft/codepush/react/CodePushNativeModule.java:44:
error: cannot find symbol
public class CodePushNativeModule extends NativeCodePushSpec {
```
The react-native gradle plugin's `findPackageJsonFile()` looks for
`../package.json` next to the gradle module first and falls back to the
app root when that file is missing. This library's module sat at
`android/app`, so the first lookup never resolved and the app root was
always read. It only stayed invisible while apps had no `codegenConfig`
of their own.
## Fix
The gradle module now lives at `android/`. The first lookup resolves to
the library's own package.json, which already carries the correct
`codegenConfig`. No second copy of the config is introduced, and this is
the layout most React Native libraries already use.
A separate commit removes the standalone gradle setup, which had stopped
working long ago: the wrapper pinned Gradle 2.4, the buildscript
classpath pinned AGP 1.3.0, `gradle.properties` was in a subproject
directory where Gradle never reads it, and Android unit tests run
through an example app. None of those files were reachable from any
build.
## Upgrading
An existing app holds an autolinking cache pointing at the old path, so
the first build after upgrading fails:
```
Configuring project ':bravemobile_react-native-code-push' without an existing directory is not allowed.
The configured projectDirectory '.../react-native-code-push/android/app' does not exist
```
Deleting these two directories clears it:
```
android/build/generated/autolinking
android/app/build/generated/autolinking
```
Nothing else changes for consumers. The gradle project name stays
`:bravemobile_react-native-code-push` because it is derived from the npm
package name, and the apply path for `codepush-export.gradle` is
untouched.
## Verification
codegen, Java compilation, unit tests and the CMake native build all
pass on the RN 0.77.3, 0.80.3, 0.83.2 and 0.86.0 example apps, covering
both ends of the supported range.
The reproduction case was checked on the lowest and highest versions:
with `codegenConfig` present in the app root, `NativeCodePushSpec.java`
is generated for the library and the app's own spec is generated for the
app module, each in its own place.1 parent 3c304b5 commit 622e8c3
47 files changed
Lines changed: 53 additions & 361 deletions
File tree
- android
- app
- gradle/wrapper
- src
- debug
- main
- cpp
- java/com/microsoft/codepush/react
- test/java/com/microsoft/codepush/react
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
| 157 | + | |
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
2 | 3 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
7 | 26 | | |
8 | | - | |
9 | | - | |
10 | 27 | | |
11 | | - | |
12 | | - | |
| 28 | + | |
| 29 | + | |
13 | 30 | | |
14 | | - | |
15 | 31 | | |
16 | | - | |
17 | | - | |
18 | | - | |
| 32 | + | |
| 33 | + | |
19 | 34 | | |
20 | | - | |
21 | | - | |
22 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
23 | 48 | | |
24 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
This file was deleted.
Binary file not shown.
This file was deleted.
This file was deleted.
0 commit comments