title: Gradle - how to prevent dependent submodule's tasks from running if dependent task fails?
body: <p>In a multi-module project with modules <code>mod-a</code> and <code>mod-b</code>, <code>mod-b</code> has <code>mod-a</code> as a project lib dependency:</p>
  
  <pre><code>project(":mod_b") {
      dependencies {
          implementation project(':mod_a')
      }
  }
  </code></pre>
  
  <p>Both <code>mod-a</code> and <code>mod-b</code> are configured to publish Maven artifacts (jars) if their tests pass, using the <a href="https://docs.gradle.org/current/userguide/publishing_maven.html" rel="nofollow noreferrer">maven-publish plugin</a>:</p>
  
  <pre><code>// within each module's build.gradle
  tasks.withType(AbstractPublishToMaven) {
      dependsOn test
  }
  </code></pre>
  
  <p>When I run Gradle with the <a href="https://docs.gradle.org/current/userguide/command_line_interface.html#sec:continue_build_on_failure" rel="nofollow noreferrer"><code>--continue</code></a> flag then if tests in <code>mod-a</code> fail then no <code>mod-a</code> artifacts are published.  However, artifacts are published for <code>mod-b</code>.  Why is this and how to I prevent this happening (I wish to continue to use the <code>--continue</code> option)?</p>
  
  <p>e.g. this results in publishing of <code>com.example:mod-b:x.y.z</code>, when I do not wish it to:</p>
  
  <pre><code>./gradlew --continue clean publishToMavenLocal
  </code></pre>
  
  <p>i.e. if there were 3 modules (<code>mod-a</code> <code>-depends-on-&gt;</code> <code>mod-b</code> <code>-depends-on-&gt;</code> <code>mod-c</code>), then if only <code>mod-b</code>'s tests fail and then only <code>mod-a</code> should be published).</p>