@react-native/gradle-plugin 0.75.0-rc.6 → 0.75.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/gradle/libs.versions.toml +2 -0
- package/package.json +3 -2
- package/react-native-gradle-plugin/build.gradle.kts +2 -0
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt +16 -12
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/NdkConfiguratorUtils.kt +1 -0
- package/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactExtensionTest.kt +42 -12
- package/settings-plugin/build.gradle.kts +1 -0
- package/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt +7 -1
- package/settings.gradle.kts +1 -0
- package/shared/build.gradle.kts +1 -0
- package/{react-native-gradle-plugin → shared}/src/main/kotlin/com/facebook/react/utils/Os.kt +1 -1
- package/{react-native-gradle-plugin → shared}/src/main/kotlin/com/facebook/react/utils/TaskUtils.kt +3 -3
- package/shared-testutil/build.gradle.kts +38 -0
- /package/{react-native-gradle-plugin → shared}/src/main/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtils.kt +0 -0
- /package/{react-native-gradle-plugin → shared}/src/test/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtilsTest.kt +0 -0
- /package/{react-native-gradle-plugin → shared}/src/test/kotlin/com/facebook/react/utils/OsTest.kt +0 -0
- /package/{react-native-gradle-plugin → shared}/src/test/kotlin/com/facebook/react/utils/TaskUtilsTest.kt +0 -0
- /package/{react-native-gradle-plugin/src/test → shared-testutil/src/main}/kotlin/com/facebook/react/tests/OsRule.kt +0 -0
- /package/{react-native-gradle-plugin/src/test → shared-testutil/src/main}/kotlin/com/facebook/react/tests/WithOs.kt +0 -0
|
@@ -5,6 +5,7 @@ guava = "31.0.1-jre"
|
|
|
5
5
|
javapoet = "1.13.0"
|
|
6
6
|
junit = "4.13.2"
|
|
7
7
|
kotlin = "1.9.24"
|
|
8
|
+
assertj = "3.25.1"
|
|
8
9
|
|
|
9
10
|
[libraries]
|
|
10
11
|
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
|
@@ -13,6 +14,7 @@ gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
|
|
|
13
14
|
guava = { module = "com.google.guava:guava", version.ref = "guava" }
|
|
14
15
|
javapoet = { module = "com.squareup:javapoet", version.ref = "javapoet" }
|
|
15
16
|
junit = {module = "junit:junit", version.ref = "junit" }
|
|
17
|
+
assertj = { module = "org.assertj:assertj-core", version.ref = "assertj" }
|
|
16
18
|
|
|
17
19
|
[plugins]
|
|
18
20
|
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native/gradle-plugin",
|
|
3
|
-
"version": "0.75.0
|
|
3
|
+
"version": "0.75.0",
|
|
4
4
|
"description": "Gradle Plugin for React Native",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"README.md",
|
|
33
33
|
"react-native-gradle-plugin",
|
|
34
34
|
"settings-plugin",
|
|
35
|
-
"shared"
|
|
35
|
+
"shared",
|
|
36
|
+
"shared-testutil"
|
|
36
37
|
]
|
|
37
38
|
}
|
|
@@ -184,19 +184,23 @@ abstract class ReactExtension @Inject constructor(val project: Project) {
|
|
|
184
184
|
internal fun getGradleDependenciesToApply(inputFile: File): MutableList<Pair<String, String>> {
|
|
185
185
|
val model = JsonUtils.fromAutolinkingConfigJson(inputFile)
|
|
186
186
|
val result = mutableListOf<Pair<String, String>>()
|
|
187
|
-
model
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
187
|
+
model
|
|
188
|
+
?.dependencies
|
|
189
|
+
?.values
|
|
190
|
+
?.filter { it.platforms?.android !== null }
|
|
191
|
+
?.forEach { deps ->
|
|
192
|
+
val nameCleansed = deps.nameCleansed
|
|
193
|
+
val dependencyConfiguration = deps.platforms?.android?.dependencyConfiguration
|
|
194
|
+
val buildTypes = deps.platforms?.android?.buildTypes ?: emptyList()
|
|
195
|
+
if (buildTypes.isEmpty()) {
|
|
196
|
+
result.add((dependencyConfiguration ?: "implementation") to ":$nameCleansed")
|
|
197
|
+
} else {
|
|
198
|
+
buildTypes.forEach { buildType ->
|
|
199
|
+
result.add(
|
|
200
|
+
(dependencyConfiguration ?: "${buildType}Implementation") to ":$nameCleansed")
|
|
201
|
+
}
|
|
202
|
+
}
|
|
197
203
|
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
204
|
return result
|
|
201
205
|
}
|
|
202
206
|
}
|
package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/NdkConfiguratorUtils.kt
CHANGED
|
@@ -113,6 +113,7 @@ internal object NdkConfiguratorUtils {
|
|
|
113
113
|
"**/libreact_utils.so",
|
|
114
114
|
"**/librrc_image.so",
|
|
115
115
|
"**/librrc_legacyviewmanagerinterop.so",
|
|
116
|
+
"**/librrc_textinput.so",
|
|
116
117
|
"**/librrc_view.so",
|
|
117
118
|
"**/libruntimeexecutor.so",
|
|
118
119
|
"**/libturbomodulejsijni.so",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
package com.facebook.react
|
|
9
9
|
|
|
10
10
|
import com.facebook.react.ReactExtension.Companion.getGradleDependenciesToApply
|
|
11
|
+
import org.assertj.core.api.Assertions.assertThat
|
|
11
12
|
import org.intellij.lang.annotations.Language
|
|
12
|
-
import org.junit.Assert.*
|
|
13
13
|
import org.junit.Rule
|
|
14
14
|
import org.junit.Test
|
|
15
15
|
import org.junit.rules.TemporaryFolder
|
|
@@ -30,7 +30,7 @@ class ReactExtensionTest {
|
|
|
30
30
|
.trimIndent())
|
|
31
31
|
|
|
32
32
|
val deps = getGradleDependenciesToApply(validJsonFile)
|
|
33
|
-
|
|
33
|
+
assertThat(deps).isEmpty()
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
@Test
|
|
@@ -57,8 +57,7 @@ class ReactExtensionTest {
|
|
|
57
57
|
.trimIndent())
|
|
58
58
|
|
|
59
59
|
val deps = getGradleDependenciesToApply(validJsonFile)
|
|
60
|
-
|
|
61
|
-
assertTrue("implementation" to ":react-native_oss-library-example" in deps)
|
|
60
|
+
assertThat(deps).containsExactly("implementation" to ":react-native_oss-library-example")
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
@Test
|
|
@@ -86,8 +85,7 @@ class ReactExtensionTest {
|
|
|
86
85
|
.trimIndent())
|
|
87
86
|
|
|
88
87
|
val deps = getGradleDependenciesToApply(validJsonFile)
|
|
89
|
-
|
|
90
|
-
assertTrue("compileOnly" to ":react-native_oss-library-example" in deps)
|
|
88
|
+
assertThat(deps).containsExactly("compileOnly" to ":react-native_oss-library-example")
|
|
91
89
|
}
|
|
92
90
|
|
|
93
91
|
@Test
|
|
@@ -115,9 +113,10 @@ class ReactExtensionTest {
|
|
|
115
113
|
.trimIndent())
|
|
116
114
|
|
|
117
115
|
val deps = getGradleDependenciesToApply(validJsonFile)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
assertThat(deps)
|
|
117
|
+
.containsExactly(
|
|
118
|
+
"debugImplementation" to ":react-native_oss-library-example",
|
|
119
|
+
"releaseImplementation" to ":react-native_oss-library-example")
|
|
121
120
|
}
|
|
122
121
|
|
|
123
122
|
@Test
|
|
@@ -154,9 +153,40 @@ class ReactExtensionTest {
|
|
|
154
153
|
.trimIndent())
|
|
155
154
|
|
|
156
155
|
val deps = getGradleDependenciesToApply(validJsonFile)
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
156
|
+
assertThat(deps)
|
|
157
|
+
.containsExactly(
|
|
158
|
+
"implementation" to ":react-native_oss-library-example",
|
|
159
|
+
"implementation" to ":react-native_another-library-for-testing")
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@Test
|
|
163
|
+
fun getGradleDependenciesToApply_withiOSOnlyLibrary_returnsEmptyDepsMap() {
|
|
164
|
+
val validJsonFile =
|
|
165
|
+
createJsonFile(
|
|
166
|
+
"""
|
|
167
|
+
{
|
|
168
|
+
"reactNativeVersion": "1000.0.0",
|
|
169
|
+
"dependencies": {
|
|
170
|
+
"@react-native/oss-library-example": {
|
|
171
|
+
"root": "./node_modules/@react-native/oss-library-example",
|
|
172
|
+
"name": "@react-native/oss-library-example",
|
|
173
|
+
"platforms": {
|
|
174
|
+
"ios": {
|
|
175
|
+
"podspecPath": "./node_modules/@react-native/oss-library-example/oss-library-example.podspec",
|
|
176
|
+
"version": "0.0.0",
|
|
177
|
+
"configurations": [],
|
|
178
|
+
"scriptPhases": []
|
|
179
|
+
},
|
|
180
|
+
"android": null
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
"""
|
|
186
|
+
.trimIndent())
|
|
187
|
+
|
|
188
|
+
val deps = getGradleDependenciesToApply(validJsonFile)
|
|
189
|
+
assertThat(deps).isEmpty()
|
|
160
190
|
}
|
|
161
191
|
|
|
162
192
|
private fun createJsonFile(@Language("JSON") input: String) =
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
package com.facebook.react
|
|
9
9
|
|
|
10
10
|
import com.facebook.react.utils.JsonUtils
|
|
11
|
+
import com.facebook.react.utils.windowsAwareCommandLine
|
|
11
12
|
import java.io.File
|
|
12
13
|
import java.math.BigInteger
|
|
13
14
|
import java.security.MessageDigest
|
|
@@ -25,6 +26,11 @@ abstract class ReactSettingsExtension @Inject constructor(val settings: Settings
|
|
|
25
26
|
private val outputFolder =
|
|
26
27
|
settings.layout.rootDirectory.file("build/generated/autolinking/").asFile
|
|
27
28
|
|
|
29
|
+
private val defaultConfigCommand: List<String> =
|
|
30
|
+
windowsAwareCommandLine(listOf("npx", "@react-native-community/cli", "config")).map {
|
|
31
|
+
it.toString()
|
|
32
|
+
}
|
|
33
|
+
|
|
28
34
|
/**
|
|
29
35
|
* Utility function to autolink libraries using an external command as source of truth.
|
|
30
36
|
*
|
|
@@ -39,7 +45,7 @@ abstract class ReactSettingsExtension @Inject constructor(val settings: Settings
|
|
|
39
45
|
*/
|
|
40
46
|
@JvmOverloads
|
|
41
47
|
public fun autolinkLibrariesFromCommand(
|
|
42
|
-
command: List<String> =
|
|
48
|
+
command: List<String> = defaultConfigCommand,
|
|
43
49
|
workingDirectory: File? = settings.layout.rootDirectory.dir("../").asFile,
|
|
44
50
|
lockFiles: FileCollection =
|
|
45
51
|
settings.layout.rootDirectory
|
package/settings.gradle.kts
CHANGED
package/shared/build.gradle.kts
CHANGED
package/{react-native-gradle-plugin → shared}/src/main/kotlin/com/facebook/react/utils/Os.kt
RENAMED
|
@@ -10,7 +10,7 @@ package com.facebook.react.utils
|
|
|
10
10
|
import com.facebook.react.utils.KotlinStdlibCompatUtils.lowercaseCompat
|
|
11
11
|
import java.io.File
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
object Os {
|
|
14
14
|
|
|
15
15
|
fun isWindows(): Boolean =
|
|
16
16
|
System.getProperty("os.name")?.lowercaseCompat()?.contains("windows") ?: false
|
package/{react-native-gradle-plugin → shared}/src/main/kotlin/com/facebook/react/utils/TaskUtils.kt
RENAMED
|
@@ -7,17 +7,17 @@
|
|
|
7
7
|
|
|
8
8
|
package com.facebook.react.utils
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
fun windowsAwareCommandLine(vararg args: Any): List<Any> =
|
|
11
11
|
windowsAwareCommandLine(args.toList())
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
fun windowsAwareCommandLine(args: List<Any>): List<Any> =
|
|
14
14
|
if (Os.isWindows()) {
|
|
15
15
|
listOf("cmd", "/c") + args
|
|
16
16
|
} else {
|
|
17
17
|
args
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
fun windowsAwareBashCommandLine(
|
|
21
21
|
vararg args: String,
|
|
22
22
|
bashWindowsHome: String? = null
|
|
23
23
|
): List<String> =
|
|
@@ -0,0 +1,38 @@
|
|
|
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.tasks.KotlinCompile
|
|
10
|
+
|
|
11
|
+
plugins { alias(libs.plugins.kotlin.jvm) }
|
|
12
|
+
|
|
13
|
+
repositories { mavenCentral() }
|
|
14
|
+
|
|
15
|
+
group = "com.facebook.react"
|
|
16
|
+
|
|
17
|
+
dependencies { implementation(libs.junit) }
|
|
18
|
+
|
|
19
|
+
java { targetCompatibility = JavaVersion.VERSION_11 }
|
|
20
|
+
|
|
21
|
+
kotlin { jvmToolchain(17) }
|
|
22
|
+
|
|
23
|
+
tasks.withType<KotlinCompile>().configureEach {
|
|
24
|
+
kotlinOptions {
|
|
25
|
+
apiVersion = "1.6"
|
|
26
|
+
jvmTarget = "11"
|
|
27
|
+
allWarningsAsErrors = true
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
tasks.withType<Test>().configureEach {
|
|
32
|
+
testLogging {
|
|
33
|
+
exceptionFormat = TestExceptionFormat.FULL
|
|
34
|
+
showExceptions = true
|
|
35
|
+
showCauses = true
|
|
36
|
+
showStackTraces = true
|
|
37
|
+
}
|
|
38
|
+
}
|
|
File without changes
|
|
File without changes
|
/package/{react-native-gradle-plugin → shared}/src/test/kotlin/com/facebook/react/utils/OsTest.kt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|