title: gradle: calling a task from another task
body: <p>I am aware that the currently supported method for invoking a task from another task is to use <code>dependsOn</code> or <code>finalizedBy</code>, but I run into an issue with this.</p>
  
  <p>I have a task, <code>taskA</code>, that is usable on it's own.  I have another task, <code>taskB</code>, which, when called, will depend upon <code>taskA</code>.  The problem is that <code>taskB</code> has additional conditions that require the task be skipped if they fail. Here is the workflow I am going for:</p>
  
  <pre><code>$ gradle taskA
  :taskA
  
  BUILD SUCCESSFUL
  $ gradle taskB
  checking condition 1... PASS
  checking condition 2... PASS
  :taskA
  :taskB
  
  BUILD SUCCESSFUL
  $ gradle taskB
  checking condition 1... PASS
  checking condition 2... FAIL
  :taskA SKIPPED
  :taskB SKIPPED
  
  BUILD SUCCESSFUL
  </code></pre>
  
  <p>If called directly, or as a <code>doFirst</code> or <code>dependsOn</code> or something from a different task, <code>taskA</code> should execute regardless of the conditions.  But if <code>taskB</code> is called, the conditions must pass before <code>taskA</code> is executed.  Here's what I've tried:</p>
  
  <pre><code>project.tasks.create(name: "taskB", type: MyTask, dependsOn: "taskA")
  project.taskB{
    onlyIf {
      if (!conditionA()){
        return false
      }
      if (!conditionB()){
        return false
      }
      return true
    }
  }
  </code></pre>
  
  <p>The problem here is that <code>taskA</code> will execute before the <code>onlyIf</code> is checked on <code>taskB</code>, so even if a condition fails, <code>taskA</code> will execute.</p>
  
  <p>How can I accomplish this?</p>