title: Maven plugin crossed execution order
body: <p>I'm writing some integration tests using failsafe plugin.</p>
  
  <p>I want to execute the following:</p>
  
  <p>1) Start Docker (goal start in phase pre-integration-test)</p>
  
  <p>2) Start Spring (goal start in phase pre-integration-test)</p>
  
  <p>3) Tests (phase integration-test)</p>
  
  <p>4) Stop Spring (goal stop in post-integration-test)</p>
  
  <p>5) Stop Docker (goal stop in post-integration-test)</p>
  
  <p>Why? I want to start Docker BEFORE Spring so all databases are ready when Spring boots and also I want to stop Docker AFTER Spring to avoid a lot of errors in Spring due to database connection losses.</p>
  
  <p>I have the following pom.xml:</p>
  
  <pre><code>        &lt;plugin&gt;
              &lt;groupId&gt;io.fabric8&lt;/groupId&gt;
              &lt;artifactId&gt;docker-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;0.20.1&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;run-docker-containers&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;start&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          ...
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
                  &lt;execution&gt;
                      &lt;id&gt;stop-docker-containers&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;stop&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;pre-integration-test&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;start&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          ...
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
                  &lt;execution&gt;
                      &lt;id&gt;post-integration-test&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;stop&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  </code></pre>
  
  <p>But with this pom.xml I'm getting this order:</p>
  
  <p>1) Start Docker</p>
  
  <p>2) Start Spring </p>
  
  <p>3) Tests </p>
  
  <p>4) Stop Docker </p>
  
  <p>5) Stop Spring</p>
  
  <p>This is, Docker is stopped BEFORE Spring and I don't want that.</p>
  
  <p>I know that the execution order in Maven is given by the order in pom.xml, but in this case I need to have crossed goals.</p>
  
  <p>Any advice?</p>
  
  <p>Thanks.</p>