Incremental compilation on task which calls a third party tool on multiple subdirectories


(william.r.phillips.jr) #1

I have a task which uses and “exec” task to call a third party tool on each subdirs below an arbitrary directory in the project:

task thirdparty {
    def units = []
    file('thirdparty/').eachDir { d -> units.add(d.name) }
    units.each  { unit ->
        exec {
            workingDir "thirdparty/$unit"
            commandLine 'mytool', 'build'
        }
    }
}

This works for me, but it does not allow incremental compilation: each unit is built on every compile.

I have been trying to make this incremental by adding inputs and outputs to the exec task:

task thirdparty {
    def units = []
    file('thirdparty/').eachDir { d -> units.add(d.name) }
    units.each  { unit ->
        exec {
            inputs.source fileTree(dir: "thirdparty/$unit")
            outputs.dir file("thirdparty/build/$unit")
            workingDir "thirdparty/$unit"
            commandLine 'mytool', 'build'
        }
    }
}

However, this doesn’t seem to work for me.
Each directory build happens, and then reports “up-to-date”.

Any recommendations on what to do to solve this one?