diff --git a/WordPress/build.gradle b/WordPress/build.gradle index b3724df76361..006de851ae42 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -12,6 +12,7 @@ plugins { id "se.bjurr.violations.violation-comments-to-github-gradle-plugin" id "com.google.gms.google-services" id 'dagger.hilt.android.plugin' + id "org.jetbrains.kotlinx.kover" } sentry { diff --git a/build.gradle b/build.gradle index 157ec9effa0e..491972cf882f 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { id "io.gitlab.arturbosch.detekt" id 'com.automattic.android.measure-builds' + id "org.jetbrains.kotlinx.kover" id "androidx.navigation.safeargs.kotlin" apply false id "com.android.library" apply false id 'com.google.gms.google-services' apply false @@ -248,4 +249,5 @@ dependencies { detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:$gradle.ext.detektVersion" } +apply from: './config/gradle/code_coverage.gradle' apply from: './config/gradle/gradle_build_scan.gradle' diff --git a/config/gradle/code_coverage.gradle b/config/gradle/code_coverage.gradle new file mode 100644 index 000000000000..6ffe328b90ba --- /dev/null +++ b/config/gradle/code_coverage.gradle @@ -0,0 +1,71 @@ +static String resolveProjectVariantForCodeCoverage(Project project) { + if (project.name == "WordPress") { + return "wordpressVanillaRelease" + } else { + return "release" + } +} + +subprojects { + pluginManager.withPlugin("org.jetbrains.kotlinx.kover") { + if (project.plugins.hasPlugin("com.android.library") || project.plugins.hasPlugin("com.android.application")) { + koverReport { + defaults { + mergeWith(resolveProjectVariantForCodeCoverage(project)) + } + } + } + } +} + +dependencies { + kover( + project(":WordPress"), + project(":libs:editor"), + project(":libs:image-editor"), + project(":libs:processors"), + ) +} + +koverReport { + filters { + excludes { + packages( + 'com.bumptech.glide', + 'dagger.*', + '*.compose*', + '*.debug*', + 'hilt_aggregated_deps', + '*.databinding', + 'org.wordpress.android.modules', + 'org.wordpress.android.widgets', + ) + + classes( + '*_Factory*', + '*Activity', + '*Activity$*', + '*Adapter', + '*Adapter$*', + '*BuildConfig', + '*DiffCallback*', + '*Dialog', + '*Dialog$*', + '*Fragment', + '*Fragment$*', + '*FragmentDirections*', + '*FragmentKt*', + '*Module', + '*Module_*', + '*View', + '*View$*', + '*ViewHolder', + '*ViewHolder$*', + '*ViewHolderKt*', + '*.Hilt_*', + '*HiltModules*', + '*_MembersInjector', + ) + } + } +} diff --git a/libs/editor/build.gradle b/libs/editor/build.gradle index b6323f01d4c0..a6203ef1c9ed 100644 --- a/libs/editor/build.gradle +++ b/libs/editor/build.gradle @@ -2,6 +2,7 @@ plugins { id "com.android.library" id "org.jetbrains.kotlin.android" id "org.jetbrains.kotlin.plugin.parcelize" + id "org.jetbrains.kotlinx.kover" } repositories { diff --git a/libs/image-editor/build.gradle b/libs/image-editor/build.gradle index 21fbf110e765..2cdd7f6bf40f 100644 --- a/libs/image-editor/build.gradle +++ b/libs/image-editor/build.gradle @@ -3,6 +3,7 @@ plugins { id "org.jetbrains.kotlin.android" id "org.jetbrains.kotlin.plugin.parcelize" id "androidx.navigation.safeargs.kotlin" + id "org.jetbrains.kotlinx.kover" } android { diff --git a/libs/processors/build.gradle b/libs/processors/build.gradle index 03b3715127f0..8e338bd2ea76 100644 --- a/libs/processors/build.gradle +++ b/libs/processors/build.gradle @@ -1,6 +1,7 @@ plugins { id "org.jetbrains.kotlin.jvm" id "org.jetbrains.kotlin.kapt" + id "org.jetbrains.kotlinx.kover" } sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/settings.gradle b/settings.gradle index 5ce20fe7d7ed..5e48b42287db 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,6 +8,7 @@ pluginManagement { gradle.ext.detektVersion = '1.23.0' gradle.ext.violationCommentsVersion = '1.67' gradle.ext.measureBuildsVersion = '2.0.3' + gradle.ext.koverVersion = '0.7.5' plugins { id "org.jetbrains.kotlin.android" version gradle.ext.kotlinVersion @@ -24,6 +25,7 @@ pluginManagement { id "io.gitlab.arturbosch.detekt" version gradle.ext.detektVersion id "se.bjurr.violations.violation-comments-to-github-gradle-plugin" version gradle.ext.violationCommentsVersion id 'com.automattic.android.measure-builds' version gradle.ext.measureBuildsVersion + id "org.jetbrains.kotlinx.kover" version gradle.ext.koverVersion } repositories { maven {