Skip to content

Commit

Permalink
Merge 45ae844 into 549cbb4
Browse files Browse the repository at this point in the history
  • Loading branch information
buenaflor authored Aug 8, 2023
2 parents 549cbb4 + 45ae844 commit b58b3b4
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 50 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: all clean compile javadocs dryRelease update stop checkFormat format api assembleBenchmarkTestRelease assembleUiTestRelease
.PHONY: all clean compile javadocs dryRelease update stop checkFormat format api assembleBenchmarkTestRelease assembleUiTestRelease androidCoverageReport

all: stop clean javadocs compile
all: stop clean javadocs compile jacocoTestReport
assembleBenchmarks: stop clean assembleBenchmarkTestRelease
assembleUiTests: stop clean assembleUiTestRelease

Expand Down Expand Up @@ -50,3 +50,7 @@ assembleBenchmarkTestRelease:
assembleUiTestRelease:
./gradlew :sentry-android-integration-tests:sentry-uitest-android:assembleRelease
./gradlew :sentry-android-integration-tests:sentry-uitest-android:assembleAndroidTest -DtestBuildType=release

# Create coverage reports
jacocoTestReport:
./gradlew jacocoTestReport
61 changes: 61 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ plugins {
id(Config.QualityPlugins.detekt) version Config.QualityPlugins.detektVersion
`maven-publish`
id(Config.QualityPlugins.binaryCompatibilityValidator) version Config.QualityPlugins.binaryCompatibilityValidatorVersion
id(Config.QualityPlugins.jacocoAndroid) version Config.QualityPlugins.jacocoAndroidVersion apply false
}

buildscript {
Expand Down Expand Up @@ -97,6 +98,66 @@ allprojects {
}

subprojects {
val jacocoAndroidModules = listOf(
"sentry-android-core",
"sentry-android-fragment",
"sentry-android-navigation",
"sentry-android-ndk",
"sentry-android-okhttp",
"sentry-android-sqlite",
"sentry-android-timber",
"sentry-compose"
)
if (jacocoAndroidModules.contains(name)) {
afterEvaluate {
jacoco {
toolVersion = "0.8.10"
}

tasks.withType<Test> {
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = true
excludes = listOf("jdk.internal.*")
}
}

tasks.getByName("jacocoTestReport") {
if (this@afterEvaluate.name == "sentry-compose") {
dependsOn("jacocoCompose")
}
}
}
}

// Handle Jacoco for KMP modules manually
if (name == "sentry-compose") {
tasks.create("jacocoCompose", JacocoReport::class) {
dependsOn("testReleaseUnitTest")

reports {
html.required.set(false)
xml.required.set(true)
}

val classesDir = "$buildDir/tmp/kotlin-classes/release"
val sourcesDir = "$projectDir/src/androidMain/kotlin"

val classesTree = fileTree(classesDir).setExcludes(
listOf(
"**/R.class",
"**/R$*.class",
"**/BuildConfig.*",
"**/Manifest*.*",
"**/*Test*.*",
"android/**/*.*"
)
)
executionData.setFrom("$buildDir/jacoco/testReleaseUnitTest.exec")
classDirectories.setFrom(classesTree)
sourceDirectories.setFrom(sourcesDir)
}
}

plugins.withId(Config.QualityPlugins.detektPlugin) {
configure<DetektExtension> {
buildUponDefaultConfig = true
Expand Down
2 changes: 2 additions & 0 deletions buildSrc/src/main/java/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ object Config {
val binaryCompatibilityValidatorVersion = "0.13.0"
val binaryCompatibilityValidatorPlugin = "org.jetbrains.kotlinx:binary-compatibility-validator:$binaryCompatibilityValidatorVersion"
val binaryCompatibilityValidator = "org.jetbrains.kotlinx.binary-compatibility-validator"
val jacocoAndroid = "com.mxalbert.gradle.jacoco-android"
val jacocoAndroidVersion = "0.2.0"
}

object Sentry {
Expand Down
7 changes: 1 addition & 6 deletions sentry-android-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id("com.android.library")
kotlin("android")
jacoco
id(Config.QualityPlugins.jacocoAndroid)
id(Config.QualityPlugins.errorProne)
id(Config.QualityPlugins.gradleVersions)
}
Expand Down Expand Up @@ -64,12 +65,6 @@ android {
}
}

tasks.withType<Test> {
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = false
}
}

tasks.withType<JavaCompile>().configureEach {
options.errorprone {
check("NullAway", net.ltgt.gradle.errorprone.CheckSeverity.ERROR)
Expand Down
7 changes: 1 addition & 6 deletions sentry-android-fragment/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
id("com.android.library")
kotlin("android")
jacoco
id(Config.QualityPlugins.jacocoAndroid)
id(Config.QualityPlugins.gradleVersions)
id(Config.QualityPlugins.detektPlugin)
}
Expand Down Expand Up @@ -54,12 +55,6 @@ android {
}
}

tasks.withType<Test> {
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = false
}
}

kotlin {
explicitApi()
}
Expand Down
7 changes: 1 addition & 6 deletions sentry-android-navigation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
id("com.android.library")
kotlin("android")
jacoco
id(Config.QualityPlugins.jacocoAndroid)
id(Config.QualityPlugins.gradleVersions)
id(Config.QualityPlugins.detektPlugin)
}
Expand Down Expand Up @@ -55,12 +56,6 @@ android {
}
}

tasks.withType<Test> {
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = false
}
}

kotlin {
explicitApi()
}
Expand Down
7 changes: 1 addition & 6 deletions sentry-android-ndk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
id("com.android.library")
kotlin("android")
jacoco
id(Config.QualityPlugins.jacocoAndroid)
id(Config.NativePlugins.nativeBundleExport)
id(Config.QualityPlugins.gradleVersions)
}
Expand Down Expand Up @@ -96,12 +97,6 @@ android {
}
}

tasks.withType<Test> {
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = false
}
}

dependencies {
api(projects.sentry)
api(projects.sentryAndroidCore)
Expand Down
7 changes: 1 addition & 6 deletions sentry-android-okhttp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id("com.android.library")
kotlin("android")
jacoco
id(Config.QualityPlugins.jacocoAndroid)
id(Config.QualityPlugins.gradleVersions)
id(Config.QualityPlugins.detektPlugin)
}
Expand Down Expand Up @@ -56,12 +57,6 @@ android {
}
}

tasks.withType<Test> {
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = false
}
}

kotlin {
explicitApi()
}
Expand Down
7 changes: 1 addition & 6 deletions sentry-android-sqlite/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id("com.android.library")
kotlin("android")
jacoco
id(Config.QualityPlugins.jacocoAndroid)
id(Config.QualityPlugins.gradleVersions)
id(Config.QualityPlugins.detektPlugin)
}
Expand Down Expand Up @@ -56,12 +57,6 @@ android {
}
}

tasks.withType<Test> {
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = false
}
}

kotlin {
explicitApi()
}
Expand Down
7 changes: 1 addition & 6 deletions sentry-android-timber/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id("com.android.library")
kotlin("android")
jacoco
id(Config.QualityPlugins.jacocoAndroid)
id(Config.QualityPlugins.gradleVersions)
id(Config.QualityPlugins.detektPlugin)
}
Expand Down Expand Up @@ -59,12 +60,6 @@ android {
}
}

tasks.withType<Test> {
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = false
}
}

kotlin {
explicitApi()
}
Expand Down
7 changes: 1 addition & 6 deletions sentry-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
id("com.android.library")
id("org.jetbrains.compose")
jacoco
id(Config.QualityPlugins.jacocoAndroid)
id(Config.QualityPlugins.gradleVersions)
id(Config.QualityPlugins.detektPlugin)
id(Config.BuildPlugins.dokkaPluginAlias)
Expand Down Expand Up @@ -113,12 +114,6 @@ android {
}
}

tasks.withType<Test> {
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = false
}
}

tasks.withType<Detekt> {
// Target version of the generated JVM bytecode. It is used for type resolution.
jvmTarget = JavaVersion.VERSION_1_8.toString()
Expand Down

0 comments on commit b58b3b4

Please sign in to comment.