Skip to content

Commit af6e8a2

Browse files
authored
fix(android): fix autolink not generating code in 0.82+ (#2547)
1 parent 974ec4f commit af6e8a2

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

.github/actions/gradle/action.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ runs:
1515
node --eval "require('./android/gradle-wrapper.js').configureGradleWrapper('${{ inputs.project-root }}/android')"
1616
shell: bash
1717
- name: Build
18-
if: ${{ github.event_name != 'schedule' }}
1918
run: ./gradlew ${{ inputs.arguments }}
2019
shell: bash
2120
working-directory: ${{ inputs.project-root }}/android
22-
- name: Build nightly
23-
if: ${{ github.event_name == 'schedule' }}
24-
run: ./gradlew -PnewArchEnabled=true ${{ inputs.arguments }}
25-
shell: bash
26-
working-directory: ${{ inputs.project-root }}/android

test-app.gradle

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,19 @@ ext.applyTestAppModule = { Project project ->
7070
if (reactNativeVersion >= 0 && reactNativeVersion < v(0, 75, 0)) {
7171
importLegacyAutolinkingModule(reactNativeDir)
7272
applyNativeModulesAppBuildGradle(project)
73+
} else if (reactNativeVersion >= v(0, 82, 0)) {
74+
// Ensure community modules can continue using `isNewArchEnabled()` to
75+
// determine whether New Architecture is enabled when it is enabled by
76+
// default in React Native 0.82 and later.
77+
def newArchProps = ["react.newArchEnabled", "newArchEnabled"]
78+
project.gradle.beforeProject { subproject ->
79+
newArchProps.each { prop ->
80+
if (subproject.hasProperty(prop)) {
81+
subproject.setProperty(prop, "true")
82+
}
83+
subproject.ext.set(prop, "true")
84+
}
85+
}
7386
}
7487

7588
def isRntaProject =
@@ -210,4 +223,21 @@ ext.applyTestAppModule = { Project project ->
210223
}
211224
}
212225
}
226+
227+
// Make `:app:preBuild` depend on all subproject `preBuild` tasks to ensure
228+
// all code has been generated before the CMake configuration step.
229+
project.gradle.projectsEvaluated {
230+
def app = project.rootProject.subprojects.find { it.path == ":app" }
231+
def preBuild = app?.tasks?.findByName("preBuild")
232+
if (preBuild != null) {
233+
project.rootProject.subprojects { subproject ->
234+
if (subproject.path != ":app" && subproject.path != ":support") {
235+
def subPreBuild = subproject.tasks.findByName("preBuild")
236+
if (subPreBuild != null) {
237+
preBuild.dependsOn(subPreBuild)
238+
}
239+
}
240+
}
241+
}
242+
}
213243
}

0 commit comments

Comments
 (0)