@ohos-ports/react-native-gradle-plugin 0.71.19-beta.0 → 0.86.0-beta.0
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/README.md +11 -4
- package/build.gradle.kts +33 -41
- package/gradle/libs.versions.toml +22 -0
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +3 -1
- package/gradle.properties +2 -0
- package/gradlew +32 -18
- package/gradlew.bat +22 -18
- package/package.json +21 -11
- package/react-native-gradle-plugin/README.md +17 -0
- package/react-native-gradle-plugin/build.gradle.kts +83 -0
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/ReactExtension.kt +78 -10
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt +320 -0
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactRootProjectPlugin.kt +86 -0
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/TaskConfiguration.kt +36 -25
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/internal/PrivateReactExtension.kt +11 -4
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt +60 -50
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateAutolinkingNewArchitecturesFileTask.kt +252 -0
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTask.kt +8 -3
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTask.kt +11 -18
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateEntryPointTask.kt +108 -0
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GeneratePackageListTask.kt +214 -0
- package/{src/main/kotlin/com/facebook/react/tasks → react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal}/BuildCodegenCLITask.kt +24 -17
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/CustomExecTask.kt +46 -0
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/tasks/internal/PrepareBoostTask.kt +10 -4
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareGflagsTask.kt +119 -0
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/tasks/internal/PrepareGlogTask.kt +26 -18
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/tasks/internal/PreparePrefabHeadersTask.kt +28 -12
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/tasks/internal/utils/PrefabPreprocessingEntry.kt +4 -3
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/AgpConfiguratorUtils.kt +163 -0
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/BackwardCompatUtils.kt +71 -0
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt +299 -0
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/JdkConfiguratorUtils.kt +64 -0
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/utils/NdkConfiguratorUtils.kt +59 -65
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/utils/PathUtils.kt +44 -30
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt +119 -0
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt +96 -0
- package/settings-plugin/build.gradle.kts +73 -0
- package/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt +217 -0
- package/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsPlugin.kt +23 -0
- package/settings-plugin/src/test/kotlin/com/facebook/react/ReactSettingsExtensionTest.kt +475 -0
- package/settings.gradle.kts +10 -1
- package/shared/build.gradle.kts +52 -0
- package/shared/src/main/kotlin/com/facebook/react/model/ModelAutolinkingAndroidProjectJson.kt +18 -0
- package/shared/src/main/kotlin/com/facebook/react/model/ModelAutolinkingConfigJson.kt +14 -0
- package/shared/src/main/kotlin/com/facebook/react/model/ModelAutolinkingDependenciesJson.kt +18 -0
- package/shared/src/main/kotlin/com/facebook/react/model/ModelAutolinkingDependenciesPlatformAndroidJson.kt +23 -0
- package/shared/src/main/kotlin/com/facebook/react/model/ModelAutolinkingDependenciesPlatformJson.kt +12 -0
- package/shared/src/main/kotlin/com/facebook/react/model/ModelAutolinkingProjectJson.kt +10 -0
- package/{src → shared/src}/main/kotlin/com/facebook/react/model/ModelCodegenConfig.kt +2 -1
- package/{src → shared/src}/main/kotlin/com/facebook/react/model/ModelPackageJson.kt +1 -1
- package/shared/src/main/kotlin/com/facebook/react/utils/JsonUtils.kt +43 -0
- package/shared/src/main/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtils.kt +32 -0
- package/{src → shared/src}/main/kotlin/com/facebook/react/utils/Os.kt +7 -6
- package/{src → shared/src}/main/kotlin/com/facebook/react/utils/TaskUtils.kt +4 -5
- package/shared/src/test/kotlin/com/facebook/react/utils/JsonUtilsTest.kt +382 -0
- package/shared/src/test/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtilsTest.kt +82 -0
- package/shared/src/test/kotlin/com/facebook/react/utils/OsTest.kt +87 -0
- package/shared/src/test/kotlin/com/facebook/react/utils/TaskUtilsTest.kt +76 -0
- package/shared-testutil/build.gradle.kts +46 -0
- package/shared-testutil/src/main/kotlin/com/facebook/react/tests/OsRule.kt +52 -0
- package/shared-testutil/src/main/kotlin/com/facebook/react/tests/WithOs.kt +17 -0
- package/build/libs/react-native-gradle-plugin.jar +0 -0
- package/index.js +0 -73
- package/src/main/kotlin/com/facebook/react/ReactPlugin.kt +0 -212
- package/src/main/kotlin/com/facebook/react/tasks/internal/PrepareJSCTask.kt +0 -50
- package/src/main/kotlin/com/facebook/react/tasks/internal/PrepareLibeventTask.kt +0 -51
- package/src/main/kotlin/com/facebook/react/utils/AgpConfiguratorUtils.kt +0 -54
- package/src/main/kotlin/com/facebook/react/utils/BackwardCompatUtils.kt +0 -48
- package/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt +0 -109
- package/src/main/kotlin/com/facebook/react/utils/JsonUtils.kt +0 -21
- package/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt +0 -55
- /package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/utils/FileUtils.kt +0 -0
- /package/{src → shared/src}/main/kotlin/com/facebook/react/model/ModelCodegenConfigAndroid.kt +0 -0
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# react-native
|
|
1
|
+
# @react-native/gradle-plugin
|
|
2
2
|
|
|
3
3
|
[![Version][version-badge]][package]
|
|
4
4
|
|
|
@@ -7,10 +7,17 @@ A Gradle Plugin used to support development of React Native applications for And
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
yarn add react-native
|
|
10
|
+
yarn add @react-native/gradle-plugin
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
*Note: We're using `yarn` to install deps. Feel free to change commands to use `npm` 3+ and `npx` if you like*
|
|
14
14
|
|
|
15
|
-
[version-badge]: https://img.shields.io/npm/v
|
|
16
|
-
[package]: https://www.npmjs.com/package
|
|
15
|
+
[version-badge]: https://img.shields.io/npm/v/@react-native/gradle-plugin?style=flat-square
|
|
16
|
+
[package]: https://www.npmjs.com/package/@react-native/gradle-plugin
|
|
17
|
+
|
|
18
|
+
## Testing
|
|
19
|
+
|
|
20
|
+
To run the tests in this package, run the following commands from the React Native root folder:
|
|
21
|
+
|
|
22
|
+
1. `yarn` to install the dependencies. You just need to run this once
|
|
23
|
+
2. `./gradlew -p packages/gradle-plugin test`.
|
package/build.gradle.kts
CHANGED
|
@@ -5,55 +5,47 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
9
|
-
|
|
10
8
|
plugins {
|
|
11
|
-
kotlin
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
repositories {
|
|
16
|
-
google()
|
|
17
|
-
mavenCentral()
|
|
9
|
+
alias(libs.plugins.kotlin.jvm).apply(false)
|
|
10
|
+
alias(libs.plugins.ktfmt).apply(true)
|
|
18
11
|
}
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
tasks.register("build") {
|
|
14
|
+
dependsOn(
|
|
15
|
+
":react-native-gradle-plugin:build",
|
|
16
|
+
":settings-plugin:build",
|
|
17
|
+
":shared-testutil:build",
|
|
18
|
+
":shared:build",
|
|
19
|
+
)
|
|
27
20
|
}
|
|
28
21
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
implementation("com.squareup:javapoet:1.13.0")
|
|
37
|
-
|
|
38
|
-
testImplementation("junit:junit:4.13.2")
|
|
22
|
+
tasks.register("clean") {
|
|
23
|
+
dependsOn(
|
|
24
|
+
":react-native-gradle-plugin:clean",
|
|
25
|
+
":settings-plugin:clean",
|
|
26
|
+
":shared-testutil:clean",
|
|
27
|
+
":shared:clean",
|
|
28
|
+
)
|
|
39
29
|
}
|
|
40
30
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
31
|
+
tasks.named("ktfmtCheck") {
|
|
32
|
+
dependsOn(
|
|
33
|
+
":react-native-gradle-plugin:ktfmtCheck",
|
|
34
|
+
":settings-plugin:ktfmtCheck",
|
|
35
|
+
":shared-testutil:ktfmtCheck",
|
|
36
|
+
":shared:ktfmtCheck",
|
|
37
|
+
)
|
|
44
38
|
}
|
|
45
39
|
|
|
46
|
-
tasks.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
tasks.named("ktfmtFormat") {
|
|
41
|
+
dependsOn(
|
|
42
|
+
":react-native-gradle-plugin:ktfmtFormat",
|
|
43
|
+
":settings-plugin:ktfmtFormat",
|
|
44
|
+
":shared-testutil:ktfmtFormat",
|
|
45
|
+
":shared:ktfmtFormat",
|
|
46
|
+
)
|
|
50
47
|
}
|
|
51
48
|
|
|
52
|
-
tasks
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
showExceptions = true
|
|
56
|
-
showCauses = true
|
|
57
|
-
showStackTraces = true
|
|
58
|
-
}
|
|
59
|
-
}
|
|
49
|
+
// We intentionally disable the `ktfmtCheck` tasks as the formatting is primarly handled inside
|
|
50
|
+
// fbsource
|
|
51
|
+
allprojects { tasks.withType<com.ncorti.ktfmt.gradle.tasks.KtfmtCheckTask>() { enabled = false } }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[versions]
|
|
2
|
+
agp = "8.12.0"
|
|
3
|
+
gson = "2.8.9"
|
|
4
|
+
guava = "31.0.1-jre"
|
|
5
|
+
javapoet = "1.13.0"
|
|
6
|
+
junit = "4.13.2"
|
|
7
|
+
kotlin = "2.1.20"
|
|
8
|
+
assertj = "3.25.1"
|
|
9
|
+
ktfmt = "0.22.0"
|
|
10
|
+
|
|
11
|
+
[libraries]
|
|
12
|
+
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
|
13
|
+
android-gradle-plugin = { module = "com.android.tools.build:gradle", version.ref = "agp" }
|
|
14
|
+
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
|
|
15
|
+
guava = { module = "com.google.guava:guava", version.ref = "guava" }
|
|
16
|
+
javapoet = { module = "com.squareup:javapoet", version.ref = "javapoet" }
|
|
17
|
+
junit = {module = "junit:junit", version.ref = "junit" }
|
|
18
|
+
assertj = { module = "org.assertj:assertj-core", version.ref = "assertj" }
|
|
19
|
+
|
|
20
|
+
[plugins]
|
|
21
|
+
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
|
22
|
+
ktfmt = { id = "com.ncorti.ktfmt.gradle", version.ref = "ktfmt" }
|
|
Binary file
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
distributionBase=GRADLE_USER_HOME
|
|
2
2
|
distributionPath=wrapper/dists
|
|
3
|
-
distributionUrl=https\://
|
|
3
|
+
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-9.3.1-bin.zip
|
|
4
|
+
networkTimeout=120000
|
|
5
|
+
validateDistributionUrl=false
|
|
4
6
|
zipStoreBase=GRADLE_USER_HOME
|
|
5
7
|
zipStorePath=wrapper/dists
|
package/gradlew
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
|
|
3
3
|
#
|
|
4
|
-
# Copyright © 2015
|
|
4
|
+
# Copyright © 2015 the original authors.
|
|
5
5
|
#
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
# you may not use this file except in compliance with the License.
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
# See the License for the specific language governing permissions and
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
#
|
|
18
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
19
|
+
#
|
|
18
20
|
|
|
19
21
|
##############################################################################
|
|
20
22
|
#
|
|
@@ -55,7 +57,7 @@
|
|
|
55
57
|
# Darwin, MinGW, and NonStop.
|
|
56
58
|
#
|
|
57
59
|
# (3) This script is generated from the Groovy template
|
|
58
|
-
# https://github.com/gradle/gradle/blob/
|
|
60
|
+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
59
61
|
# within the Gradle project.
|
|
60
62
|
#
|
|
61
63
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
@@ -80,13 +82,11 @@ do
|
|
|
80
82
|
esac
|
|
81
83
|
done
|
|
82
84
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
APP_NAME="Gradle"
|
|
85
|
+
# This is normally unused
|
|
86
|
+
# shellcheck disable=SC2034
|
|
86
87
|
APP_BASE_NAME=${0##*/}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
88
|
+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
|
89
|
+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
|
90
90
|
|
|
91
91
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
92
92
|
MAX_FD=maximum
|
|
@@ -114,7 +114,6 @@ case "$( uname )" in #(
|
|
|
114
114
|
NONSTOP* ) nonstop=true ;;
|
|
115
115
|
esac
|
|
116
116
|
|
|
117
|
-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|
118
117
|
|
|
119
118
|
|
|
120
119
|
# Determine the Java command to use to start the JVM.
|
|
@@ -133,22 +132,29 @@ location of your Java installation."
|
|
|
133
132
|
fi
|
|
134
133
|
else
|
|
135
134
|
JAVACMD=java
|
|
136
|
-
|
|
135
|
+
if ! command -v java >/dev/null 2>&1
|
|
136
|
+
then
|
|
137
|
+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
137
138
|
|
|
138
139
|
Please set the JAVA_HOME variable in your environment to match the
|
|
139
140
|
location of your Java installation."
|
|
141
|
+
fi
|
|
140
142
|
fi
|
|
141
143
|
|
|
142
144
|
# Increase the maximum file descriptors if we can.
|
|
143
145
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|
144
146
|
case $MAX_FD in #(
|
|
145
147
|
max*)
|
|
148
|
+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
|
149
|
+
# shellcheck disable=SC2039,SC3045
|
|
146
150
|
MAX_FD=$( ulimit -H -n ) ||
|
|
147
151
|
warn "Could not query maximum file descriptor limit"
|
|
148
152
|
esac
|
|
149
153
|
case $MAX_FD in #(
|
|
150
154
|
'' | soft) :;; #(
|
|
151
155
|
*)
|
|
156
|
+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
|
157
|
+
# shellcheck disable=SC2039,SC3045
|
|
152
158
|
ulimit -n "$MAX_FD" ||
|
|
153
159
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
154
160
|
esac
|
|
@@ -165,7 +171,6 @@ fi
|
|
|
165
171
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
166
172
|
if "$cygwin" || "$msys" ; then
|
|
167
173
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
|
168
|
-
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
|
169
174
|
|
|
170
175
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
|
171
176
|
|
|
@@ -193,18 +198,27 @@ if "$cygwin" || "$msys" ; then
|
|
|
193
198
|
done
|
|
194
199
|
fi
|
|
195
200
|
|
|
196
|
-
|
|
197
|
-
#
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
#
|
|
201
|
+
|
|
202
|
+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
203
|
+
DEFAULT_JVM_OPTS='-Xmx64m -Xms64m -Dos.name=Linux'
|
|
204
|
+
|
|
205
|
+
# Collect all arguments for the java command:
|
|
206
|
+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
|
207
|
+
# and any embedded shellness will be escaped.
|
|
208
|
+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
|
209
|
+
# treated as '${Hostname}' itself on the command line.
|
|
201
210
|
|
|
202
211
|
set -- \
|
|
203
212
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
|
204
|
-
-
|
|
205
|
-
org.gradle.wrapper.GradleWrapperMain \
|
|
213
|
+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
|
206
214
|
"$@"
|
|
207
215
|
|
|
216
|
+
# Stop when "xargs" is not available.
|
|
217
|
+
if ! command -v xargs >/dev/null 2>&1
|
|
218
|
+
then
|
|
219
|
+
die "xargs is not available"
|
|
220
|
+
fi
|
|
221
|
+
|
|
208
222
|
# Use "xargs" to parse quoted args.
|
|
209
223
|
#
|
|
210
224
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
package/gradlew.bat
CHANGED
|
@@ -13,8 +13,10 @@
|
|
|
13
13
|
@rem See the License for the specific language governing permissions and
|
|
14
14
|
@rem limitations under the License.
|
|
15
15
|
@rem
|
|
16
|
+
@rem SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
@rem
|
|
16
18
|
|
|
17
|
-
@if "%DEBUG%"
|
|
19
|
+
@if "%DEBUG%"=="" @echo off
|
|
18
20
|
@rem ##########################################################################
|
|
19
21
|
@rem
|
|
20
22
|
@rem Gradle startup script for Windows
|
|
@@ -25,7 +27,8 @@
|
|
|
25
27
|
if "%OS%"=="Windows_NT" setlocal
|
|
26
28
|
|
|
27
29
|
set DIRNAME=%~dp0
|
|
28
|
-
if "%DIRNAME%"
|
|
30
|
+
if "%DIRNAME%"=="" set DIRNAME=.
|
|
31
|
+
@rem This is normally unused
|
|
29
32
|
set APP_BASE_NAME=%~n0
|
|
30
33
|
set APP_HOME=%DIRNAME%
|
|
31
34
|
|
|
@@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|
|
40
43
|
|
|
41
44
|
set JAVA_EXE=java.exe
|
|
42
45
|
%JAVA_EXE% -version >NUL 2>&1
|
|
43
|
-
if
|
|
46
|
+
if %ERRORLEVEL% equ 0 goto execute
|
|
44
47
|
|
|
45
|
-
echo.
|
|
46
|
-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
47
|
-
echo.
|
|
48
|
-
echo Please set the JAVA_HOME variable in your environment to match the
|
|
49
|
-
echo location of your Java installation.
|
|
48
|
+
echo. 1>&2
|
|
49
|
+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
|
50
|
+
echo. 1>&2
|
|
51
|
+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
|
52
|
+
echo location of your Java installation. 1>&2
|
|
50
53
|
|
|
51
54
|
goto fail
|
|
52
55
|
|
|
@@ -56,32 +59,33 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
|
56
59
|
|
|
57
60
|
if exist "%JAVA_EXE%" goto execute
|
|
58
61
|
|
|
59
|
-
echo.
|
|
60
|
-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
|
61
|
-
echo.
|
|
62
|
-
echo Please set the JAVA_HOME variable in your environment to match the
|
|
63
|
-
echo location of your Java installation.
|
|
62
|
+
echo. 1>&2
|
|
63
|
+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
|
64
|
+
echo. 1>&2
|
|
65
|
+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
|
66
|
+
echo location of your Java installation. 1>&2
|
|
64
67
|
|
|
65
68
|
goto fail
|
|
66
69
|
|
|
67
70
|
:execute
|
|
68
71
|
@rem Setup the command line
|
|
69
72
|
|
|
70
|
-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
71
73
|
|
|
72
74
|
|
|
73
75
|
@rem Execute Gradle
|
|
74
|
-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -
|
|
76
|
+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
|
75
77
|
|
|
76
78
|
:end
|
|
77
79
|
@rem End local scope for the variables with windows NT shell
|
|
78
|
-
if
|
|
80
|
+
if %ERRORLEVEL% equ 0 goto mainEnd
|
|
79
81
|
|
|
80
82
|
:fail
|
|
81
83
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
82
84
|
rem the _cmd.exe /c_ return code!
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
set EXIT_CODE=%ERRORLEVEL%
|
|
86
|
+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
|
87
|
+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
|
88
|
+
exit /b %EXIT_CODE%
|
|
85
89
|
|
|
86
90
|
:mainEnd
|
|
87
91
|
if "%OS%"=="Windows_NT" endlocal
|
package/package.json
CHANGED
|
@@ -1,30 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohos-ports/react-native-gradle-plugin",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
3
|
+
"version": "0.86.0-beta.0",
|
|
4
|
+
"description": "Gradle Plugin for React Native",
|
|
5
|
+
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/ohos-ports/ohos-ports.git",
|
|
9
|
-
"directory": "ports/react-native-gradle-plugin/0.
|
|
8
|
+
"url": "git+https://github.com/ohos-ports/ohos-ports.git",
|
|
9
|
+
"directory": "ports/react-native-gradle-plugin/0.86.0"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/ohos-ports/ohos-ports/tree/main/ports/react-native-gradle-plugin/0.86.0#readme",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"gradle",
|
|
14
|
+
"plugin",
|
|
15
|
+
"react-native"
|
|
16
|
+
],
|
|
17
|
+
"bugs": "https://github.com/ohos-ports/ohos-ports/issues",
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": "^20.19.4 || ^22.13.0 || ^24.3.0 || >= 25.0.0"
|
|
10
20
|
},
|
|
11
21
|
"scripts": {
|
|
12
22
|
"build": "./gradlew build",
|
|
13
23
|
"clean": "./gradlew clean",
|
|
14
24
|
"test": "./gradlew check"
|
|
15
25
|
},
|
|
16
|
-
"main": "index.js",
|
|
17
|
-
"license": "MIT",
|
|
18
26
|
"files": [
|
|
19
27
|
"settings.gradle.kts",
|
|
20
28
|
"build.gradle.kts",
|
|
21
29
|
"gradle",
|
|
22
30
|
"gradlew",
|
|
23
31
|
"gradlew.bat",
|
|
24
|
-
"src/main",
|
|
25
32
|
"README.md",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
33
|
+
"react-native-gradle-plugin",
|
|
34
|
+
"!react-native-gradle-plugin/src/test",
|
|
35
|
+
"settings-plugin",
|
|
36
|
+
"shared",
|
|
37
|
+
"shared-testutil",
|
|
38
|
+
"gradle.properties"
|
|
29
39
|
]
|
|
30
40
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# React Native Gradle Plugin
|
|
2
|
+
|
|
3
|
+
This plugin is used by React Native Apps to configure themselves.
|
|
4
|
+
|
|
5
|
+
NOTE: It's important that this folder is called `react-native-gradle-plugin` as it's used
|
|
6
|
+
by users in their `build.gradle` file as follows:
|
|
7
|
+
|
|
8
|
+
```gradle
|
|
9
|
+
buildscript {
|
|
10
|
+
// ...
|
|
11
|
+
dependencies {
|
|
12
|
+
classpath("com.facebook.react:react-native-gradle-plugin")
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The name of the artifact is imposed by the folder name.
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
|
9
|
+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
10
|
+
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
|
11
|
+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
12
|
+
|
|
13
|
+
plugins {
|
|
14
|
+
alias(libs.plugins.kotlin.jvm)
|
|
15
|
+
alias(libs.plugins.ktfmt)
|
|
16
|
+
id("java-gradle-plugin")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
repositories {
|
|
20
|
+
google()
|
|
21
|
+
mavenCentral()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
gradlePlugin {
|
|
25
|
+
plugins {
|
|
26
|
+
create("react") {
|
|
27
|
+
id = "com.facebook.react"
|
|
28
|
+
implementationClass = "com.facebook.react.ReactPlugin"
|
|
29
|
+
}
|
|
30
|
+
create("reactrootproject") {
|
|
31
|
+
id = "com.facebook.react.rootproject"
|
|
32
|
+
implementationClass = "com.facebook.react.ReactRootProjectPlugin"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
group = "com.facebook.react"
|
|
38
|
+
|
|
39
|
+
dependencies {
|
|
40
|
+
implementation(project(":shared"))
|
|
41
|
+
|
|
42
|
+
implementation(gradleApi())
|
|
43
|
+
|
|
44
|
+
// The KGP/AGP version is defined by React Native Gradle plugin.
|
|
45
|
+
// Therefore we specify an implementation dep rather than a compileOnly.
|
|
46
|
+
implementation(libs.kotlin.gradle.plugin)
|
|
47
|
+
implementation(libs.android.gradle.plugin)
|
|
48
|
+
|
|
49
|
+
implementation(libs.gson)
|
|
50
|
+
implementation(libs.guava)
|
|
51
|
+
implementation(libs.javapoet)
|
|
52
|
+
|
|
53
|
+
testImplementation(libs.junit)
|
|
54
|
+
testImplementation(libs.assertj)
|
|
55
|
+
testImplementation(project(":shared-testutil"))
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// We intentionally don't build for Java 17 as users will see a cryptic bytecode version
|
|
59
|
+
// error first. Instead we produce a Java 11-compatible Gradle Plugin, so that AGP can print their
|
|
60
|
+
// nice message showing that JDK 11 (or 17) is required first
|
|
61
|
+
java { targetCompatibility = JavaVersion.VERSION_11 }
|
|
62
|
+
|
|
63
|
+
kotlin { jvmToolchain(26) }
|
|
64
|
+
|
|
65
|
+
tasks.withType<KotlinCompile>().configureEach {
|
|
66
|
+
compilerOptions {
|
|
67
|
+
apiVersion.set(KotlinVersion.KOTLIN_1_8)
|
|
68
|
+
// See comment above on JDK 11 support
|
|
69
|
+
jvmTarget.set(JvmTarget.JVM_11)
|
|
70
|
+
allWarningsAsErrors.set(
|
|
71
|
+
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
tasks.withType<Test>().configureEach {
|
|
77
|
+
testLogging {
|
|
78
|
+
exceptionFormat = TestExceptionFormat.FULL
|
|
79
|
+
showExceptions = true
|
|
80
|
+
showCauses = true
|
|
81
|
+
showStackTraces = true
|
|
82
|
+
}
|
|
83
|
+
}
|
package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/ReactExtension.kt
RENAMED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
package com.facebook.react
|
|
9
9
|
|
|
10
|
+
import com.facebook.react.utils.JsonUtils
|
|
10
11
|
import com.facebook.react.utils.projectPathToLibraryName
|
|
12
|
+
import java.io.File
|
|
11
13
|
import javax.inject.Inject
|
|
12
14
|
import org.gradle.api.Project
|
|
13
15
|
import org.gradle.api.file.DirectoryProperty
|
|
@@ -15,7 +17,7 @@ import org.gradle.api.file.RegularFileProperty
|
|
|
15
17
|
import org.gradle.api.provider.ListProperty
|
|
16
18
|
import org.gradle.api.provider.Property
|
|
17
19
|
|
|
18
|
-
abstract class ReactExtension @Inject constructor(project: Project) {
|
|
20
|
+
abstract class ReactExtension @Inject constructor(val project: Project) {
|
|
19
21
|
|
|
20
22
|
private val objects = project.objects
|
|
21
23
|
|
|
@@ -31,7 +33,7 @@ abstract class ReactExtension @Inject constructor(project: Project) {
|
|
|
31
33
|
/**
|
|
32
34
|
* The path to the react-native NPM package folder.
|
|
33
35
|
*
|
|
34
|
-
* Default: ${rootProject.dir}/../node_modules/react-native
|
|
36
|
+
* Default: ${rootProject.dir}/../node_modules/react-native
|
|
35
37
|
*/
|
|
36
38
|
val reactNativeDir: DirectoryProperty =
|
|
37
39
|
objects.directoryProperty().convention(root.dir("node_modules/react-native"))
|
|
@@ -74,6 +76,16 @@ abstract class ReactExtension @Inject constructor(project: Project) {
|
|
|
74
76
|
val bundleAssetName: Property<String> =
|
|
75
77
|
objects.property(String::class.java).convention("index.android.bundle")
|
|
76
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Whether the Bundle Asset should be compressed when packaged into a `.apk`, or not. Disabling
|
|
81
|
+
* compression for the `.bundle` allows it to be directly memory-mapped to RAM, hence improving
|
|
82
|
+
* startup time - at the cost of a larger resulting `.apk` size.
|
|
83
|
+
*
|
|
84
|
+
* Default: false
|
|
85
|
+
*/
|
|
86
|
+
val enableBundleCompression: Property<Boolean> =
|
|
87
|
+
objects.property(Boolean::class.java).convention(false)
|
|
88
|
+
|
|
77
89
|
/**
|
|
78
90
|
* Toggles the .so Cleanup step. If enabled, we will clean up all the unnecessary files before the
|
|
79
91
|
* bundle task. If disabled, the developers will have to manually cleanup the files. Default: true
|
|
@@ -85,14 +97,13 @@ abstract class ReactExtension @Inject constructor(project: Project) {
|
|
|
85
97
|
objects.listProperty(String::class.java).convention(emptyList())
|
|
86
98
|
|
|
87
99
|
/**
|
|
88
|
-
* Allows to specify the debuggable variants (by default just 'debug'). Variants in this list
|
|
89
|
-
* will
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* where you want dev mode to be enabled. Default: ['debug']
|
|
100
|
+
* Allows to specify the debuggable variants (by default just 'debug'). Variants in this list will
|
|
101
|
+
* not be bundled (the bundle file will not be created and won't be copied over).
|
|
102
|
+
*
|
|
103
|
+
* Default: ['debug', 'debugOptimized']
|
|
93
104
|
*/
|
|
94
105
|
val debuggableVariants: ListProperty<String> =
|
|
95
|
-
objects.listProperty(String::class.java).convention(listOf("debug"))
|
|
106
|
+
objects.listProperty(String::class.java).convention(listOf("debug", "debugOptimized"))
|
|
96
107
|
|
|
97
108
|
/** Hermes Config */
|
|
98
109
|
|
|
@@ -121,10 +132,10 @@ abstract class ReactExtension @Inject constructor(project: Project) {
|
|
|
121
132
|
/**
|
|
122
133
|
* The path to the react-native-codegen NPM package folder.
|
|
123
134
|
*
|
|
124
|
-
* Default: ${rootProject.dir}/../node_modules
|
|
135
|
+
* Default: ${rootProject.dir}/../node_modules/@react-native/codegen
|
|
125
136
|
*/
|
|
126
137
|
val codegenDir: DirectoryProperty =
|
|
127
|
-
objects.directoryProperty().convention(root.dir("node_modules
|
|
138
|
+
objects.directoryProperty().convention(root.dir("node_modules/@react-native/codegen"))
|
|
128
139
|
|
|
129
140
|
/**
|
|
130
141
|
* The root directory for all JS files for the app.
|
|
@@ -148,4 +159,61 @@ abstract class ReactExtension @Inject constructor(project: Project) {
|
|
|
148
159
|
*/
|
|
149
160
|
val codegenJavaPackageName: Property<String> =
|
|
150
161
|
objects.property(String::class.java).convention("com.facebook.fbreact.specs")
|
|
162
|
+
|
|
163
|
+
/** Auto-linking Utils */
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Utility function to autolink libraries to the app.
|
|
167
|
+
*
|
|
168
|
+
* This function will read the autolinking configuration file and add Gradle dependencies to the
|
|
169
|
+
* app. This function should be invoked inside the react {} block in the app's build.gradle and is
|
|
170
|
+
* necessary for libraries to be linked correctly.
|
|
171
|
+
*/
|
|
172
|
+
fun autolinkLibrariesWithApp() {
|
|
173
|
+
val inputFile =
|
|
174
|
+
project.rootProject.layout.buildDirectory
|
|
175
|
+
.file("generated/autolinking/autolinking.json")
|
|
176
|
+
.get()
|
|
177
|
+
.asFile
|
|
178
|
+
val dependenciesToApply = getGradleDependenciesToApply(inputFile)
|
|
179
|
+
dependenciesToApply.forEach { (configuration, path) ->
|
|
180
|
+
project.dependencies.add(configuration, project.dependencies.project(mapOf("path" to path)))
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
companion object {
|
|
185
|
+
/**
|
|
186
|
+
* Util function to construct a list of Gradle Configuration <-> Project name pairs for
|
|
187
|
+
* autolinking. Pairs looks like: "implementation" -> ":react-native_oss-library-example"
|
|
188
|
+
*
|
|
189
|
+
* They will be applied to the Gradle project for linking the libraries.
|
|
190
|
+
*
|
|
191
|
+
* @param inputFile The file to read the autolinking configuration from.
|
|
192
|
+
* @return A list of Gradle Configuration <-> Project name pairs.
|
|
193
|
+
*/
|
|
194
|
+
internal fun getGradleDependenciesToApply(inputFile: File): MutableList<Pair<String, String>> {
|
|
195
|
+
val model = JsonUtils.fromAutolinkingConfigJson(inputFile)
|
|
196
|
+
val result = mutableListOf<Pair<String, String>>()
|
|
197
|
+
model
|
|
198
|
+
?.dependencies
|
|
199
|
+
?.values
|
|
200
|
+
?.filter { it.platforms?.android !== null }
|
|
201
|
+
?.filterNot { it.platforms?.android?.isPureCxxDependency == true }
|
|
202
|
+
?.forEach { deps ->
|
|
203
|
+
val nameCleansed = deps.nameCleansed
|
|
204
|
+
val dependencyConfiguration = deps.platforms?.android?.dependencyConfiguration
|
|
205
|
+
val buildTypes = deps.platforms?.android?.buildTypes ?: emptyList()
|
|
206
|
+
if (buildTypes.isEmpty()) {
|
|
207
|
+
result.add((dependencyConfiguration ?: "implementation") to ":$nameCleansed")
|
|
208
|
+
} else {
|
|
209
|
+
buildTypes.forEach { buildType ->
|
|
210
|
+
result.add(
|
|
211
|
+
(dependencyConfiguration ?: "${buildType}Implementation") to ":$nameCleansed"
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return result
|
|
217
|
+
}
|
|
218
|
+
}
|
|
151
219
|
}
|