Skip to content

Commit de3e62f

Browse files
authored
fix: make android library evaluation depends on expo (#141)
* fix: add evaluation dependency on expo * feat: add guard for expo evaluation
1 parent 078618f commit de3e62f

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/artifacts/ArtifactsResolver.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import com.callstack.react.brownfield.processors.VariantTaskProvider
2020
import com.callstack.react.brownfield.shared.BaseProject
2121
import com.callstack.react.brownfield.shared.GradleProps
2222
import com.callstack.react.brownfield.utils.Extension
23+
import com.callstack.react.brownfield.utils.Utils
2324
import org.gradle.api.ProjectConfigurationException
2425
import org.gradle.api.artifacts.Configuration
2526
import org.gradle.api.artifacts.ResolvedArtifact
@@ -55,7 +56,7 @@ class ArtifactsResolver(
5556
* expo project does not exist in example-android-library so doing an
5657
* early exit.
5758
*/
58-
if (baseProject.project.name == "example-android-library") {
59+
if (Utils.isExampleLibrary(baseProject.project.name)) {
5960
return
6061
}
6162

gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/RNBrownfieldPlugin.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,19 @@ class RNBrownfieldPlugin
2828

2929
override fun apply(project: Project) {
3030
verifyAndroidPluginApplied(project)
31-
3231
initializers(project)
32+
33+
/**
34+
* Make sure that expo project is evaluated before the android library.
35+
* This ensures that the expo modules are available to link with the
36+
* android library, when it is evaluated.
37+
*/
38+
val expoProjectPath = ":expo"
39+
val hasExpoProject = project.findProject(expoProjectPath) != null
40+
if (hasExpoProject) {
41+
project.evaluationDependsOn(expoProjectPath)
42+
}
43+
3344
RNSourceSets.configure(project, extension)
3445
projectConfigurations.setup()
3546
registerRClassTransformer()

gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/RNSourceSets.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.callstack.react.brownfield.plugin
33
import com.android.build.gradle.LibraryExtension
44
import com.callstack.react.brownfield.exceptions.NameSpaceNotFound
55
import com.callstack.react.brownfield.utils.Extension
6+
import com.callstack.react.brownfield.utils.Utils
67
import org.gradle.api.Project
78
import org.gradle.api.Task
89
import org.gradle.api.file.Directory
@@ -27,7 +28,7 @@ object RNSourceSets {
2728
* be present on the consuming library, which is not the case
2829
* with our example library.
2930
*/
30-
if (project.name == "example-android-library") {
31+
if (Utils.isExampleLibrary(project.name)) {
3132
return
3233
}
3334
this.project = project

gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/utils/Utils.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@ object Utils {
3636
output.appendText("\n${file.readText(Charsets.UTF_8)}\n")
3737
}
3838
}
39+
40+
fun isExampleLibrary(projectName: String): Boolean {
41+
return projectName == "example-android-library"
42+
}
3943
}

0 commit comments

Comments
 (0)