Skip to content

Commit

Permalink
Refector when blocks
Browse files Browse the repository at this point in the history
Change-Id: I8c0b35434adf87a776f28a3fc83ecac9f65db998
  • Loading branch information
dturner committed Jul 5, 2024
1 parent 39991d2 commit b2d3131
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,22 @@ class AndroidJacocoConventionPlugin : Plugin<Project> {
with(target) {
pluginManager.apply("jacoco")

val androidExtension: CommonExtension<*, *, *, *, *, *> = when {
pluginManager.hasPlugin("com.android.application") -> the<BaseAppModuleExtension>()
pluginManager.hasPlugin("com.android.library") -> the<LibraryExtension>()
else -> TODO("This plugin is dependent on either nowinandroid.android.application or nowinandroid.android.library. Apply one of those plugins first.")
}
val androidExtension: CommonExtension<*, *, *, *, *, *>
val jacocoExtension: AndroidComponentsExtension<*, *, *>

val jacocoExtension: AndroidComponentsExtension<*, *, *> = when {
pluginManager.hasPlugin("com.android.application") -> the<ApplicationAndroidComponentsExtension>()
pluginManager.hasPlugin("com.android.library") -> the<LibraryAndroidComponentsExtension>()
else -> TODO("This plugin is dependent on either nowinandroid.android.application or nowinandroid.android.library. Apply one of those plugins first.")
when {
pluginManager.hasPlugin("com.android.application") -> {
androidExtension = the<BaseAppModuleExtension>()
jacocoExtension = the<ApplicationAndroidComponentsExtension>()
}
pluginManager.hasPlugin("com.android.library") -> {
androidExtension = the<LibraryExtension>()
jacocoExtension = the<LibraryAndroidComponentsExtension>()
}
else ->
TODO("This plugin is dependent on either nowinandroid.android.application or nowinandroid.android.library. Apply one of those plugins first.")
}

androidExtension.buildTypes.configureEach {
enableAndroidTestCoverage = true
enableUnitTestCoverage = true
Expand Down

0 comments on commit b2d3131

Please sign in to comment.