Skip to content

Commit 768170f

Browse files
authored
Improve coverage convention (#8)
1 parent 336d3fa commit 768170f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

plugin/src/main/kotlin/io/getstream/android/BaseConfiguration.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ internal inline fun <reified Ext : CommonExtension<*, *, *, *, *, *>> Project.co
4646
all(Test::configureTestLogging)
4747
}
4848
}
49+
50+
// Add Kotlin source directories to Android source sets. Useful, for example, for letting
51+
// them being picked up in Sonar analyses.
52+
sourceSets { all { java.srcDir("src/$name/kotlin") } }
4953
}
5054

5155
tasks.withType<JavaCompile>().configureEach {

plugin/src/main/kotlin/io/getstream/android/coverage/CoverageConfiguration.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private fun Project.configureSonar(extension: StreamProjectExtension) {
8585
property(
8686
"sonar.coverage.jacoco.xmlReportPaths",
8787
layout.buildDirectory
88-
.file("/reports/kover/report${KoverConstants.VARIANT_SUFFIX}.xml")
88+
.file("reports/kover/report${KoverConstants.VARIANT_SUFFIX}.xml")
8989
.get(),
9090
)
9191
}
@@ -103,13 +103,14 @@ private fun Project.setupKoverDependencyOnModules(includedModules: Set<String>)
103103
internal fun Project.configureCoverageModule() {
104104
val coverageOptions = requireStreamProjectExtension().coverage
105105

106+
pluginManager.apply("org.sonarqube")
107+
106108
// Only configure coverage for included modules
107109
if (name !in coverageOptions.includedModules.get()) {
110+
extensions.configure<SonarExtension> { isSkipProject = true }
108111
return
109112
}
110113

111-
pluginManager.apply("org.sonarqube")
112-
113114
// Configure Android test coverage if this is an Android module
114115
pluginManager.withPlugin("com.android.library") { configureAndroid<LibraryExtension>() }
115116
pluginManager.withPlugin("com.android.application") { configureAndroid<ApplicationExtension>() }

0 commit comments

Comments
 (0)