@react-native/gradle-plugin 0.75.0-rc.4 → 0.75.0-rc.6
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 +1 -1
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GeneratePackageListTask.kt +2 -0
- package/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GeneratePackageListTaskTest.kt +27 -0
- package/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt +27 -8
- package/settings-plugin/src/test/kotlin/com/facebook/react/ReactSettingsExtensionTest.kt +2 -1
- package/shared/src/main/kotlin/com/facebook/react/model/ModelAutolinkingDependenciesPlatformAndroidJson.kt +2 -1
- package/shared/src/test/kotlin/com/facebook/react/utils/JsonUtilsTest.kt +7 -1
package/package.json
CHANGED
|
@@ -85,6 +85,8 @@ abstract class GeneratePackageListTask : DefaultTask() {
|
|
|
85
85
|
val packages = model?.dependencies?.values ?: emptyList()
|
|
86
86
|
return packages
|
|
87
87
|
.filter { it.platforms?.android != null }
|
|
88
|
+
// The pure C++ dependencies won't have a .java/.kt file to import
|
|
89
|
+
.filterNot { it.platforms?.android?.isPureCxxDependency == true }
|
|
88
90
|
.associate { it.name to checkNotNull(it.platforms?.android) }
|
|
89
91
|
}
|
|
90
92
|
|
|
@@ -177,6 +177,33 @@ class GeneratePackageListTaskTest {
|
|
|
177
177
|
assertEquals(android, result["a-dependency"])
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
+
@Test
|
|
181
|
+
fun filterAndroidPackages_withIsPureCxxDependencyObject_returnsIt() {
|
|
182
|
+
val task = createTestTask<GeneratePackageListTask>()
|
|
183
|
+
val android =
|
|
184
|
+
ModelAutolinkingDependenciesPlatformAndroidJson(
|
|
185
|
+
sourceDir = "./a/directory/android",
|
|
186
|
+
packageImportPath = "import com.facebook.react.aPackage;",
|
|
187
|
+
packageInstance = "new APackage()",
|
|
188
|
+
buildTypes = emptyList(),
|
|
189
|
+
isPureCxxDependency = true)
|
|
190
|
+
|
|
191
|
+
val result =
|
|
192
|
+
task.filterAndroidPackages(
|
|
193
|
+
ModelAutolinkingConfigJson(
|
|
194
|
+
reactNativeVersion = "1000.0.0",
|
|
195
|
+
dependencies =
|
|
196
|
+
mapOf(
|
|
197
|
+
"a-pure-cxx-dependency" to
|
|
198
|
+
ModelAutolinkingDependenciesJson(
|
|
199
|
+
root = "./a/directory",
|
|
200
|
+
name = "a-pure-cxx-dependency",
|
|
201
|
+
platforms =
|
|
202
|
+
ModelAutolinkingDependenciesPlatformJson(android = android))),
|
|
203
|
+
project = null))
|
|
204
|
+
assertEquals(emptyMap<String, ModelAutolinkingDependenciesPlatformAndroidJson>(), result)
|
|
205
|
+
}
|
|
206
|
+
|
|
180
207
|
@Test
|
|
181
208
|
fun composeFileContent_withNoPackages_returnsValidFile() {
|
|
182
209
|
val task = createTestTask<GeneratePackageListTask>()
|
|
@@ -13,8 +13,10 @@ import java.math.BigInteger
|
|
|
13
13
|
import java.security.MessageDigest
|
|
14
14
|
import java.util.concurrent.TimeUnit
|
|
15
15
|
import javax.inject.Inject
|
|
16
|
+
import org.gradle.api.GradleException
|
|
16
17
|
import org.gradle.api.file.FileCollection
|
|
17
18
|
import org.gradle.api.initialization.Settings
|
|
19
|
+
import org.gradle.api.logging.Logging
|
|
18
20
|
|
|
19
21
|
abstract class ReactSettingsExtension @Inject constructor(val settings: Settings) {
|
|
20
22
|
|
|
@@ -42,17 +44,32 @@ abstract class ReactSettingsExtension @Inject constructor(val settings: Settings
|
|
|
42
44
|
lockFiles: FileCollection =
|
|
43
45
|
settings.layout.rootDirectory
|
|
44
46
|
.dir("../")
|
|
45
|
-
.files("yarn.lock", "package-lock.json", "package.json")
|
|
47
|
+
.files("yarn.lock", "package-lock.json", "package.json", "react-native.config.js")
|
|
46
48
|
) {
|
|
47
49
|
outputFile.parentFile.mkdirs()
|
|
48
50
|
val lockFilesChanged = checkAndUpdateLockfiles(lockFiles, outputFolder)
|
|
49
|
-
if (lockFilesChanged || outputFile.exists().not()) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
if (lockFilesChanged || outputFile.exists().not() || outputFile.length() != 0L) {
|
|
52
|
+
val process =
|
|
53
|
+
ProcessBuilder(command)
|
|
54
|
+
.directory(workingDirectory)
|
|
55
|
+
.redirectOutput(ProcessBuilder.Redirect.to(outputFile))
|
|
56
|
+
.redirectError(ProcessBuilder.Redirect.INHERIT)
|
|
57
|
+
.start()
|
|
58
|
+
val finished = process.waitFor(5, TimeUnit.MINUTES)
|
|
59
|
+
if (!finished || (process.exitValue() != 0)) {
|
|
60
|
+
val prefixCommand =
|
|
61
|
+
"ERROR: autolinkLibrariesFromCommand: process ${command.joinToString(" ")}"
|
|
62
|
+
val message =
|
|
63
|
+
if (!finished) "${prefixCommand} timed out"
|
|
64
|
+
else "${prefixCommand} exited with error code: ${process.exitValue()}"
|
|
65
|
+
val logger = Logging.getLogger("ReactSettingsExtension")
|
|
66
|
+
logger.error(message)
|
|
67
|
+
if (outputFile.length() != 0L) {
|
|
68
|
+
logger.error(outputFile.readText().substring(0, 1024))
|
|
69
|
+
}
|
|
70
|
+
outputFile.delete()
|
|
71
|
+
throw GradleException(message)
|
|
72
|
+
}
|
|
56
73
|
}
|
|
57
74
|
linkLibraries(getLibrariesToAutolink(outputFile))
|
|
58
75
|
}
|
|
@@ -118,6 +135,8 @@ abstract class ReactSettingsExtension @Inject constructor(val settings: Settings
|
|
|
118
135
|
// We handle scenarios where there are deps that are
|
|
119
136
|
// iOS-only or missing the Android configs.
|
|
120
137
|
?.filter { it.platforms?.android?.sourceDir != null }
|
|
138
|
+
// We want to skip dependencies that are pure C++ as they won't contain a .gradle file.
|
|
139
|
+
?.filterNot { it.platforms?.android?.isPureCxxDependency == true }
|
|
121
140
|
?.associate { deps ->
|
|
122
141
|
":${deps.nameCleansed}" to File(deps.platforms?.android?.sourceDir)
|
|
123
142
|
} ?: emptyMap()
|
|
@@ -86,7 +86,8 @@ class ReactSettingsExtensionTest {
|
|
|
86
86
|
"cxxModuleCMakeListsModuleName": null,
|
|
87
87
|
"cxxModuleCMakeListsPath": null,
|
|
88
88
|
"cxxModuleHeaderName": null,
|
|
89
|
-
"dependencyConfiguration": "implementation"
|
|
89
|
+
"dependencyConfiguration": "implementation",
|
|
90
|
+
"isPureCxxDependency": false
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
}
|
|
@@ -18,5 +18,6 @@ data class ModelAutolinkingDependenciesPlatformAndroidJson(
|
|
|
18
18
|
val cxxModuleCMakeListsModuleName: String? = null,
|
|
19
19
|
val cxxModuleCMakeListsPath: String? = null,
|
|
20
20
|
val cxxModuleHeaderName: String? = null,
|
|
21
|
-
val dependencyConfiguration: String? = null
|
|
21
|
+
val dependencyConfiguration: String? = null,
|
|
22
|
+
val isPureCxxDependency: Boolean? = null
|
|
22
23
|
)
|
|
@@ -216,7 +216,8 @@ class JsonUtilsTest {
|
|
|
216
216
|
"cxxModuleCMakeListsModuleName": null,
|
|
217
217
|
"cxxModuleCMakeListsPath": null,
|
|
218
218
|
"cxxModuleHeaderName": null,
|
|
219
|
-
"dependencyConfiguration": "implementation"
|
|
219
|
+
"dependencyConfiguration": "implementation",
|
|
220
|
+
"isPureCxxDependency": false
|
|
220
221
|
}
|
|
221
222
|
}
|
|
222
223
|
}
|
|
@@ -298,6 +299,11 @@ class JsonUtilsTest {
|
|
|
298
299
|
.platforms!!
|
|
299
300
|
.android!!
|
|
300
301
|
.dependencyConfiguration)
|
|
302
|
+
assertFalse(
|
|
303
|
+
parsed.dependencies!!["@react-native/oss-library-example"]!!
|
|
304
|
+
.platforms!!
|
|
305
|
+
.android!!
|
|
306
|
+
.isPureCxxDependency!!)
|
|
301
307
|
}
|
|
302
308
|
|
|
303
309
|
private fun createJsonFile(@Language("JSON") input: String) =
|