|
| 1 | +import kotlinx.kover.gradle.plugin.dsl.tasks.* |
| 2 | + |
| 3 | +plugins { |
| 4 | + id ("org.jetbrains.kotlinx.kover") |
| 5 | + id ("com.android.application") |
| 6 | + id ("org.jetbrains.kotlin.android") |
| 7 | +} |
| 8 | + |
| 9 | +android { |
| 10 | + namespace = "kotlinx.kover.test.android" |
| 11 | + compileSdk = 32 |
| 12 | + |
| 13 | + defaultConfig { |
| 14 | + applicationId = "kotlinx.kover.test.android" |
| 15 | + minSdk = 21 |
| 16 | + targetSdk = 31 |
| 17 | + versionCode = 1 |
| 18 | + versionName = "1.0" |
| 19 | + |
| 20 | + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" |
| 21 | + } |
| 22 | + |
| 23 | + buildTypes { |
| 24 | + release { |
| 25 | + isMinifyEnabled = true |
| 26 | + } |
| 27 | + } |
| 28 | + compileOptions { |
| 29 | + sourceCompatibility = JavaVersion.VERSION_1_8 |
| 30 | + targetCompatibility = JavaVersion.VERSION_1_8 |
| 31 | + } |
| 32 | + kotlinOptions { |
| 33 | + jvmTarget = "1.8" |
| 34 | + } |
| 35 | + buildFeatures { |
| 36 | + viewBinding = true |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +dependencies { |
| 41 | + implementation("androidx.core:core-ktx:1.8.0") |
| 42 | + implementation("androidx.appcompat:appcompat:1.5.0") |
| 43 | + implementation("com.google.android.material:material:1.6.1") |
| 44 | + implementation("androidx.constraintlayout:constraintlayout:2.1.4") |
| 45 | + testImplementation("junit:junit:4.13.2") |
| 46 | +} |
| 47 | + |
| 48 | +tasks.register("findAllTasks") { |
| 49 | + dependsOn("findTotalTasks") |
| 50 | + dependsOn("findDebugTasks") |
| 51 | +} |
| 52 | + |
| 53 | +tasks.register("findDebugTasks") { |
| 54 | + doLast { |
| 55 | + val xmlName = tasks.withType<KoverXmlReport>().matching { |
| 56 | + it.variantName == "debug" |
| 57 | + }.single().name |
| 58 | + |
| 59 | + val htmlName = tasks.withType<KoverHtmlReport>().matching { |
| 60 | + it.variantName == "debug" |
| 61 | + }.single().name |
| 62 | + |
| 63 | + val verifyName = tasks.withType<KoverVerifyReport>().matching { |
| 64 | + it.variantName == "debug" |
| 65 | + }.single().name |
| 66 | + |
| 67 | + val logName = tasks.withType<KoverLogReport>().matching { |
| 68 | + it.variantName == "debug" |
| 69 | + }.single().name |
| 70 | + |
| 71 | + val binaryName = tasks.withType<KoverBinaryReport>().matching { |
| 72 | + it.variantName == "debug" |
| 73 | + }.single().name |
| 74 | + |
| 75 | + println("XML=$xmlName") |
| 76 | + println("HTML=$htmlName") |
| 77 | + println("Verify=$verifyName") |
| 78 | + println("Log=$logName") |
| 79 | + println("Binary=$binaryName") |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | +tasks.register("findTotalTasks") { |
| 84 | + doLast { |
| 85 | + val xmlName = tasks.withType<KoverXmlReport>().matching { |
| 86 | + it.variantName == "" |
| 87 | + }.single().name |
| 88 | + |
| 89 | + val htmlName = tasks.withType<KoverHtmlReport>().matching { |
| 90 | + it.variantName == "" |
| 91 | + }.single().name |
| 92 | + |
| 93 | + val verifyName = tasks.withType<KoverVerifyReport>().matching { |
| 94 | + it.variantName == "" |
| 95 | + }.single().name |
| 96 | + |
| 97 | + val logName = tasks.withType<KoverLogReport>().matching { |
| 98 | + it.variantName == "" |
| 99 | + }.single().name |
| 100 | + |
| 101 | + val binaryName = tasks.withType<KoverBinaryReport>().matching { |
| 102 | + it.variantName == "" |
| 103 | + }.single().name |
| 104 | + |
| 105 | + println("XML=$xmlName") |
| 106 | + println("HTML=$htmlName") |
| 107 | + println("Verify=$verifyName") |
| 108 | + println("Log=$logName") |
| 109 | + println("Binary=$binaryName") |
| 110 | + } |
| 111 | +} |
0 commit comments