@@ -7,7 +7,6 @@ import com.callstack.react.brownfield.expo.utils.DependencyInfo
77import com.callstack.react.brownfield.expo.utils.ExpoGradleProjectProjection
88import com.callstack.react.brownfield.expo.utils.VersionMediatingDependencySet
99import com.callstack.react.brownfield.expo.utils.asExpoGradleProjectProjection
10- import com.callstack.react.brownfield.plugin.RNBrownfieldPlugin.Companion.EXPO_PROJECT_LOCATOR
1110import com.callstack.react.brownfield.shared.Constants
1211import com.callstack.react.brownfield.shared.Logging
1312import groovy.json.JsonOutput
@@ -30,39 +29,35 @@ fun Node.getChildNodeByName(nodeName: String): Node? {
3029 }
3130}
3231
33- open class ExpoPublishingHelper (val brownfieldAppProject : Project , val expoProject : Project ) {
34- fun configure () {
35- brownfieldAppProject.evaluationDependsOn( EXPO_PROJECT_LOCATOR )
32+ open class ExpoPublishingHelper (val brownfieldAppProject : Project ) {
33+ fun afterEvaluate () {
34+ val discoverableExpoProjects = getDiscoverableExpoProjects( )
3635
37- brownfieldAppProject.afterEvaluate {
38- val discoverableExpoProjects = getDiscoverableExpoProjects()
36+ Logging .log(
37+ " Discovered ${discoverableExpoProjects.size} discoverable Expo projects: " +
38+ discoverableExpoProjects.joinToString(
39+ " , " ,
40+ ) { it.name },
41+ )
3942
40- Logging .log(
41- " Discovered ${discoverableExpoProjects.size} discoverable Expo projects: " +
42- discoverableExpoProjects.joinToString(
43- " , " ,
44- ) { it.name },
43+ val expoTransitiveDependencies =
44+ discoverAllExpoTransitiveDependencies(
45+ expoProjects = discoverableExpoProjects,
4546 )
4647
47- val expoTransitiveDependencies =
48- discoverAllExpoTransitiveDependencies(
49- expoProjects = discoverableExpoProjects ,
50- )
51-
48+ Logging .log(
49+ " Collected a total of ${expoTransitiveDependencies.size} unique Expo transitive " +
50+ " dependencies for brownfield app project publishing " ,
51+ )
52+ expoTransitiveDependencies.forEach {
5253 Logging .log(
53- " Collected a total of ${expoTransitiveDependencies.size} unique Expo transitive " +
54- " dependencies for brownfield app project publishing " ,
54+ " (*) dependency ${it.groupId} : ${it.artifactId} : ${it.version} (scope: ${it.scope} , " +
55+ " ${ if (it.optional) " optional " else " required " } ) " ,
5556 )
56- expoTransitiveDependencies.forEach {
57- Logging .log(
58- " (*) dependency ${it.groupId} :${it.artifactId} :${it.version} (scope: ${it.scope} , " +
59- " ${if (it.optional) " optional" else " required" } )" ,
60- )
61- }
62-
63- reconfigurePOM(expoTransitiveDependencies)
64- reconfigureGradleModuleJSON(expoTransitiveDependencies)
6557 }
58+
59+ reconfigurePOM(expoTransitiveDependencies)
60+ reconfigureGradleModuleJSON(expoTransitiveDependencies)
6661 }
6762
6863 protected fun shouldExcludeDependency (
@@ -356,14 +351,18 @@ open class ExpoPublishingHelper(val brownfieldAppProject: Project, val expoProje
356351 ) {
357352 dependenciesNodes.forEach { depNodeList ->
358353 depNodeList.childNodes.forEach { depNode ->
359- // below: some nodes are not dependencies, but pure text, in which case their name is '#text'
360- if (depNode.nodeName == " dependency" ) {
354+ /* *
355+ * below: some nodes are not dependencies, but pure text, in which case their name is '#text'
356+ *
357+ * Only add dependencies with compile scope, if scope is null, default to compile
358+ */
359+ val scope = depNode.getChildNodeByName(" scope" )?.textContent
360+ if (depNode.nodeName == " dependency" && (scope == null || scope == " compile" )) {
361361 val groupId = depNode.getChildNodeByName(" groupId" )!! .textContent
362362 val maybeArtifactId = depNode.getChildNodeByName(" artifactId" )
363363
364364 val artifactId = maybeArtifactId!! .textContent
365365 val version = depNode.getChildNodeByName(" version" )?.textContent
366- val scope = depNode.getChildNodeByName(" scope" )?.textContent
367366 val optional = depNode.getChildNodeByName(" optional" )?.textContent
368367
369368 val dependencyInfo =
@@ -385,38 +384,22 @@ open class ExpoPublishingHelper(val brownfieldAppProject: Project, val expoProje
385384 pkgProject : Project ,
386385 dependencies : VersionMediatingDependencySet ,
387386 ) {
388- pkgProject.configurations
389- .filter { cfg ->
390- setOf (
391- " test" ,
392- " androidTest" ,
393- " kapt" ,
394- " annotationProcessor" ,
395- " lint" ,
396- " detached" ,
397- ).none {
398- cfg.name.contains(it, ignoreCase = true )
399- }
400- }
401- .filter { cfg ->
402- setOf (" compile" , " implementation" , " api" , " runtime" ).any {
403- cfg.name.contains(it, ignoreCase = true )
387+ val configurations = pkgProject.configurations.matching {
388+ it.name.contains(" implementation" , ignoreCase = true ) || it.name.contains(" api" , ignoreCase = true )
389+ }
390+ configurations.forEach {
391+ it.dependencies.forEach { dep ->
392+ if (dep.group != null ) {
393+ dependencies.add(
394+ DependencyInfo .fromGradleDep(
395+ groupId = dep.group!! ,
396+ artifactId = dep.name,
397+ version = dep.version,
398+ ),
399+ )
404400 }
405401 }
406- .forEach { cfg ->
407- cfg.dependencies
408- .filter { dep ->
409- dep.group != null
410- }.forEach { dep ->
411- dependencies.add(
412- DependencyInfo .fromGradleDep(
413- groupId = dep.group!! ,
414- artifactId = dep.name,
415- version = dep.version,
416- ),
417- )
418- }
419- }
402+ }
420403 }
421404
422405 /* *
0 commit comments