Consume files from another task producing multiple files

I’m trying to incorporate wix (windows installer) and one task produces several files in the destination directory (${buildDir}\wix-obj), in the other, at the moment, I’m just trying to list the outputs and it keeps just listing the directory instead of the files. I’m not sure why that is. It is the problem I’m trying to work around because I need the explicit list of files to feed to the next command line.

task wixCandle(dependsOn: wixLibExtract) {
 description 'Preprocesses and compiles WiX source files into object files.'
    FileTree src = fileTree(dir: 'src/main/wix')
 src.include '**/*.wxs'
    inputs.files src
    doLast {
  exec {
   executable file("${buildDir}\wix-lib\wix-" + wixVersion + "\bin\candle.exe")
        args "-out", "${buildDir}/wix-obj/"
   args src
        args "-ext", "WixUtilExtension.dll"
   args "-ext", "WixUIExtension.dll"
   args "-arch", "x64"
   args "-dProductVersion=9.9.9.9"
   args "-dIsOriginalMSI=1"
  }
 }
 outputs.dir("${buildDir}\wix-obj")
}
  task wixLight(dependsOn: wixCandle) {
 outputs.upToDateWhen { false }
    doLast {
  FileCollection src = wixCandle.outputs.files
  src.each { File file -> println file.name }
 }
}

This is because a ‘FileCollection’ is exactly that, a collection of ‘File’. A directory is also represented as a single ‘File’ instance. If you want the collection of files in that directory you should probably create a ‘FileTree’.

task wixLight(dependsOn: wixCandle) {

outputs.upToDateWhen { false }

doLast {

FileCollection src = fileTree(wixCandle.outputs.files.singleFile)

src.each { File file -> println file.name }

}

}

Thanks this was exactly what I needed.