title: Silently handle Gradle task failure
body: <p>I have a project which should run a specific Gradle task (<code>sonarqube</code> task) only if a condition is met after <code>build</code> task is executed. This task can fail as it communicates with a remote server which is sometimes not available. If the server is unavailable, I'd like to silently handle the error an print some message to console instead of failing the whole build.</p>
  
  <p>Currently I am able to do so with the following configuration:</p>
  
  <pre class="lang-java prettyprint-override"><code>build.doLast {
      if ('desired.value' == System.properties['some.prop']) {
          try {
              tasks.sonarqube.execute()
          } catch(e) {
              ...
          }
      }
  }
  </code></pre>
  
  <p>However using this method I get deprecation messages. After reading up a bit I supposedly should not be using <code>execute</code>, so instead I came up with this:</p>
  
  <pre class="lang-java prettyprint-override"><code>if ('desired.value' == System.properties['some.property']) {
      build.finalizedBy sonarqube
  }
  </code></pre>
  
  <p>However in this case, if <code>sonarqube</code> task fails my whole build will fail as well. How could I handle <code>sonarqube</code> task failures in such case?</p>
  
  <p>I am using Gradle <code>4.5.1</code>.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>The builds are ran using the following command:</p>
  
  <pre><code>./gradlew build
  </code></pre>
  
  <p>Modifying it like the following will cause Gradle to ignore not only <code>sonarqube</code> failures, but also <code>build</code> failures which is not what I want:</p>
  
  <pre><code>./gradlew build --continue
  </code></pre>