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 tasks are not run when the build is cancelled #28399

Closed
CLOVIS-AI opened this issue Mar 8, 2024 · 1 comment
Closed

Finalizer tasks are not run when the build is cancelled #28399

CLOVIS-AI opened this issue Mar 8, 2024 · 1 comment
Labels
closed:duplicate Duplicated or superseeded by another issue in:execution-engine incremental, up-to-date, overlapping outputs

Comments

@CLOVIS-AI
Copy link

Current Behavior

Let's imagine we have two tasks:

  • a
  • b

and we have declared that task("a") { finalizedBy("b") }.

If we cancel the build (CTRL-C in the CLI, stop button in IDEA) while a is running, both a and b are marked as cancelled.

Expected Behavior

a should be cancelled, but b should run anyway.

Context (optional)

Finalizer tasks are useful in situations where the build creates a resource that has to be cleaned up regardless of the build failing or succeeding. An example of such a resource is a web container that is started before an integration test task and which should be always shut down, even if some of the tests fail.
https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:finalizer_tasks

I would expect that long-running tasks that start servers would fall under the same use-case, and thus would also need to be finalized even if they are cancelled before finishing.

Steps to Reproduce

// build.gradle.kts

val a by tasks.registering {
   doLast {
        Thread.sleep(10000)
    }

    finalizedBy(b)
} 

val b by tasks.registering {
    doLast {
        println("Ran")
    }
}

Gradle version

8.3

Build scan URL (optional)

No response

Your Environment (optional)

No response

@ov7a
Copy link
Member

ov7a commented Mar 11, 2024

This issue will be closed as a duplicate of

Please add your use case and 👍 to that issue.

If you think our analysis is wrong, please provide us with more detailed information explaining why.

@ov7a ov7a closed this as not planned Won't fix, can't repro, duplicate, stale Mar 11, 2024
@ov7a ov7a added closed:duplicate Duplicated or superseeded by another issue in:execution-engine incremental, up-to-date, overlapping outputs and removed a:bug to-triage labels Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed:duplicate Duplicated or superseeded by another issue in:execution-engine incremental, up-to-date, overlapping outputs
Projects
None yet
Development

No branches or pull requests

2 participants