Steve Mitcham
Steve Mitcham

Reputation: 5313

Task is always up to date

I've got a gradle build with a task like the following

task createFolders {
  file(rootFolder).mkDirs()
}

Note that in the real system there are about 15 folders getting created during this task.

This task always reports as UP-TO-DATE when I run the task, even if I run it directly after deleted the folders being created. I have several tasks that depend on this task and they run.

How do I tell gradle that this task is only up to date if all the created folders exist?

Upvotes: 6

Views: 4131

Answers (1)

Opal
Opal

Reputation: 84784

It happens because folders are created during configuration phase. Add an action:

task createFolders << {
  file(rootFolder).mkDirs()
}

For more details see here and here.

Upvotes: 7

Related Questions