title: How to do something before Gradle task's dependencies are executed?
body: <p>I have the following in <code>build.gradle</code>:</p>
  
  <pre class="lang-groovy prettyprint-override"><code>task aoeu &lt;&lt; {
      println "**************************** during"
  }
  
  tasks.publish.dependsOn(aoeu)
  
  tasks.publish.doFirst {
      println "************************* before"
  }
  
  tasks.publish.doLast {
      println "************************* after"
  }
  </code></pre>
  
  <p>Its output is:</p>
  
  <pre><code>:aoeu
  **************************** during
  :publish
  ************************* before
  ************************* after
  </code></pre>
  
  <p>But what I really need is for the 'during' to happen between 'before' and 'after'. How can this be done? Should 'publish' simply depend on 'before'? If so, how can I guarantee that it happen before other dependencies?</p>