Commits
Claus Rasmussen authored 7008bb4af07
112 112 | internal fun Project.configureJacoco( |
113 113 | androidComponentsExtension: AndroidComponentsExtension<*, *, *>, |
114 114 | ) { |
115 115 | configure<JacocoPluginExtension> { |
116 116 | toolVersion = libs.findVersion("jacoco").get().toString() |
117 117 | } |
118 118 | |
119 119 | val jacocoTestReport = tasks.create("jacocoTestReport") |
120 120 | |
121 121 | androidComponentsExtension.onVariants { variant -> |
122 - | if (variant.name.contains("projectEnvRelease")) { |
122 + | if (variant.name.contains("${MinGraviditetFlavor.projectEnv.name}Release")) { |
123 123 | |
124 124 | val testTaskName = "test${variant.name.capitalize()}UnitTest" |
125 125 | |
126 126 | val reportTask = tasks.register("jacoco${testTaskName.capitalize()}Report", JacocoReport::class) { |
127 127 | dependsOn(testTaskName) |
128 128 | |
129 129 | reports { |
130 130 | xml.required.set(true) |
131 131 | csv.required.set(false) |
132 132 | html.required.set(true) |
133 133 | |
134 - | |
135 134 | val versionName = rootProject.extra["versionName"] as? String |
136 135 | val versionCode = rootProject.extra["versionCode"] as? Int |
137 136 | html.outputLocation.set(file("${project.buildDir}/../../qa-reports/coverage-reports-$versionName-$versionCode/${project.name}")) |
138 137 | } |
139 138 | |
140 139 | classDirectories.setFrom( |
141 140 | fileTree("$buildDir/tmp/kotlin-classes/${variant.name}") { |
142 141 | exclude(coverageExclusions) |
143 142 | }, |
144 143 | ) |
149 148 | |
150 149 | project.android.testOptions { |
151 150 | unitTests.all { |
152 151 | it.testLogging { |
153 152 | events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED) |
154 153 | exceptionFormat = TestExceptionFormat.FULL |
155 154 | } |
156 155 | } |
157 156 | } |
158 157 | |
159 - | jacocoTestReport.dependsOn(reportTask) |
160 - | |
161 - | jacocoTestReport.doLast { |
162 - | println("Wrote '${project.name}' coverage report to ${jacoco.reportsDirectory.get()}/index.html") |
163 - | jacocoTestReportPrint("jacoco${testTaskName.capitalize()}Report") |
158 + | jacocoTestReport.apply { |
159 + | dependsOn(reportTask) |
160 + | doLast { |
161 + | println("Wrote '${project.name}' coverage report to ${jacoco.reportsDirectory.get()}/index.html") |
162 + | jacocoTestReportPrint("jacoco${testTaskName.capitalize()}Report") |
163 + | } |
164 164 | } |
165 165 | } |
166 166 | } |
167 167 | |
168 168 | tasks.withType<Test>().configureEach { |
169 169 | configure<JacocoTaskExtension> { |
170 170 | // Required for JaCoCo + Robolectric |
171 171 | // https://github.com/robolectric/robolectric/issues/2230 |
172 172 | // TODO: Consider removing if not we don't add Robolectric |
173 173 | isIncludeNoLocationClasses = true |