Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0

- name: Build modules
run: ./gradlew build jacocoTestReport -x :maps-app:generateDebugScreenshotTestConfig -x :maps-app:generateReleaseScreenshotTestConfig --stacktrace
run: ./gradlew build koverXmlReportDebug -x :maps-app:generateDebugScreenshotTestConfig -x :maps-app:generateReleaseScreenshotTestConfig --stacktrace

- name: Run Screenshot Tests
run: ./gradlew :maps-app:validateDebugScreenshotTest
Expand Down
2 changes: 1 addition & 1 deletion build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies {
implementation(libs.kotlin.gradle.plugin)
implementation(libs.android.gradle.plugin)
implementation(libs.dokka.plugin)
implementation(libs.org.jacoco.core)
implementation(libs.kover.gradle.plugin)
implementation(libs.gradle.maven.publish.plugin)

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,68 +17,37 @@
// buildSrc/src/main/kotlin/PublishingConventionPlugin.kt
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import kotlinx.kover.gradle.plugin.dsl.KoverProjectExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.*
import org.gradle.testing.jacoco.plugins.JacocoPluginExtension
import org.gradle.api.tasks.testing.Test
import org.gradle.testing.jacoco.plugins.JacocoTaskExtension
import org.gradle.testing.jacoco.tasks.JacocoReport

class PublishingConventionPlugin : Plugin<Project> {
override fun apply(project: Project) {
project.run {

applyPlugins()
configureJacoco()
configureKover()
configureVanniktechPublishing()
}
}

private fun Project.applyPlugins() {
apply(plugin = "com.android.library")
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "org.gradle.jacoco")
apply(plugin = "org.jetbrains.kotlinx.kover")
apply(plugin = "com.vanniktech.maven.publish")
}

private fun Project.configureJacoco() {
configure<JacocoPluginExtension> {
toolVersion = "0.8.15" // Compatible with newer JDKs
}

// AGP 9.0+ built-in Jacoco support or manual configuration.
// We create a "jacocoTestReport" task to match the CI workflow.

tasks.register<JacocoReport>("jacocoTestReport") {
// Dependencies
dependsOn("testDebugUnitTest")

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

// Source directories
val mainSrc = "${layout.projectDirectory}/src/main/java"
sourceDirectories.setFrom(files(mainSrc))

// Class directories - AGP 9's built-in Kotlin compiler outputs to
// intermediates/built_in_kotlinc/, not the legacy tmp/kotlin-classes/ path.
classDirectories.setFrom(
fileTree(layout.buildDirectory.dir("intermediates/built_in_kotlinc/debug")) {
include("**/classes/**")
},
fileTree(layout.buildDirectory.dir("intermediates/javac/debug")) {
include("**/classes/**")
exclude("**/R.class", "**/R\$*.class", "**/BuildConfig.class")
}
)

// Execution data from the unit test task
executionData.setFrom(fileTree(layout.buildDirectory.get()) {
include("outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec")
})
private fun Project.configureKover() {
configure<KoverProjectExtension> {
reports {
filters {
excludes {
androidGeneratedClasses()
}
}
}
}
}

Expand Down
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ buildscript {
classpath(libs.maps.secrets.plugin)
classpath(libs.kotlin.gradle.plugin)
classpath(libs.dokka.plugin)
classpath(libs.jacoco.android.plugin)
}
}

Expand Down
6 changes: 2 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ junit = "4.13.2"
junitktx = "1.3.0"
leakcanaryAndroid = "2.14"
mockk = "1.14.11"
org-jacoco-core = "0.8.15"
jacoco-plugin = "0.2.1"
kover = "0.9.9"
robolectric = "4.16.1"
screenshot = "0.0.1-alpha14"
truth = "1.4.5"
Expand Down Expand Up @@ -83,12 +82,11 @@ androidx-test-espresso = { module = "androidx.test.espresso:espresso-core", vers
androidx-test-junit-ktx = { module = "androidx.test.ext:junit-ktx", version.ref = "junitktx" }
androidx-test-rules = { module = "androidx.test:rules", version.ref = "androidCore" }
androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidxtest" }
jacoco-android-plugin = { module = "com.mxalbert.gradle:jacoco-android", version.ref = "jacoco-plugin" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinxCoroutines" }
leakcanary-android = { module = "com.squareup.leakcanary:leakcanary-android", version.ref = "leakcanaryAndroid" }
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
mockk-android = { group = "io.mockk", name = "mockk-android", version.ref = "mockk" }
org-jacoco-core = { module = "org.jacoco:org.jacoco.core", version.ref = "org-jacoco-core" }
kover-gradle-plugin = { module = "org.jetbrains.kotlinx:kover-gradle-plugin", version.ref = "kover" }
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
screenshot-validation-api = { group = "com.android.tools.screenshot", name = "screenshot-validation-api", version.ref = "screenshot" }
test-junit = { module = "junit:junit", version.ref = "junit" }
Expand Down
Loading