How to handle UP-TO-DATE on task with same input and output?

I have 2 tasks :

task('resizeImages', type: Magick) {
  input fileTree(dir: 'resources', include: '**/*.png')
  output 'out/resources/480x800'
  convert {
    resize resolution.ratio
  }
}
  task('applyNinePatch', type: Magick, dependsOn: 'resizeImages') {
  input fileTree(dir: 'out/resources/480x800', include: '**/*.9.png')
  output 'out/resources/480x800'
  convert {
    border {
      width 1
      color 'none'
    }
    xc 'black'
    gravity 'North'
    geometry '1x1+0x+0'
    composite()
    xc 'black'
    gravity 'West'
    geometry '1x1+0x+0'
    composite()
  }
}

the input FileTree is stored in a property with @InputFiles annotation, the outpout File in a property with @OutputDirectory.

My problem is that resizeImages is executed all the time, even when the input files are not modified, because the output files are modified by applyNinePatch. I tried to add “outputs.upToDateWhen { true }” on resizeImages, without success.

Thanks in advance for your answers.

To use the up-to-date feature, you’ll have to use separate input and output files/directories.