title: gradle doLast philosophy
body: <p>In a gradle build file, there are multiple ways to specify the items executed for a particular task. the doFirst method puts a task item on the top of the task stack, so that the item is executed before the rest of the task stack. This is very handy if you need to do some preparatory items before the main task. In fact, if you call doFirst several times, the item added in the last call is the first thing executed.</p>
  
  <p>In theory, doLast should be doing something similar, but doLast should get called AFTER the main execution of the task is complete. But, in gradle 1.2, if you call doLast and then add something to the main task after doLast in the gradle.build file, the main task item is the last item called. For example, the following gradle build file:</p>
  
  <pre><code>task myTask
  
  myTask &lt;&lt; {
      println "myTask main execution block"
  }
  
  myTask.doFirst {
  println "myTask doFirst call one"
  }
  
  myTask.doFirst {
      println "myTask doFirst call two"
  }
  
  myTask.doLast {
      println "myTask doLast"
  }
  
  myTask &lt;&lt; {
      println "myTask more main execution block"
  }
  </code></pre>
  
  <p>Produces the following output:</p>
  
  <pre><code>:myTask
  myTask doFirst call two
  myTask doFirst call one
  myTask main execution block
  myTask doLast
  myTask more main execution block
  
  BUILD SUCCESSFUL
  
  Total time: 1.585 secs
  </code></pre>
  
  <p>My question is this: Is it the intent of doLast to simply append steps onto the end of the task (like doFirst tacks on to the beginning)? If so, doLast seems pointless with the exception of providing symmetry with doFirst. A user can simply do myTask &lt;&lt; {...} to append something on to the end. I would have thought that doLast would make sure that any "doLast" items would be done after the main execution block.</p>
  
  <p>Is this simply the way gradle's doLast is supposed to work, or is this a bug?? (or am I just stupid for appending something onto the main execution block after calling doLast -- which was a simple mistake after tacking in another execution block).</p>