Task is always up-to-date even when task.outputs.files changed on disk

Given the following task:

task test_outputs() {
	inputs.files file("C:/TEMP/in.txt")
	outputs.files file("C:/TEMP/out.txt")
	doLast {
		println "executing..."
	}
}

When I first execute the task, I get the expected output:

:test_outputs
executing...

If I modify or delete the output file C:/TEMP/out.txt file and re-execute the task, I constantly get an up-to-date message:

:test_outputs UP-TO-DATE

What am I doing wrong ?

By the way, I am using Gradle 4.1 on Windows 10 64-bit

If that’s all the task does (prints a message), Gradle sees that you’re not modifying the output file and assumes there’s a problem with overlapping outputs (or pre-existing files) in the task’s outputs. This is counter-intuitive and there are some changes in the next Gradle release to make this less likely to happen.

If your task did something to out.txt, you wouldn’t see this behavior.