Stale output directories being cleaned up

(Eric Deandrea) #1

Starting with Gradle 4.2 - I have run into this “feature” -

I am building my own plugin which is wiring 2 other plugins together (both plugins I do not own). Envision this scenario:

  • Plugin A (I do not own) has task B, which outputs some files into directory C (under $buildDir)
  • Plugin X (I do not own) has task Y, which outputs some files into directory Z (under $buildDir)
  • Plugin D (I own) has a Copy task E. Task E copies a certain subset of files from directory Z and places them into directory C
  • Task E in plugin D dependsOn tasks B & Y, so they will run first

Everything was great until I tried to update to Gradle 4.2 and hit the safer handling of stale output files. Now when task E goes to run, it first deletes the contents of directory C, since it considers it “stale”, even though my goal is to copy additional files into a directory which already existed.

How do I stop this behavior?

(Eric Deandrea) #2

I actually fixed this myself. I declared additional output directories on tasks B & Y so therefore Gradle didn’t consider them stale.