How to keep build cache on changed build.gradle file?

based on this answer, Tasks are UP-TO-DATE so long as the inputs and outputs don’t change.

But i just add this task finalized by existing task

def releaseTasks = tasks.findAll { task ->"assemblerelease") }
if (releaseTasks) {
    def firstReleaseTask = releaseTasks.iterator().next()
    firstReleaseTask.finalizedBy tasks.named("oldReleases")

Previous build are success, iam not run gradlew clean, iam not changing src folder, but the entire build run from over when i run gradlew assemble again.

Question: how to keep the build cache indicator ? because i need 30+ mins to finish build from over :frowning:

You can also easily see why a task is not up-to-date when running with --info as it then outputs why a task is considered out of date.

Btw. the tasks.findAll is a very bad idea.
You completely break task configuration avoidance using it, making all your builds slower as each and ever task needs to be realized and configured.