Optimizing up-to-date check in a batch task (run task for individual files)


(Alejandro Salas) #1

Hello everyone,

I have the following task which goes through all java files and processes them with the Delombok Ant Task. http://projectlombok.org/features/delombok.html

The up to date check is working as I would expect with the inputs/outputs I have. The problem with this is that if I modify one single java file, the task runs for all files which is unnecessary. The Ant Task does not perform an up to date check.

What I want is the task to run targeting just the modified files and not the whole set of java files. I don’t know if this is possible and if so, if it’s possible just by modifying the script or if it would involve the Ant Task (which I don’t control).

Thanks in advance.

task delombok {
    inputs.files file(srcJava)
    outputs.dir file(srcDelomboked)
          doLast {
        FileCollection collection = files(configurations.compile)
        FileCollection sumTree = collection + fileTree(dir: 'bin')
            ant.taskdef(name: 'replacer', classname: 'lombok.delombok.ant.DelombokTask', classpath: configurations.compile.asPath)
         ant.replacer(from:srcJava, to:srcDelomboked, classpath: sumTree.asPath)
    }
}

(Peter Niederwieser) #2

There isn’t currently a way to ask Gradle which inputs have changed, but it’s on our list of things to do. Meanwhile, you could implement your own solution (e.g. based on file timestamps), and use that instead of Gradle’s up-to-date check.


(Alejandro Salas) #3

Thank you for the answer. I’ll look into it to see how it goes.