@react-native/gradle-plugin 0.72.3 → 0.72.5
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/build.gradle.kts +8 -4
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/gradlew +6 -0
- package/gradlew.bat +8 -6
- package/package.json +1 -1
- package/src/main/kotlin/com/facebook/react/TaskConfiguration.kt +4 -2
- package/src/main/kotlin/com/facebook/react/internal/PrivateReactExtension.kt +28 -7
- package/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt +31 -29
- package/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTask.kt +2 -5
- package/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt +4 -1
- package/src/main/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtils.kt +32 -0
- package/src/main/kotlin/com/facebook/react/utils/Os.kt +5 -4
- package/src/main/kotlin/com/facebook/react/utils/PathUtils.kt +12 -5
- package/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt +9 -2
package/build.gradle.kts
CHANGED
|
@@ -11,7 +11,7 @@ import org.gradle.configurationcache.extensions.serviceOf
|
|
|
11
11
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
12
12
|
|
|
13
13
|
plugins {
|
|
14
|
-
kotlin("jvm") version "1.
|
|
14
|
+
kotlin("jvm") version "1.7.22"
|
|
15
15
|
id("java-gradle-plugin")
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -33,7 +33,7 @@ group = "com.facebook.react"
|
|
|
33
33
|
|
|
34
34
|
dependencies {
|
|
35
35
|
implementation(gradleApi())
|
|
36
|
-
implementation("com.android.tools.build:gradle:7.4.
|
|
36
|
+
implementation("com.android.tools.build:gradle:7.4.2")
|
|
37
37
|
implementation("com.google.code.gson:gson:2.8.9")
|
|
38
38
|
implementation("com.google.guava:guava:31.0.1-jre")
|
|
39
39
|
implementation("com.squareup:javapoet:1.13.0")
|
|
@@ -54,8 +54,12 @@ java {
|
|
|
54
54
|
targetCompatibility = JavaVersion.VERSION_11
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
tasks.withType<
|
|
58
|
-
kotlinOptions {
|
|
57
|
+
tasks.withType<KotlinCompile> {
|
|
58
|
+
kotlinOptions {
|
|
59
|
+
jvmTarget = JavaVersion.VERSION_11.majorVersion
|
|
60
|
+
apiVersion = "1.5"
|
|
61
|
+
languageVersion = "1.5"
|
|
62
|
+
}
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
tasks.withType<Test>().configureEach {
|
|
Binary file
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
distributionBase=GRADLE_USER_HOME
|
|
2
2
|
distributionPath=wrapper/dists
|
|
3
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-
|
|
3
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip
|
|
4
4
|
zipStoreBase=GRADLE_USER_HOME
|
|
5
5
|
zipStorePath=wrapper/dists
|
package/gradlew
CHANGED
|
@@ -205,6 +205,12 @@ set -- \
|
|
|
205
205
|
org.gradle.wrapper.GradleWrapperMain \
|
|
206
206
|
"$@"
|
|
207
207
|
|
|
208
|
+
# Stop when "xargs" is not available.
|
|
209
|
+
if ! command -v xargs >/dev/null 2>&1
|
|
210
|
+
then
|
|
211
|
+
die "xargs is not available"
|
|
212
|
+
fi
|
|
213
|
+
|
|
208
214
|
# Use "xargs" to parse quoted args.
|
|
209
215
|
#
|
|
210
216
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
package/gradlew.bat
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
@rem limitations under the License.
|
|
15
15
|
@rem
|
|
16
16
|
|
|
17
|
-
@if "%DEBUG%"
|
|
17
|
+
@if "%DEBUG%"=="" @echo off
|
|
18
18
|
@rem ##########################################################################
|
|
19
19
|
@rem
|
|
20
20
|
@rem Gradle startup script for Windows
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
if "%OS%"=="Windows_NT" setlocal
|
|
26
26
|
|
|
27
27
|
set DIRNAME=%~dp0
|
|
28
|
-
if "%DIRNAME%"
|
|
28
|
+
if "%DIRNAME%"=="" set DIRNAME=.
|
|
29
29
|
set APP_BASE_NAME=%~n0
|
|
30
30
|
set APP_HOME=%DIRNAME%
|
|
31
31
|
|
|
@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|
|
40
40
|
|
|
41
41
|
set JAVA_EXE=java.exe
|
|
42
42
|
%JAVA_EXE% -version >NUL 2>&1
|
|
43
|
-
if
|
|
43
|
+
if %ERRORLEVEL% equ 0 goto execute
|
|
44
44
|
|
|
45
45
|
echo.
|
|
46
46
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
@@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
|
75
75
|
|
|
76
76
|
:end
|
|
77
77
|
@rem End local scope for the variables with windows NT shell
|
|
78
|
-
if
|
|
78
|
+
if %ERRORLEVEL% equ 0 goto mainEnd
|
|
79
79
|
|
|
80
80
|
:fail
|
|
81
81
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
82
82
|
rem the _cmd.exe /c_ return code!
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
set EXIT_CODE=%ERRORLEVEL%
|
|
84
|
+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
|
85
|
+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
|
86
|
+
exit /b %EXIT_CODE%
|
|
85
87
|
|
|
86
88
|
:mainEnd
|
|
87
89
|
if "%OS%"=="Windows_NT" endlocal
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ package com.facebook.react
|
|
|
9
9
|
|
|
10
10
|
import com.android.build.api.variant.Variant
|
|
11
11
|
import com.facebook.react.tasks.BundleHermesCTask
|
|
12
|
+
import com.facebook.react.utils.KotlinStdlibCompatUtils.capitalizeCompat
|
|
12
13
|
import com.facebook.react.utils.NdkConfiguratorUtils.configureJsEnginePackagingOptions
|
|
13
14
|
import com.facebook.react.utils.NdkConfiguratorUtils.configureNewArchPackagingOptions
|
|
14
15
|
import com.facebook.react.utils.ProjectUtils.isHermesEnabled
|
|
@@ -19,7 +20,7 @@ import org.gradle.api.Project
|
|
|
19
20
|
|
|
20
21
|
@Suppress("SpreadOperator", "UnstableApiUsage")
|
|
21
22
|
internal fun Project.configureReactTasks(variant: Variant, config: ReactExtension) {
|
|
22
|
-
val targetName = variant.name.
|
|
23
|
+
val targetName = variant.name.capitalizeCompat()
|
|
23
24
|
val targetPath = variant.name
|
|
24
25
|
|
|
25
26
|
// Resources: generated/assets/react/<variant>/index.android.bundle
|
|
@@ -51,13 +52,14 @@ internal fun Project.configureReactTasks(variant: Variant, config: ReactExtensio
|
|
|
51
52
|
configureJsEnginePackagingOptions(config, variant, isHermesEnabledInThisVariant)
|
|
52
53
|
|
|
53
54
|
if (!isDebuggableVariant) {
|
|
55
|
+
val entryFileEnvVariable = System.getenv("ENTRY_FILE")
|
|
54
56
|
val bundleTask =
|
|
55
57
|
tasks.register("createBundle${targetName}JsAndAssets", BundleHermesCTask::class.java) {
|
|
56
58
|
it.root.set(config.root)
|
|
57
59
|
it.nodeExecutableAndArgs.set(config.nodeExecutableAndArgs)
|
|
58
60
|
it.cliFile.set(cliFile)
|
|
59
61
|
it.bundleCommand.set(config.bundleCommand)
|
|
60
|
-
it.entryFile.set(detectedEntryFile(config))
|
|
62
|
+
it.entryFile.set(detectedEntryFile(config, entryFileEnvVariable))
|
|
61
63
|
it.extraPackagerArgs.set(config.extraPackagerArgs)
|
|
62
64
|
it.bundleConfig.set(config.bundleConfig)
|
|
63
65
|
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 =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
}
|
|
@@ -133,35 +133,37 @@ abstract class BundleHermesCTask : DefaultTask() {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
internal fun getBundleCommand(bundleFile: File, sourceMapFile: File): List<Any>
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
136
|
+
internal fun getBundleCommand(bundleFile: File, sourceMapFile: File): List<Any> {
|
|
137
|
+
val rootFile = root.get().asFile
|
|
138
|
+
val commandLine =
|
|
139
|
+
mutableListOf<String>().apply {
|
|
140
|
+
addAll(nodeExecutableAndArgs.get())
|
|
141
|
+
add(cliFile.get().asFile.cliPath(rootFile))
|
|
142
|
+
add(bundleCommand.get())
|
|
143
|
+
add("--platform")
|
|
144
|
+
add("android")
|
|
145
|
+
add("--dev")
|
|
146
|
+
add(devEnabled.get().toString())
|
|
147
|
+
add("--reset-cache")
|
|
148
|
+
add("--entry-file")
|
|
149
|
+
add(entryFile.get().asFile.cliPath(rootFile))
|
|
150
|
+
add("--bundle-output")
|
|
151
|
+
add(bundleFile.cliPath(rootFile))
|
|
152
|
+
add("--assets-dest")
|
|
153
|
+
add(resourcesDir.get().asFile.cliPath(rootFile))
|
|
154
|
+
add("--sourcemap-output")
|
|
155
|
+
add(sourceMapFile.cliPath(rootFile))
|
|
156
|
+
if (bundleConfig.isPresent) {
|
|
157
|
+
add("--config")
|
|
158
|
+
add(bundleConfig.get().asFile.cliPath(rootFile))
|
|
159
|
+
}
|
|
160
|
+
add("--minify")
|
|
161
|
+
add(minifyEnabled.get().toString())
|
|
162
|
+
addAll(extraPackagerArgs.get())
|
|
163
|
+
add("--verbose")
|
|
164
|
+
}
|
|
165
|
+
return windowsAwareCommandLine(commandLine)
|
|
166
|
+
}
|
|
165
167
|
|
|
166
168
|
internal fun getHermescCommand(
|
|
167
169
|
hermesCommand: String,
|
|
@@ -38,13 +38,10 @@ abstract class GenerateCodegenSchemaTask : Exec() {
|
|
|
38
38
|
// Those are known build paths where the source map or other
|
|
39
39
|
// .js files could be stored/generated. We want to make sure we don't pick them up
|
|
40
40
|
// for execution avoidance.
|
|
41
|
-
it.exclude("**/generated/source/codegen/**/*")
|
|
42
41
|
it.exclude("**/build/ASSETS/**/*")
|
|
43
42
|
it.exclude("**/build/RES/**/*")
|
|
44
|
-
it.exclude("**/build/generated
|
|
45
|
-
it.exclude("**/build/
|
|
46
|
-
it.exclude("**/build/generated/sourcemaps/react/**/*")
|
|
47
|
-
it.exclude("**/build/intermediates/sourcemaps/react/**/*")
|
|
43
|
+
it.exclude("**/build/generated/**/*")
|
|
44
|
+
it.exclude("**/build/intermediates/**/*")
|
|
48
45
|
}
|
|
49
46
|
|
|
50
47
|
@get:OutputFile
|
|
@@ -28,7 +28,10 @@ internal object DependencyUtils {
|
|
|
28
28
|
}
|
|
29
29
|
// We add the snapshot for users on nightlies.
|
|
30
30
|
mavenRepoFromUrl("https://oss.sonatype.org/content/repositories/snapshots/")
|
|
31
|
-
repositories.mavenCentral
|
|
31
|
+
repositories.mavenCentral { repo ->
|
|
32
|
+
// We don't want to fetch JSC from Maven Central as there are older versions there.
|
|
33
|
+
repo.content { it.excludeModule("org.webkit", "android-jsc") }
|
|
34
|
+
}
|
|
32
35
|
// Android JSC is installed from npm
|
|
33
36
|
mavenRepoFromURI(File(reactNativeDir, "../jsc-android/dist").toURI())
|
|
34
37
|
repositories.google()
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
package com.facebook.react.utils
|
|
9
|
+
|
|
10
|
+
import java.util.Locale
|
|
11
|
+
|
|
12
|
+
object KotlinStdlibCompatUtils {
|
|
13
|
+
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
|
14
|
+
fun String.lowercaseCompat(): String = (this as java.lang.String).toLowerCase(Locale.ROOT)
|
|
15
|
+
|
|
16
|
+
fun String.capitalizeCompat(): String =
|
|
17
|
+
if (isNotEmpty()) {
|
|
18
|
+
val firstChar = this[0]
|
|
19
|
+
val uppercaseChar = Character.toUpperCase(firstChar)
|
|
20
|
+
val restString = this@capitalizeCompat.substring(1)
|
|
21
|
+
uppercaseChar + restString
|
|
22
|
+
} else {
|
|
23
|
+
this
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
fun String.toBooleanStrictOrNullCompat(): Boolean? =
|
|
27
|
+
when (this) {
|
|
28
|
+
"true" -> true
|
|
29
|
+
"false" -> false
|
|
30
|
+
else -> null
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -7,18 +7,19 @@
|
|
|
7
7
|
|
|
8
8
|
package com.facebook.react.utils
|
|
9
9
|
|
|
10
|
+
import com.facebook.react.utils.KotlinStdlibCompatUtils.lowercaseCompat
|
|
10
11
|
import java.io.File
|
|
11
12
|
|
|
12
13
|
internal object Os {
|
|
13
14
|
|
|
14
15
|
fun isWindows(): Boolean =
|
|
15
|
-
System.getProperty("os.name")?.
|
|
16
|
+
System.getProperty("os.name")?.lowercaseCompat()?.contains("windows") ?: false
|
|
16
17
|
|
|
17
|
-
fun isMac(): Boolean = System.getProperty("os.name")?.
|
|
18
|
+
fun isMac(): Boolean = System.getProperty("os.name")?.lowercaseCompat()?.contains("mac") ?: false
|
|
18
19
|
|
|
19
20
|
fun isLinuxAmd64(): Boolean {
|
|
20
|
-
val osNameMatch = System.getProperty("os.name")?.
|
|
21
|
-
val archMatch = System.getProperty("os.arch")?.
|
|
21
|
+
val osNameMatch = System.getProperty("os.name")?.lowercaseCompat()?.contains("linux") ?: false
|
|
22
|
+
val archMatch = System.getProperty("os.arch")?.lowercaseCompat()?.contains("amd64") ?: false
|
|
22
23
|
return osNameMatch && archMatch
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -11,6 +11,7 @@ package com.facebook.react.utils
|
|
|
11
11
|
|
|
12
12
|
import com.facebook.react.ReactExtension
|
|
13
13
|
import com.facebook.react.model.ModelPackageJson
|
|
14
|
+
import com.facebook.react.utils.KotlinStdlibCompatUtils.capitalizeCompat
|
|
14
15
|
import com.facebook.react.utils.Os.cliPath
|
|
15
16
|
import java.io.File
|
|
16
17
|
import org.gradle.api.Project
|
|
@@ -25,9 +26,11 @@ import org.gradle.api.file.DirectoryProperty
|
|
|
25
26
|
*
|
|
26
27
|
* @param config The [ReactExtension] configured for this project
|
|
27
28
|
*/
|
|
28
|
-
internal fun detectedEntryFile(config: ReactExtension): File =
|
|
29
|
+
internal fun detectedEntryFile(config: ReactExtension, envVariableOverride: String? = null): File =
|
|
29
30
|
detectEntryFile(
|
|
30
|
-
entryFile = config.entryFile.orNull?.asFile,
|
|
31
|
+
entryFile = config.entryFile.orNull?.asFile,
|
|
32
|
+
reactRoot = config.root.get().asFile,
|
|
33
|
+
envVariableOverride = envVariableOverride)
|
|
31
34
|
|
|
32
35
|
/**
|
|
33
36
|
* Computes the CLI file for React Native. The Algo follows this order:
|
|
@@ -54,9 +57,13 @@ internal fun detectedCliFile(config: ReactExtension): File =
|
|
|
54
57
|
internal fun detectedHermesCommand(config: ReactExtension): String =
|
|
55
58
|
detectOSAwareHermesCommand(config.root.get().asFile, config.hermesCommand.get())
|
|
56
59
|
|
|
57
|
-
private fun detectEntryFile(
|
|
60
|
+
private fun detectEntryFile(
|
|
61
|
+
entryFile: File?,
|
|
62
|
+
reactRoot: File,
|
|
63
|
+
envVariableOverride: String? = null
|
|
64
|
+
): File =
|
|
58
65
|
when {
|
|
59
|
-
|
|
66
|
+
envVariableOverride != null -> File(reactRoot, envVariableOverride)
|
|
60
67
|
entryFile != null -> entryFile
|
|
61
68
|
File(reactRoot, "index.android.js").exists() -> File(reactRoot, "index.android.js")
|
|
62
69
|
else -> File(reactRoot, "index.js")
|
|
@@ -182,7 +189,7 @@ internal fun getHermesOSBin(): String {
|
|
|
182
189
|
internal fun projectPathToLibraryName(projectPath: String): String =
|
|
183
190
|
projectPath
|
|
184
191
|
.split(':', '-', '_', '.')
|
|
185
|
-
.joinToString("") { token -> token.
|
|
192
|
+
.joinToString("") { token -> token.capitalizeCompat() }
|
|
186
193
|
.plus("Spec")
|
|
187
194
|
|
|
188
195
|
/**
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
package com.facebook.react.utils
|
|
9
9
|
|
|
10
10
|
import com.facebook.react.model.ModelPackageJson
|
|
11
|
+
import com.facebook.react.utils.KotlinStdlibCompatUtils.lowercaseCompat
|
|
12
|
+
import com.facebook.react.utils.KotlinStdlibCompatUtils.toBooleanStrictOrNullCompat
|
|
11
13
|
import org.gradle.api.Project
|
|
12
14
|
import org.gradle.api.file.DirectoryProperty
|
|
13
15
|
|
|
@@ -22,13 +24,18 @@ internal object ProjectUtils {
|
|
|
22
24
|
internal val Project.isHermesEnabled: Boolean
|
|
23
25
|
get() =
|
|
24
26
|
if (project.hasProperty("hermesEnabled")) {
|
|
25
|
-
project
|
|
27
|
+
project
|
|
28
|
+
.property("hermesEnabled")
|
|
29
|
+
.toString()
|
|
30
|
+
.lowercaseCompat()
|
|
31
|
+
.toBooleanStrictOrNullCompat()
|
|
32
|
+
?: true
|
|
26
33
|
} else if (project.extensions.extraProperties.has("react")) {
|
|
27
34
|
@Suppress("UNCHECKED_CAST")
|
|
28
35
|
val reactMap = project.extensions.extraProperties.get("react") as? Map<String, Any?>
|
|
29
36
|
when (val enableHermesKey = reactMap?.get("enableHermes")) {
|
|
30
37
|
is Boolean -> enableHermesKey
|
|
31
|
-
is String -> enableHermesKey.
|
|
38
|
+
is String -> enableHermesKey.lowercaseCompat().toBooleanStrictOrNullCompat() ?: true
|
|
32
39
|
else -> HERMES_FALLBACK
|
|
33
40
|
}
|
|
34
41
|
} else {
|