Skip to content

Commit a27999c

Browse files
authored
Merge pull request #5 from pesjak/fix/self-consuming-android-app
Use the module's own linked resources when it is the Android application
2 parents 568a9a2 + 9bbfc33 commit a27999c

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

compose-nav-graph-gradle/src/main/kotlin/com/github/skydoves/navgraph/gradle/NavGraphGradlePlugin.kt

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,18 +1065,22 @@ public class NavGraphGradlePlugin : Plugin<Project> {
10651065
}
10661066
}
10671067

1068-
/** The first `com.android.application` project that declares a dependency on [module]. Checks the always-created
1069-
* `implementation` configuration (variant runtime classpaths like `devDebugRuntimeClasspath` are registered
1070-
* lazily, so iterating their names at `projectsEvaluated` is unreliable). */
1068+
/** The `com.android.application` whose linked resources feed the KMP render: [module] ITSELF when it carries the
1069+
* application plugin (a single-module Compose-Multiplatform app — KMP + `com.android.application` on one module —
1070+
* links its own R/.ap_, so it needs no external consumer), else the first application project that declares a
1071+
* dependency on [module]. Checks the always-created `implementation` configuration (variant runtime classpaths
1072+
* like `devDebugRuntimeClasspath` are registered lazily, so iterating their names at `projectsEvaluated` is
1073+
* unreliable). */
10711074
private fun findConsumingAndroidApp(module: Project): Project? =
1072-
module.rootProject.allprojects.firstOrNull { candidate ->
1073-
candidate.path != module.path &&
1074-
candidate.plugins.hasPlugin("com.android.application") &&
1075-
candidate.configurations.findByName("implementation")
1076-
?.allDependencies?.any {
1077-
it is ProjectDependency && projectDependencyPath(it) == module.path
1078-
} == true
1079-
}
1075+
module.takeIf { it.plugins.hasPlugin("com.android.application") }
1076+
?: module.rootProject.allprojects.firstOrNull { candidate ->
1077+
candidate.path != module.path &&
1078+
candidate.plugins.hasPlugin("com.android.application") &&
1079+
candidate.configurations.findByName("implementation")
1080+
?.allDependencies?.any {
1081+
it is ProjectDependency && projectDependencyPath(it) == module.path
1082+
} == true
1083+
}
10801084

10811085
/** The consuming app's debug variant — `debug`, or `<flavor>Debug` (e.g. `devDebug`) when flavored. Reads the
10821086
* first product flavor off the `android` extension reflectively (no AGP compile dependency); iterating the

0 commit comments

Comments
 (0)