Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.callstack.react.brownfield.expo.utils.DependencyInfo
import com.callstack.react.brownfield.expo.utils.ExpoGradleProjectProjection
import com.callstack.react.brownfield.expo.utils.VersionMediatingDependencySet
import com.callstack.react.brownfield.expo.utils.asExpoGradleProjectProjection
import com.callstack.react.brownfield.plugin.RNBrownfieldPlugin.Companion.EXPO_PROJECT_LOCATOR
import com.callstack.react.brownfield.shared.Constants
import com.callstack.react.brownfield.shared.Logging
import groovy.json.JsonOutput
Expand All @@ -30,11 +29,8 @@ fun Node.getChildNodeByName(nodeName: String): Node? {
}
}

open class ExpoPublishingHelper(val brownfieldAppProject: Project, val expoProject: Project) {
fun configure() {
brownfieldAppProject.evaluationDependsOn(EXPO_PROJECT_LOCATOR)

brownfieldAppProject.afterEvaluate {
open class ExpoPublishingHelper(val brownfieldAppProject: Project) {
fun afterEvaluate() {
val discoverableExpoProjects = getDiscoverableExpoProjects()

Logging.log(
Expand Down Expand Up @@ -62,7 +58,6 @@ open class ExpoPublishingHelper(val brownfieldAppProject: Project, val expoProje

reconfigurePOM(expoTransitiveDependencies)
reconfigureGradleModuleJSON(expoTransitiveDependencies)
}
}

protected fun shouldExcludeDependency(
Expand Down Expand Up @@ -356,22 +351,26 @@ open class ExpoPublishingHelper(val brownfieldAppProject: Project, val expoProje
) {
dependenciesNodes.forEach { depNodeList ->
depNodeList.childNodes.forEach { depNode ->
// below: some nodes are not dependencies, but pure text, in which case their name is '#text'
if (depNode.nodeName == "dependency") {
/**
* below: some nodes are not dependencies, but pure text, in which case their name is '#text'
*
* only add dependencies with compile scope
*/
val scope = depNode.getChildNodeByName("scope")?.textContent
if (depNode.nodeName == "dependency" && scope == "compile") {
Comment thread
hurali97 marked this conversation as resolved.
Outdated
val groupId = depNode.getChildNodeByName("groupId")!!.textContent
val maybeArtifactId = depNode.getChildNodeByName("artifactId")

val artifactId = maybeArtifactId!!.textContent
val version = depNode.getChildNodeByName("version")?.textContent
val scope = depNode.getChildNodeByName("scope")?.textContent
val optional = depNode.getChildNodeByName("optional")?.textContent

val dependencyInfo =
DependencyInfo(
groupId = groupId,
artifactId = artifactId,
version = version,
scope = scope ?: "compile",
scope = scope,
optional = optional?.toBoolean() ?: false,
)

Expand All @@ -385,38 +384,19 @@ open class ExpoPublishingHelper(val brownfieldAppProject: Project, val expoProje
pkgProject: Project,
dependencies: VersionMediatingDependencySet,
) {
pkgProject.configurations
.filter { cfg ->
setOf(
"test",
"androidTest",
"kapt",
"annotationProcessor",
"lint",
"detached",
).none {
cfg.name.contains(it, ignoreCase = true)
}
}
.filter { cfg ->
setOf("compile", "implementation", "api", "runtime").any {
cfg.name.contains(it, ignoreCase = true)
listOf("implementation", "api").forEach {
pkgProject.configurations.getByName(it).dependencies.forEach { dep ->
Comment thread
hurali97 marked this conversation as resolved.
Outdated
if (dep.group != null) {
dependencies.add(
DependencyInfo.fromGradleDep(
groupId = dep.group!!,
artifactId = dep.name,
version = dep.version,
),
)
}
}
.forEach { cfg ->
cfg.dependencies
.filter { dep ->
dep.group != null
}.forEach { dep ->
dependencies.add(
DependencyInfo.fromGradleDep(
groupId = dep.group!!,
artifactId = dep.name,
version = dep.version,
),
)
}
}
}
Comment thread
hurali97 marked this conversation as resolved.
Outdated
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ class RNBrownfieldPlugin
*/
if (this.isExpoProject) {
Logging.log("Expo project detected.")
ExpoPublishingHelper(
brownfieldAppProject = project,
expoProject = maybeExpoProject!!,
).configure()
project.evaluationDependsOn(EXPO_PROJECT_LOCATOR)
}

RNSourceSets.configure(project, extension)
Expand All @@ -54,6 +51,12 @@ class RNBrownfieldPlugin

project.afterEvaluate {
afterEvaluate()

if (this.isExpoProject) {
ExpoPublishingHelper(
brownfieldAppProject = project,
).afterEvaluate()
}
}
}

Expand Down