title: How to use exec() output in gradle
body: <p>I am trying to implement a gradle task to dynamically create a buildsignature.properties file from a series of environment variable values and shell executions.  I have it mostly working, but I can't seem to get the output of the shell commands.  Here's my task...</p>
  
  <pre class="lang-groovy prettyprint-override"><code>task generateBuildSignature &lt;&lt; {
      ext.whoami = exec() {
          executable = "whoami"
      }
      ext.hostname = exec() {
           executable = "hostname"
      }
      ext.buildTag = System.env.BUILD_TAG ?: "dev"
  
      ant.propertyfile(
          file: "${buildDir}/buildsignature.properties",
          comment: "This file is automatically generated - DO NOT EDIT!" ) {
          entry( key: "version", value: "${project.version}" )
          entry( key: "buildTimestamp", value: "${new Date().format('yyyy-MM-dd HH:mm:ss z')}" )
          entry( key: "buildUser", value: "${ext.whoami}" )
          entry( key: "buildSystem", value: "${ext.hostname}" )
          entry( key: "buildTag", value: "$ext.buildTag" )
      }
  }
  </code></pre>
  
  <p>But the resulting properties field does not get the desired results for buildUser and buildSystem.</p>
  
  <pre><code>#This file is automatically generated - DO NOT EDIT!
  #Mon, 18 Jun 2012 18:14:14 -0700
  version=1.1.0
  buildTimestamp=2012-06-18 18\:14\:14 PDT
  buildUser=org.gradle.process.internal.DefaultExecHandle$ExecResultImpl@2e6a54f9
  buildSystem=org.gradle.process.internal.DefaultExecHandle$ExecResultImpl@46f0bf3d
  buildTag=dev
  </code></pre>
  
  <p>How do I get buildUser and buildSystem to match the output of the corresponding exec rather than some default ExecResultImpl toString?  This really can't be that hard, can it?</p>