@react-native/gradle-plugin 0.72.3 → 0.72.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/gradle-plugin",
3
- "version": "0.72.3",
3
+ "version": "0.72.4",
4
4
  "description": "⚛️ Gradle Plugin for React Native",
5
5
  "homepage": "https://github.com/facebook/react-native/tree/HEAD/packages/react-native-gradle-plugin",
6
6
  "repository": {
@@ -51,13 +51,14 @@ internal fun Project.configureReactTasks(variant: Variant, config: ReactExtensio
51
51
  configureJsEnginePackagingOptions(config, variant, isHermesEnabledInThisVariant)
52
52
 
53
53
  if (!isDebuggableVariant) {
54
+ val entryFileEnvVariable = System.getenv("ENTRY_FILE")
54
55
  val bundleTask =
55
56
  tasks.register("createBundle${targetName}JsAndAssets", BundleHermesCTask::class.java) {
56
57
  it.root.set(config.root)
57
58
  it.nodeExecutableAndArgs.set(config.nodeExecutableAndArgs)
58
59
  it.cliFile.set(cliFile)
59
60
  it.bundleCommand.set(config.bundleCommand)
60
- it.entryFile.set(detectedEntryFile(config))
61
+ it.entryFile.set(detectedEntryFile(config, entryFileEnvVariable))
61
62
  it.extraPackagerArgs.set(config.extraPackagerArgs)
62
63
  it.bundleConfig.set(config.bundleConfig)
63
64
  it.bundleAssetName.set(config.bundleAssetName)
@@ -25,11 +25,32 @@ abstract class PrivateReactExtension @Inject constructor(project: Project) {
25
25
 
26
26
  private val objects = project.objects
27
27
 
28
- val root: DirectoryProperty = objects.directoryProperty()
29
-
30
- val reactNativeDir: DirectoryProperty = objects.directoryProperty()
31
-
32
- val nodeExecutableAndArgs: ListProperty<String> = objects.listProperty(String::class.java)
33
-
34
- val codegenDir: DirectoryProperty = objects.directoryProperty()
28
+ val root: DirectoryProperty =
29
+ objects
30
+ .directoryProperty()
31
+ .convention(
32
+ // This is the default for the project root if the users hasn't specified anything.
33
+ // If the project is called "react-native-github"
34
+ // - We're inside the Github Repo -> root is defined by RN Tester (so no default
35
+ // needed)
36
+ // - We're inside an includedBuild as we're performing a build from source
37
+ // (then we're inside `node_modules/react-native`, so default should be ../../)
38
+ // If the project is called in any other name
39
+ // - We're inside a user project, so inside the ./android folder. Default should be
40
+ // ../
41
+ // User can always override this default by setting a `root =` inside the template.
42
+ if (project.rootProject.name == "react-native-github") {
43
+ project.rootProject.layout.projectDirectory.dir("../../")
44
+ } else {
45
+ project.rootProject.layout.projectDirectory.dir("../")
46
+ })
47
+
48
+ val reactNativeDir: DirectoryProperty =
49
+ objects.directoryProperty().convention(root.dir("node_modules/react-native"))
50
+
51
+ val nodeExecutableAndArgs: ListProperty<String> =
52
+ objects.listProperty(String::class.java).convention(listOf("node"))
53
+
54
+ val codegenDir: DirectoryProperty =
55
+ objects.directoryProperty().convention(root.dir("node_modules/@react-native/codegen"))
35
56
  }
@@ -25,9 +25,11 @@ import org.gradle.api.file.DirectoryProperty
25
25
  *
26
26
  * @param config The [ReactExtension] configured for this project
27
27
  */
28
- internal fun detectedEntryFile(config: ReactExtension): File =
28
+ internal fun detectedEntryFile(config: ReactExtension, envVariableOverride: String? = null): File =
29
29
  detectEntryFile(
30
- entryFile = config.entryFile.orNull?.asFile, reactRoot = config.root.get().asFile)
30
+ entryFile = config.entryFile.orNull?.asFile,
31
+ reactRoot = config.root.get().asFile,
32
+ envVariableOverride = envVariableOverride)
31
33
 
32
34
  /**
33
35
  * Computes the CLI file for React Native. The Algo follows this order:
@@ -54,9 +56,13 @@ internal fun detectedCliFile(config: ReactExtension): File =
54
56
  internal fun detectedHermesCommand(config: ReactExtension): String =
55
57
  detectOSAwareHermesCommand(config.root.get().asFile, config.hermesCommand.get())
56
58
 
57
- private fun detectEntryFile(entryFile: File?, reactRoot: File): File =
59
+ private fun detectEntryFile(
60
+ entryFile: File?,
61
+ reactRoot: File,
62
+ envVariableOverride: String? = null
63
+ ): File =
58
64
  when {
59
- System.getenv("ENTRY_FILE") != null -> File(System.getenv("ENTRY_FILE"))
65
+ envVariableOverride != null -> File(reactRoot, envVariableOverride)
60
66
  entryFile != null -> entryFile
61
67
  File(reactRoot, "index.android.js").exists() -> File(reactRoot, "index.android.js")
62
68
  else -> File(reactRoot, "index.js")