Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalizer task input can be destroyed with Configuration Cache enabled #30193

Closed
bamboo opened this issue Aug 15, 2024 · 0 comments · Fixed by #30192
Closed

Finalizer task input can be destroyed with Configuration Cache enabled #30193

bamboo opened this issue Aug 15, 2024 · 0 comments · Fixed by #30192
Assignees
Labels
a:bug in:configuration-cache Configuration Caching
Milestone

Comments

@bamboo
Copy link
Member

bamboo commented Aug 15, 2024

Current Behavior

A finalizer task with inputs produced by other tasks can have its inputs destroyed by another task before execution.

Expected Behavior

Gradle should prevent other tasks from destroying the finalizer task inputs before the finalizer task has been executed.

Context (optional)

No response

Steps to Reproduce

In the example below, Gradle should not allow the clean task to run between :b and :c (the producer task and the finalizer / consumer task) but that's not what happen when the Configuration Cache feature is enabled:

plugins {
    id 'java'
}

abstract class TaskReader extends DefaultTask {
    @InputFile abstract RegularFileProperty getFile()
    @TaskAction def action() {}
}

abstract class TaskWriter extends DefaultTask {
    @OutputFile abstract RegularFileProperty getFile()
    @TaskAction def action() {
        file.get().asFile.text = "foo"
    }
}

tasks.register("a", DefaultTask) {
    finalizedBy("b")
}

def taskWriter = tasks.register("c", TaskWriter) {
    file = project.layout.buildDirectory.file("output.txt")
}

tasks.register("b", TaskReader) {
    file = taskWriter.get().file
}

Gradle version

8.10

Build scan URL (optional)

No response

Your Environment (optional)

No response

@bamboo bamboo added a:bug in:configuration-cache Configuration Caching labels Aug 15, 2024
@bamboo bamboo added this to the 8.11 RC1 milestone Aug 15, 2024
@bamboo bamboo self-assigned this Aug 15, 2024
bamboo added a commit that referenced this issue Aug 15, 2024
So the scheduler can correctly handle finalizer dependencies in the presence of
a destroyer task like `clean`.

Fixes #30193
bamboo added a commit that referenced this issue Aug 15, 2024
So the scheduler can correctly handle finalizer dependencies in the presence of
a destroyer task like `clean`.

Fixes #30193
6hundreds pushed a commit that referenced this issue Aug 26, 2024
So the scheduler can correctly handle finalizer dependencies in the presence of
a destroyer task like `clean`.

Fixes #30193
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug in:configuration-cache Configuration Caching
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant