title: Gradle custom task action order
body: <p>I'm looking at a simple example of a custom task in a Gradle build file from Mastering Gradle by Mainak Mitra (page 70). The build script is:</p>
  
  <pre><code>println "Working on custom task in build script"
  
  class SampleTask extends DefaultTask {
      String systemName = "DefaultMachineName"
      String systemGroup = "DefaultSystemGroup"
      @TaskAction
      def action1() {
        println "System Name is "+systemName+" and group is "+systemGroup 
      }
      @TaskAction
      def action2() {
        println 'Adding multiple actions for refactoring'
      }
  
  }
  
  task hello(type: SampleTask)
  hello {
      systemName='MyDevelopmentMachine'
      systemGroup='Development'
  }
  
  hello.doFirst {println "Executing first statement "} 
  hello.doLast {println "Executing last statement "}
  </code></pre>
  
  <p>If I run the build script with gradle -q :hello, the output is:</p>
  
  <pre><code>Executing first statement 
  System Name is MyDevelopmentMachine and group is Development
  Adding multiple actions for refactoring
  Executing last statement 
  </code></pre>
  
  <p>As expected with the doFirst method excecuting first, the two custom actions executing in the order in which they were defined, then the doLast action executing. If I comment out the lines adding the doFirst and doLast actions, the output is:</p>
  
  <pre><code>Adding multiple actions for refactoring
  System Name is MyDevelopmentMachine and group is Development
  </code></pre>
  
  <p>The custom actions are now executing in the reverse order in which they are defined. I'm not sure why.</p>