Skip to content

Commit 07fde18

Browse files
Setup sonar for core
1 parent 4dcc812 commit 07fde18

File tree

7 files changed

+82
-3
lines changed

7 files changed

+82
-3
lines changed

build.gradle.kts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import java.io.FileNotFoundException
22
import java.util.Calendar
3-
3+
apply(from = "${rootDir}/gradle/scripts/sonar.gradle")
44
// Top-level build file where you can add configuration options common to all sub-projects/modules.
55
plugins {
66
alias(libs.plugins.android.application) apply false
@@ -11,6 +11,8 @@ plugins {
1111
alias(libs.plugins.ksp) apply false
1212
alias(libs.plugins.arturbosch.detekt) apply true
1313
alias(libs.plugins.spotless) apply true
14+
alias(libs.plugins.sonarqube) apply true
15+
alias(libs.plugins.kover) apply true
1416
}
1517

1618
spotless {
@@ -32,6 +34,7 @@ detekt {
3234

3335
// License tasks
3436
subprojects {
37+
apply(from = "${rootDir}/gradle/scripts/coverage.gradle")
3538
tasks.register("generateLicense") {
3639
val currentYear = Calendar.getInstance().get(Calendar.YEAR).toString()
3740
val licenseTemplate = file("../config/license/license.template")

gradle/libs.versions.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ ksp = "2.2.0-2.0.2"
2323
robolectric = "4.15.1"
2424
detekt = "1.23.8"
2525
spotless = "7.2.1"
26-
klint = "13.0.0"
26+
kover = "0.9.1"
27+
sonarqube = "6.3.0.5676"
2728

2829

2930
[libraries]
@@ -72,4 +73,6 @@ kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "ko
7273
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
7374
arturbosch-detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
7475
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
76+
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover"}
77+
sonarqube = { id = "org.sonarqube", version.ref = "sonarqube"}
7578

gradle/scripts/coverage.gradle

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
if (!rootProject.ext.sonar.ignoreModules.contains(name)) {
2+
apply plugin: "org.jetbrains.kotlinx.kover"
3+
apply plugin: "org.sonarqube"
4+
5+
if (hasProperty('android')) {
6+
android {
7+
buildTypes {
8+
debug {
9+
testCoverageEnabled = true
10+
enableUnitTestCoverage = true
11+
enableAndroidTestCoverage true
12+
}
13+
}
14+
}
15+
}
16+
17+
kover {
18+
reports {
19+
verify {
20+
warningInsteadOfFailure = true
21+
}
22+
}
23+
}
24+
25+
sonarqube {
26+
properties {
27+
property "sonar.junit.reportPaths", "./build/test-results/testDebugUnitTest"
28+
property "sonar.coverage.jacoco.xmlReportPaths", "./build/reports/kover/reportDebug.xml"
29+
property "sonar.sources", "src/main/java"
30+
}
31+
}
32+
}

gradle/scripts/sonar.gradle

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
apply plugin: "org.sonarqube"
2+
3+
ext.sonar = [
4+
ignoreModules : [
5+
'stream-android-core-lint',
6+
'stream-android-core-annotations',
7+
'app'
8+
],
9+
excludeFilter : [
10+
'**/test/**',
11+
'**/androidTest/**',
12+
'**/R.class',
13+
'**/R2.class',
14+
'**/R$*.class',
15+
'**/BuildConfig.*',
16+
'**/Manifest*.*',
17+
'**/*Test*.*'
18+
]
19+
]
20+
21+
ext.sonar.ignoreModules.each {
22+
ext.sonar.excludeFilter << "**/${it}/**"
23+
}
24+
25+
sonarqube {
26+
properties {
27+
property("sonar.host.url", "https://sonarcloud.io")
28+
property("sonar.token", "${System.getenv("SONAR_TOKEN")}")
29+
property("sonar.organization", "getstream")
30+
property("sonar.projectKey", "GetStream_stream-core-android")
31+
property("sonar.projectName", "stream-core-android")
32+
property "sonar.java.coveragePlugin", "jacoco"
33+
property "sonar.sourceEncoding", "UTF-8"
34+
property "sonar.java.binaries", "${rootDir}/**/build/tmp/java-classes/debug"
35+
property "sonar.coverage.exclusions", rootProject.ext.sonar.excludeFilter
36+
}
37+
}

stream-android-core/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ plugins {
55
alias(libs.plugins.kotlin.android)
66
alias(libs.plugins.ksp)
77
alias(libs.plugins.arturbosch.detekt)
8+
alias(libs.plugins.sonarqube)
9+
alias(libs.plugins.kover)
810
}
911

1012
kotlin {

stream-android-core/src/main/java/io/getstream/android/core/api/model/config/StreamHttpConfig.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package io.getstream.android.core.api.model.config
1717

18+
import io.getstream.android.core.annotations.StreamCoreApi
1819
import okhttp3.Interceptor
1920
import okhttp3.OkHttpClient
2021

@@ -25,6 +26,7 @@ import okhttp3.OkHttpClient
2526
* @param automaticInterceptors Whether to add automatic interceptors.
2627
* @param configuredInterceptors The configured interceptors.
2728
*/
29+
@StreamCoreApi
2830
data class StreamHttpConfig(
2931
val httpBuilder: OkHttpClient.Builder,
3032
val automaticInterceptors: Boolean = true,

stream-android-core/src/main/java/io/getstream/android/core/internal/subscribe/StreamSubscriptionManagerImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ internal class StreamSubscriptionManagerImpl<T>(
117117
object : StreamSubscription {
118118
override fun cancel() {
119119
val key = keyRef.get() ?: return
120-
synchronized(weakSubscribers) { weakSubscribers.remove(key, this) }
120+
synchronized(weakSubscribers) { weakSubscribers.remove(key) }
121121
}
122122
}
123123
weakSubscribers[listener] = handle

0 commit comments

Comments
 (0)