java - How to get the Files that have changed since the last run of a Gradle Task? -
i have following gradle task:
class mytranslatetask extends defaulttask { @inputfiles filecollection srcfiles @outputdirectory file destdir @taskaction def run() { ... } }
how can files srcfiles
have changed since last run of task?
gradle 1.6 introduced incubating feature called incrementaltasksinputs
allows access files changed or removed since last task run.
ref: https://gradle.org/docs/current/dsl/org.gradle.api.tasks.incremental.incrementaltaskinputs.html
class incrementalreversetask extends defaulttask { @inputdirectory def file inputdir @outputdirectory def file outputdir @taskaction void execute(incrementaltaskinputs inputs) { inputs.outofdate { change -> def targetfile = project.file("$outputdir/${change.file.name}") targetfile.text = change.file.text.reverse() } inputs.removed { change -> def targetfile = project.file("$outputdir/${change.file.name}") if (targetfile.exists()) { targetfile.delete() } } } }
Comments
Post a Comment