Capture Exec output using Kotlin DSL

I get the feeling that you are writing to the same output directory as the “processResources” task. Each task should use a separate output directory so that up-to-date checks /task skipping can work correctly.

Something like:

task gitLog {
   ext.logDir = file("$buildDir/gitLog")
   outputs.dir logDir
   doLast {
      file("$logDir/commit.json").withOutputStream {...}
   }
} 
processResources {
   from gitLog // adds the folder and also adds a task dependency 
}