diff --git a/gradle-plugins/react/README.md b/gradle-plugins/react/README.md
index f33bf45b..9dd92310 100644
--- a/gradle-plugins/react/README.md
+++ b/gradle-plugins/react/README.md
@@ -132,6 +132,20 @@ dependencies {
+- **Expo Support**
+
+By default expo support is disabled. You can enable it by setting the following to `true`:
+
+```kts
+reactBrownfield {
+ isExpo = true
+}
+```
+
+This will take care of linking the expo dependencies like `expo-image` to your AAR.
+
+
+
## Tooling
- We are using `ktlint` and `detekt` for formatting and linting
diff --git a/gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/artifacts/ArtifactsResolver.kt b/gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/artifacts/ArtifactsResolver.kt
index 17ba085b..9eefc8db 100644
--- a/gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/artifacts/ArtifactsResolver.kt
+++ b/gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/artifacts/ArtifactsResolver.kt
@@ -50,7 +50,48 @@ class ArtifactsResolver(
}
}
+ private fun embedExpoDependencies() {
+ /**
+ * expo project does not exist in example-android-library so doing an
+ * early exit.
+ */
+ if (baseProject.project.name == "example-android-library") {
+ return
+ }
+
+ /**
+ * The expo third party dependencies are linked to `expo` project.
+ * They are linked via `api` configuration and in two ways. In the
+ * first way, they are linked as a subProject or local dependencies.
+ * In the second way, they are linked as local maven hosted dependencies.
+ *
+ * We get those dependencies of `expo` project and add those to the consumer
+ * library project.
+ */
+ val expoProject = baseProject.project.rootProject.project("expo")
+ val expoConfig = expoProject.configurations.findByName("api")
+ expoConfig?.dependencies?.forEach {
+ if (extension.resolveLocalDependencies) {
+ if (it is DefaultProjectDependency) {
+ baseProject.project.dependencies.add(
+ CONFIG_NAME,
+ expoProject.dependencies.project(mapOf("path" to ":${it.name}")),
+ )
+ } else {
+ baseProject.project.dependencies.add(
+ CONFIG_NAME,
+ it,
+ )
+ }
+ }
+ }
+ }
+
private fun embedDefaultDependencies(configName: String) {
+ if (extension.isExpo) {
+ embedExpoDependencies()
+ }
+
val config = baseProject.project.configurations.findByName(configName)
val defaultDependencies = config?.dependencies?.filterIsInstance()
defaultDependencies?.forEach { dependency ->
@@ -95,7 +136,7 @@ class ArtifactsResolver(
private fun resolveArtifacts(configuration: Configuration): Collection {
val artifacts = ArrayList()
configuration.resolvedConfiguration.resolvedArtifacts.forEach { artifact ->
- if (artifact.type != ARTIFACT_TYPE_AAR || artifact.type != ARTIFACT_TYPE_JAR) {
+ if (artifact.type != ARTIFACT_TYPE_AAR && artifact.type != ARTIFACT_TYPE_JAR) {
throw ProjectConfigurationException("Unsupported dependency. Please provide either Aar or Jar dependency", listOf())
}
artifacts.add(artifact)
diff --git a/gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/VariantHelper.kt b/gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/VariantHelper.kt
index d2fc1ef3..80dde496 100644
--- a/gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/VariantHelper.kt
+++ b/gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/VariantHelper.kt
@@ -148,7 +148,7 @@ class VariantHelper(private val variant: LibraryVariant) : BaseProject() {
filteredSourceSets.forEach { sourceSet ->
val filteredAarLibs = aarLibraries.filter { it.getAssetsDir().exists() }
filteredAarLibs.forEach {
- sourceSet.assets.srcDir(it)
+ sourceSet.assets.srcDir(it.getAssetsDir())
}
}
}
diff --git a/gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/utils/Extension.kt b/gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/utils/Extension.kt
index d2a82b07..7806cce5 100644
--- a/gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/utils/Extension.kt
+++ b/gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/utils/Extension.kt
@@ -29,4 +29,11 @@ open class Extension {
* Default value is `app`
*/
var appProjectName = "app"
+
+ /**
+ * Sets whether the consumer project is based on Expo.
+ *
+ * Default value is `false`
+ */
+ var isExpo = false
}