Skip to content

applicationVariants/libraryVariants are eagerly evaluated and result in missed test data #362

@ZacSweers

Description

@ZacSweers

Describe the bug
This code eagerly evaluates applicationVariants/libraryVariants in Android projects, and the result is that they have empty variants if the plugin is applied before the android variants are set up and the kover report task will be skipped due to no inputs.

val variants = if ("applicationVariants" in androidExtension) {
androidExtension.propertyBeans("applicationVariants")
} else {
androidExtension.propertyBeans("libraryVariants")
}

Errors
If present, stacktraces or files from build/kover/errors directory

Expected behavior
This API is old and the wrong API to use. Instead, the new androidComponents.onVariants API should be used, as this is a push system that will callback with each variant. This API is present in AGP 7.0 and later.

Reproducer
Easy to reproduce in a project that applies the kover plugin before configuring android variants.

Reports
If applicable, report files or screenshots.

Environment

  • Kover Gradle Plugin version: 0.7.0-Beta
  • Gradle version: 8.0.2/8.1.1
  • Kotlin project type: Kotlin/Android
  • Coverage Engine version (if customized in build script): N/A
  • Other context important for this bug: [e.g. OS version]

Metadata

Metadata

Assignees

Labels

BugBug issue typeS: ready for releaseStatus: merged in the main branch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions