title: How to set environment variable using Gradle?
body: <p>I know I can't set environment variable directly from Gradle, but is there some other solution?. I need to do this:</p>
  
  <ul>
  <li>do some stuff..</li>
  <li>set 4 environment variables (their values depend on some settings)</li>
  <li>run some ant scripts (that depend on environment variables)</li>
  </ul>
  
  <p>I thought of creating a file (<code>.setenvironment</code>) with all the settings I need, and then source it from Gradle (<code>source .setenvironment</code>), but I fear that I wouldn't be able to reset the variables if something goes wrong (and I need to set "JAVA_HOME", for instance, which is also important for the build scripts themself).</p>