@react-native/gradle-plugin 0.73.2 → 0.73.3
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
|
@@ -15,6 +15,7 @@ import com.facebook.react.tasks.GenerateCodegenSchemaTask
|
|
|
15
15
|
import com.facebook.react.utils.AgpConfiguratorUtils.configureBuildConfigFieldsForApp
|
|
16
16
|
import com.facebook.react.utils.AgpConfiguratorUtils.configureBuildConfigFieldsForLibraries
|
|
17
17
|
import com.facebook.react.utils.AgpConfiguratorUtils.configureDevPorts
|
|
18
|
+
import com.facebook.react.utils.AgpConfiguratorUtils.configureNamespaceForLibraries
|
|
18
19
|
import com.facebook.react.utils.BackwardCompatUtils.configureBackwardCompatibilityReactMap
|
|
19
20
|
import com.facebook.react.utils.DependencyUtils.configureDependencies
|
|
20
21
|
import com.facebook.react.utils.DependencyUtils.configureRepositories
|
|
@@ -80,6 +81,7 @@ class ReactPlugin : Plugin<Project> {
|
|
|
80
81
|
|
|
81
82
|
// Library Only Configuration
|
|
82
83
|
configureBuildConfigFieldsForLibraries(project)
|
|
84
|
+
configureNamespaceForLibraries(project)
|
|
83
85
|
project.pluginManager.withPlugin("com.android.library") {
|
|
84
86
|
configureCodegen(project, extension, rootExtension, isLibrary = true)
|
|
85
87
|
}
|
|
@@ -8,12 +8,17 @@
|
|
|
8
8
|
package com.facebook.react.utils
|
|
9
9
|
|
|
10
10
|
import com.android.build.api.variant.AndroidComponentsExtension
|
|
11
|
+
import com.android.build.gradle.LibraryExtension
|
|
11
12
|
import com.facebook.react.ReactExtension
|
|
12
13
|
import com.facebook.react.utils.ProjectUtils.isHermesEnabled
|
|
13
14
|
import com.facebook.react.utils.ProjectUtils.isNewArchEnabled
|
|
15
|
+
import java.io.File
|
|
16
|
+
import javax.xml.parsers.DocumentBuilder
|
|
17
|
+
import javax.xml.parsers.DocumentBuilderFactory
|
|
14
18
|
import org.gradle.api.Action
|
|
15
19
|
import org.gradle.api.Project
|
|
16
20
|
import org.gradle.api.plugins.AppliedPlugin
|
|
21
|
+
import org.w3c.dom.Element
|
|
17
22
|
|
|
18
23
|
@Suppress("UnstableApiUsage")
|
|
19
24
|
internal object AgpConfiguratorUtils {
|
|
@@ -63,6 +68,43 @@ internal object AgpConfiguratorUtils {
|
|
|
63
68
|
project.pluginManager.withPlugin("com.android.application", action)
|
|
64
69
|
project.pluginManager.withPlugin("com.android.library", action)
|
|
65
70
|
}
|
|
71
|
+
|
|
72
|
+
fun configureNamespaceForLibraries(appProject: Project) {
|
|
73
|
+
appProject.rootProject.allprojects { subproject ->
|
|
74
|
+
subproject.pluginManager.withPlugin("com.android.library") {
|
|
75
|
+
subproject.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl { ext ->
|
|
76
|
+
if (ext.namespace == null) {
|
|
77
|
+
val android = subproject.extensions.getByType(LibraryExtension::class.java)
|
|
78
|
+
val manifestFile = android.sourceSets.getByName("main").manifest.srcFile
|
|
79
|
+
|
|
80
|
+
manifestFile
|
|
81
|
+
.takeIf { it.exists() }
|
|
82
|
+
?.let { file ->
|
|
83
|
+
getPackageNameFromManifest(file)?.let { packageName ->
|
|
84
|
+
ext.namespace = packageName
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
66
92
|
}
|
|
67
93
|
|
|
68
94
|
const val DEFAULT_DEV_SERVER_PORT = "8081"
|
|
95
|
+
|
|
96
|
+
fun getPackageNameFromManifest(manifest: File): String? {
|
|
97
|
+
val factory: DocumentBuilderFactory = DocumentBuilderFactory.newInstance()
|
|
98
|
+
val builder: DocumentBuilder = factory.newDocumentBuilder()
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
val xmlDocument = builder.parse(manifest)
|
|
102
|
+
|
|
103
|
+
val manifestElement = xmlDocument.getElementsByTagName("manifest").item(0) as? Element
|
|
104
|
+
val packageName = manifestElement?.getAttribute("package")
|
|
105
|
+
|
|
106
|
+
return if (packageName.isNullOrEmpty()) null else packageName
|
|
107
|
+
} catch (e: Exception) {
|
|
108
|
+
return null
|
|
109
|
+
}
|
|
110
|
+
}
|