Something like the following groovy (please convert to kotlin)
task gitLog {
ext.outfile = file("$buildDir/commit.json")
outputs.file outfile
doLast {
outfile.withOutputStream { out ->
project.exec {
commandLine "bash ${utilDir}/build/git-log2json.sh".split(' ')
standardOutput = out
ignoreExitValue = false // don't need this line, it's the default
}
}
}
}
See ExecSpec