Quantcast
Channel: Gradle Forums - Latest posts
Viewing all articles
Browse latest Browse all 19854

Run cleanTaskName without adding depencies

$
0
0

I found kind of a workaround, abusing onlyIf{}
However, if the same task type is executed twice, a dummy task must be executed in between…
(similar used to force cache only by stashing outputs in onlyIf and restoring in doFirst)

I still would like to have a property to get gradle to ignore outputs and still execute, updating caches

   boolean deleteOutputs(Project project, TaskOutputs taskOutputs) {
        taskOutputs.getFiles().each { File f ->
            project.delete(f)
        }
        return true
    }

void apply(Project project) {
 def a = project.tasks.register('a', MyTask)
 def dummy = project.tasks.register('dummy')
  def b = project.tasks.register('b', MyTask)

a.configure {
  onlyIf{ deleteOutputs(project, outputs) }
}

dummy.configure {
  dependsOn a
  doLast {
    // This task must be inserted and actually do something for b to not detect overlapping outputs
  }
}

b.configure {
  dependsOn dummy
  onlyIf{ deleteOutputs(project, outputs) }
}

Edit: issue to disabling overlapping outputs


Viewing all articles
Browse latest Browse all 19854

Trending Articles