title: Gradle task to write hg revision to file
body: <p>Is there a simple way to write to file the mercurial version (or similar external command) in a gradle task:</p>
  
  <p>I'm not yet groovy/gradle conversant, but my current effort looks like this:</p>
  
  <pre><code>task versionInfo(type:Exec){
      commandLine 'hg id -i -b -t'
      ext.versionfile = new File('bin/$baseName-buildinfo.properties')
  
      doLast {
          versionfile.text = 'build.revision=' + standardOutput.toString()
      }
  }
  </code></pre>