Build a properties file from command line

I’d like to make a task that creates a build properties file from command line utilities. This is my best attempt:

task versionInfo(type:Exec){
    def props = new Properties()
    File propsFile = new File('assets/buildinfo.properties')
    commandLine 'hg id -i -b -t'.split()
    standardOutput = new ByteArrayOutputStream()
    props.setProperty('build.revision', standardOutput.toString() )
    commandLine 'powershell get-date'.split() // -format "{dd-MM-yyyy HH:mm}"'
    props.setProperty('build.date', standardOutput.toString() )
    props.store(propsFile.newWriter(), null)
    /*ext.versionfile = new File('assets/buildinfo.properties')

    doLast {
        versionfile.text = 'build.revision=' + standardOutput.toString() + 'build.date='
    }*/
}

Which don’t work as intented… Any help is appreciated, thanks! :slight_smile: