Task is up-to-date after clean

I have a series of task that runs node to generate one file output from one file input. The tasks successfully complete the “first” time, but after a ‘gradle clean’ removes the outputs, further builds claim the task is up-to-date. “gradle --debug” doesn’t help - it prints very little information - basically that it is starting the up-to-date check and that it has completed.

Is there a way to get Gradle to tell you why it thinks the task is up to date? i.e., to let me know that it is considering the right inputs and outputs, that the checksums haven’t changed, does it consider creation times?

Why does it think the task is up to date when the output files aren’t present?

Suggestions on how to debug this would be appreciated.

webpack_iad {
  dependsOn compileTypescript

  inputs.file  file('webpack.config-client.js')
  outputs.file file("$buildDir/dist/xforms.js")

  inputs.files.each  { println "IAD : in  : $it.absolutePath" }
  outputs.files.each { println "IAD : out : $it.absolutePath" }

Relevant part of ‘gradle -a webpack_iad --debug’ (including the debug output)

IAD : in  : C:\jdev\xforms\webpack.config-client.js
IAD : out : C:\jdev\xforms\build\dist\xforms.js
10:20:02.781 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :xforms:webpack_iad (Thread[main,5,main]) started.
        10:20:02.796 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :xforms:webpack_iad
        10:20:02.796 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ':xforms:webpack_iad'
        10:20:02.796 [DEBUG] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Determining if task ':xforms:webpack_iad' is up-to-date
        10:20:02.796 [INFO] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Skipping task ':xforms:webpack_iad' as it is up-to-date (took 0.0 secs).
        10:20:02.812 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':xforms:webpack_iad'
        10:20:02.812 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :xforms:webpack_iad                                                                            UP-TO-DATE
        10:20:02.812 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :xforms:webpack_iad (Thread[main,5,main]) completed. Took 0.016 secs.

I figured out that I had outputs switched, so that the first in the series of tasks declared an output produced by the second task; thus, when the first task completed the output was empty. That would be why the next time the task ran, Gradle decided it was up to date. The issue that triggered this post is resolved, but I have seen this sort of thing before. It would be nice to be able to get more information about why Gradle thinks a task is, or is not, up-to-date. In addition, when a file is declared as an output, maybe (perhaps optionally) give a warning that an expected output is not available? That would prevent situations like this. :smile:

1 Like