Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions gradle-plugins/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,20 @@ dependencies {

<hr/>

- **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.

<hr/>

## Tooling

- We are using `ktlint` and `detekt` for formatting and linting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DefaultProjectDependency>()
defaultDependencies?.forEach { dependency ->
Expand Down Expand Up @@ -95,7 +136,7 @@ class ArtifactsResolver(
private fun resolveArtifacts(configuration: Configuration): Collection<ResolvedArtifact> {
val artifacts = ArrayList<ResolvedArtifact>()
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Loading