Skip to content

Diffcoverage fails with Empty File Collection if Clean is used #67

@kingargyle

Description

@kingargyle

Describe the bug

When running a task like:

./gradlew clean testDebugUnitTestCoverage diffCoverage --no-build-cache

And configuring where the location of the class files can be found. Diff Coverage will through an error:

  • What went wrong:
    Could not determine the dependencies of task ':lib:diffCoverage'.

'diffCoverageReport.classesDirs' file collection is empty.

This is becuase the clean will have wiped out the location of the files and the configuration happens before the files are loaded.

Currently:

https://github.com/form-com/diff-coverage-gradle/blob/master/diff-coverage/src/main/kotlin/com/form/coverage/gradle/DiffCoverageTask.kt#L38

calls collectFilesOrThrow which eagerly collects the files instead of lazily doing it after the configuration phase has completed.

Ideally these should take Providers instead of FileCollections directly, so that when the task is executing it can get the files at that particular time instead of eagerly doing it whenever the get method is called.

That will always throw an error if clean is used. If clean is not used and the coverage has run before as a seperate step it'll pass.

Ideally a FileCollectionProvider should be used and read from the ReportGenerator.

Desktop (please complete the following information):

  • OS: all
  • Gradle version: 7.4.1
  • Diff Coverage plugin version: 0.9.3

To Reproduce

./gradlew clean jacocoReport diffCoverage

Works if:

./gradlew clean jacocoReport
./gradlew diffCoverage

Expected behavior

./gradlew clean jacocoReport diffCoverage

should work without crashing

A clear and concise description of what you expected to happen.

Logs

Could not determine the dependencies of task ':lib:diffCoverage'.

'diffCoverageReport.classesDirs' file collection is empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions