Skip to content

AtomicFUTransformerBase doesn't clear stale files #547

@adam-enko

Description

@adam-enko

AtomicFUTransformerBase doesn't delete the destination directory before copying files. If any of the source files are deleted, the destination will still contain the deleted files.

Solution

AtomicFUTransformerBase should delete destinationDirectory before the task executes.

Steps to reproduce

I have a Kotlin Gradle project that uses Atomicfu plugin.

The project has a single test in src/main/kotlin.

When I run ./gradlew check I see a single passing test.

I delete the test in src/main/kotlin.

When I re-run check I still see a single passing test. This is unexpected. The test should not run, because it was deleted.

I run ./gradlew clean, then ./gradlew check. I now see no tests, as expected.

Workaround

As a workaround the AtomicFU tasks can be modified to clear the destination directory before each execution:

tasks.withType<kotlinx.atomicfu.plugin.gradle.AtomicFUTransformTask>().configureEach {
    doFirst("clear stale files") {
        destinationDirectory.get().asFile.deleteRecursively()
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions