diff options
Diffstat (limited to 'buildSrc/src/main')
| -rw-r--r-- | buildSrc/src/main/kotlin/Libs.kt | 10 | ||||
| -rw-r--r-- | buildSrc/src/main/kotlin/jacoco-aggregation.gradle.kts | 34 |
2 files changed, 16 insertions, 28 deletions
diff --git a/buildSrc/src/main/kotlin/Libs.kt b/buildSrc/src/main/kotlin/Libs.kt index f538b1ad..6a73e1b9 100644 --- a/buildSrc/src/main/kotlin/Libs.kt +++ b/buildSrc/src/main/kotlin/Libs.kt @@ -26,14 +26,12 @@ import org.gradle.api.JavaVersion import org.gradle.api.Project import org.gradle.api.artifacts.VersionCatalogsExtension import org.gradle.kotlin.dsl.getByType -import kotlin.properties.ReadOnlyProperty /** * This class makes the version catalog accessible for the build scripts until Gradle adds support for it. * * See https://github.com/gradle/gradle/issues/15383 */ -@Suppress("UnstableApiUsage") public class Libs(project: Project) { /** * The version catalog of the project. @@ -41,16 +39,10 @@ public class Libs(project: Project) { private val versionCatalog = project.extensions.getByType(VersionCatalogsExtension::class).named("libs") /** - * A delegate for obtaining configuration values from a [Project] instance. - */ - private fun lib(name: String? = null): ReadOnlyProperty<Libs, String> = - ReadOnlyProperty { _, property -> get(name ?: property.name) } - - /** * Obtain the version for the specified [dependency][name]. */ operator fun get(name: String): String { - val dep = versionCatalog.findDependency(name).get().get() + val dep = versionCatalog.findLibrary(name).get().get() return "${dep.module.group}:${dep.module.name}:${dep.versionConstraint.displayName}" } diff --git a/buildSrc/src/main/kotlin/jacoco-aggregation.gradle.kts b/buildSrc/src/main/kotlin/jacoco-aggregation.gradle.kts index 5afd3e0d..7ae42cd2 100644 --- a/buildSrc/src/main/kotlin/jacoco-aggregation.gradle.kts +++ b/buildSrc/src/main/kotlin/jacoco-aggregation.gradle.kts @@ -22,7 +22,8 @@ plugins { - jacoco + base + id("jacoco-report-aggregation") } repositories { @@ -30,25 +31,20 @@ repositories { mavenCentral() } -tasks.register<JacocoReport>("codeCoverageReport") { - group = "Coverage reports" - description = "Generates an aggregate report based on all subprojects" - - reports { - xml.required.set(true) - xml.outputLocation.set(file("${buildDir}/reports/jacoco/report.xml")) - - html.required.set(true) - } - +dependencies { subprojects { - this@subprojects.plugins.withType<JacocoPlugin>().configureEach { - this@subprojects.tasks.matching { - it.extensions.findByType<JacocoTaskExtension>() != null } - .configureEach { - sourceSets(this@subprojects.the<SourceSetContainer>().named("main").get()) - executionData(this) - } + plugins.withType<JacocoPlugin>().configureEach { + jacocoAggregation(this@subprojects) } + } } + +@Suppress("UnstableApiUsage") +val codeCoverageReport by reporting.reports.creating(JacocoCoverageReport::class) { + testType.set(TestSuiteType.UNIT_TEST) +} + +tasks.check { + dependsOn(codeCoverageReport.reportTask) +} |
