diff --git a/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/Jacoco.kt b/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/Jacoco.kt index 972d539c6..ed1ea4254 100644 --- a/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/Jacoco.kt +++ b/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/Jacoco.kt @@ -19,10 +19,12 @@ package com.google.samples.apps.nowinandroid import com.android.build.api.artifact.ScopedArtifact import com.android.build.api.variant.AndroidComponentsExtension import com.android.build.api.variant.ScopedArtifacts +import com.android.build.api.variant.SourceDirectories import org.gradle.api.Project import org.gradle.api.file.Directory import org.gradle.api.file.RegularFile import org.gradle.api.provider.ListProperty +import org.gradle.api.provider.Provider import org.gradle.api.tasks.testing.Test import org.gradle.kotlin.dsl.assign import org.gradle.kotlin.dsl.configure @@ -88,11 +90,14 @@ internal fun Project.configureJacoco( html.required = true } - // TODO: This is missing files in src/debug/, src/prod, src/demo, src/demoDebug... + fun SourceDirectories.Flat?.toFilePaths(): Provider> = this + ?.all + ?.map { directories -> directories.map { it.asFile.path } } + ?: provider { emptyList() } sourceDirectories.setFrom( files( - "$projectDir/src/main/java", - "$projectDir/src/main/kotlin", + variant.sources.java.toFilePaths(), + variant.sources.kotlin.toFilePaths() ), )