title: Gradle get file collection of parent directories
body: <p>I'm trying to configure a task that will generate a single report from a collection of binary junit test results, but I'm unable to create a <code>FileCollection</code> containing the paths in which all the result files are located.</p>
  
  <p>My task is defined like this</p>
  
  <pre><code>task aggregateTestREports(type: org.gradle.api.tasks.tests.TestSupport) {
     destinationDir = reportDir
     testResultsDirs = ???
  }
  </code></pre>
  
  <p>Where the ??? is the part that I'm not getting to work.</p>
  
  <p>I can use the following code to get a list of the output.bin files in our build structure, but I need to transform this into the list of the directories the files are in.</p>
  
  <pre><code>fileTree(dir: '.', includes: ['**/test-results/binary/test/output.bin'])
  </code></pre>
  
  <p>I've tried creating a custom class from the base class like this and passing the results of that line to the <code>testOutputBinFiles</code> parameter and calculating the files dynamically</p>
  
  <pre><code>class AggregateTestReport extends TestReport {
     @Input
     def testOutputBinFiles 
  
     def getTestResultDirs() {
        def parents = []
        testOutputBinFiles.each {
           File file -&gt; parents &lt;&lt; file.parentFile.absoluteFile
        }
        parents
     }
  }
  </code></pre>
  
  <p>but this gives me an error that the return value is not compatible with a <code>FileCollection</code></p>
  
  <p>The docs for <code>FileCollection</code> indicate that the only way to get a new one is to use the <code>files()</code> function, but it isn't available from within the custom class to get a new file.</p>