Skip to content

Commit f86aa43

Browse files
authored
refactor: remove unnecessary checks for new arch (#791)
Since we no longer have a backward compatible template, these checks are no longer necessary.
1 parent 711e9ea commit f86aa43

File tree

2 files changed

+24
-38
lines changed

2 files changed

+24
-38
lines changed

packages/create-react-native-library/src/exampleApp/addCodegenBuildScript.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,25 @@ import fs from 'fs-extra';
33

44
// This is added to the example app's build.gradle file to invoke codegen before every build
55
const GRADLE_INVOKE_CODEGEN_TASK = `
6-
def isNewArchitectureEnabled() {
7-
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
6+
// Run Codegen during development for the example app.
7+
tasks.register('invokeLibraryCodegen', Exec) {
8+
workingDir "$rootDir/../../"
9+
def isWindows = System.getProperty('os.name').toLowerCase().contains('windows')
10+
11+
if (isWindows) {
12+
commandLine 'cmd', '/c', 'npx bob build --target codegen'
13+
} else {
14+
commandLine 'sh', '-c', 'npx bob build --target codegen'
15+
}
816
}
917
10-
if (isNewArchitectureEnabled()) {
11-
// Since our library doesn't invoke codegen automatically we need to do it here.
12-
tasks.register('invokeLibraryCodegen', Exec) {
13-
workingDir "$rootDir/../../"
14-
def isWindows = System.getProperty('os.name').toLowerCase().contains('windows')
15-
16-
if (isWindows) {
17-
commandLine 'cmd', '/c', 'npx bob build --target codegen'
18-
} else {
19-
commandLine 'sh', '-c', 'npx bob build --target codegen'
20-
}
21-
}
22-
preBuild.dependsOn invokeLibraryCodegen
23-
}`;
18+
preBuild.dependsOn invokeLibraryCodegen
19+
`;
2420

2521
// You need to have the files before calling pod install otherwise they won't be registered in your pod.
2622
// So we add a pre_install hook to the podfile that invokes codegen
2723
const PODSPEC_INVOKE_CODEGEN_SCRIPT = `
24+
# Run Codegen during development for the example app.
2825
pre_install do |installer|
2926
system("cd ../../ && npx bob build --target codegen")
3027
end

packages/create-react-native-library/templates/native-common/android/build.gradle

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,15 @@ def reactNativeArchitectures() {
2222
}
2323
<% } -%>
2424

25-
def isNewArchitectureEnabled() {
26-
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
27-
}
28-
2925
apply plugin: "com.android.library"
3026
apply plugin: "kotlin-android"
3127
<% if (project.moduleConfig === 'nitro-modules') { -%>
3228
apply from: '../nitrogen/generated/android/<%- project.package_cpp -%>+autolinking.gradle'
3329
<% } -%>
3430

35-
if (isNewArchitectureEnabled()) {
36-
apply plugin: "com.facebook.react"
37-
}
31+
<% if (project.arch === "new") { -%>
32+
apply plugin: "com.facebook.react"
33+
<% } -%>
3834

3935
def getExtOrIntegerDefault(name) {
4036
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["<%- project.name -%>_" + name]).toInteger()
@@ -72,9 +68,6 @@ android {
7268
defaultConfig {
7369
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
7470
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
75-
<% if (project.arch === "new") { -%>
76-
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
77-
<% } -%>
7871
<% if (project.cpp || project.moduleConfig === 'nitro-modules') { -%>
7972

8073
externalNativeBuild {
@@ -154,12 +147,10 @@ android {
154147

155148
sourceSets {
156149
main {
157-
if (isNewArchitectureEnabled()) {
158-
java.srcDirs += [
159-
"generated/java",
160-
"generated/jni"
161-
]
162-
}
150+
java.srcDirs += [
151+
"generated/java",
152+
"generated/jni"
153+
]
163154
}
164155
}
165156
<% } -%>
@@ -181,11 +172,9 @@ dependencies {
181172
}
182173

183174
<% if (project.moduleConfig === "turbo-modules" || project.viewConfig === "fabric-view") { -%>
184-
if (isNewArchitectureEnabled()) {
185-
react {
186-
jsRootDir = file("../src/")
187-
libraryName = "<%- project.viewConfig !== null ? project.name + 'View' : project.name -%>"
188-
codegenJavaPackageName = "com.<%- project.package -%>"
189-
}
175+
react {
176+
jsRootDir = file("../src/")
177+
libraryName = "<%- project.viewConfig !== null ? project.name + 'View' : project.name -%>"
178+
codegenJavaPackageName = "com.<%- project.package -%>"
190179
}
191180
<% } -%>

0 commit comments

Comments
 (0)