title: How to append a Gradle Task without using `dependsOn`?
body: <p>I am using Gradle to build a Java project involving native libraries. I have a task <code>jniHeaders</code> defined:</p>
  
  <pre><code>jniHeaders.dependsOn classes
  </code></pre>
  
  <p>so when I type <code>gradle jniHeaders</code>, it will compile the Java classes and generate JNI headers. So far so good.</p>
  
  <p>But I feel that typing <code>gradle jniHeaders</code> is not very natural. And 99% of the time, if you compile Java classes successfully, you'd want to generate JNI headers as well. It would be nice if I could <code>gradle classes</code> to compile Java classes and generate JNI headers in one step. </p>
  
  <p>In other words, <strong>I want to add the task <code>jniHeaders</code> to the end of the task <code>classes</code>, but only if <code>classes</code> is completed sucessfully and actually did some work.</strong></p>
  
  <p><code>classes.doLast</code> comes to mind, but I am unable to tell it to execute another task. <code>classes.finalizedBy jniHeaders</code> works to an extent, but generates JNI headers regardless of the outcome of <code>classes</code>. I suppose I could add some Groovy logic to get the exact behavior I want, but I also suspect there must be an easier way.</p>
  
  <p>Anyone has any suggestions?</p>