title: What is the difference between 'all' and 'each' in gradle?
body: <p>I'm working with Android Studio and the Gradle build script. When I was going to change some settings I needed to iterate some fields. But I have not very clear the difference between <code>all</code> and <code>each</code>.</p>
  
  <p>For example I googled some code to change the output <em>apk</em> file name. The code iterates the <code>applicationVariants</code> by <code>all</code> and the <code>variant.outputs</code> by <code>each</code>:</p>
  
  <pre><code>applicationVariants.all { variant -&gt;
     variant.outputs.each { output -&gt;
        output.outputFile = new File(output.outputFile.parent, "MyApp.apk")
     }
  }
  </code></pre>