title: Gradle task which depends on bootRun
body: <p>I have two mutually exclusive tasks that both should launch <code>bootRun</code> when they are complete.</p>
  
  <p>I mention that they are mutually exclusive because I don't want <code>bootRun</code> to depend on either of them.  Instead, I am looking for a flow similar to the following:</p>
  
  <pre><code>task A() {
     // setup for task A
     // runs bootRun on completion
  }
  
  task B() {
     // Does some things
     // runs bootRun on completion
  }
  </code></pre>
  
  <p>I've tried the following,</p>
  
  <pre><code>task C() {
   // Performs the task A setup
  }
  
  task A() {
   dependsOn 'C'
   dependsOn 'bootRun'
  }
  </code></pre>
  
  <p>so that <code>gradle A</code> would launch the setup (<code>task C</code>) and bootRun (with a similar setup for <code>task B</code>).  This results in <code>Task with path 'bootRun' not found in project ':x'</code></p>
  
  <p>I've also tried declaring the A/B tasks as:
  <code>task A(type: org.springframework.boot.gradle.run.BootRunTask)</code>, but that results in the error <code>Could not get unknown property 'org' for project ':x' of type org.gradle.api.Project</code></p>
  
  <p>How can I write a task in gradle that will launch bootRun when it completes?</p>
  
  <p>Edit:</p>
  
  <p>This is a multi-module setup which looks something like:</p>
  
  <pre><code>settings.gradle
  build.gradle
  Application module
     build.gradle (spring boot plugin lives here)
     main() lives here
  Service module
     build.gradle (this is where tasks A and B live)
  </code></pre>
  
  <p>The spring boot plugin is provided in the Application module's build.gradle via:</p>
  
  <pre><code>plugins {
     id 'org.springframework.boot' version '2.0.0.RELEASE'
  }
  </code></pre>
  
  <p>I can add this same plugin to the Service module as well, though it won't know what the main class is.</p>