Gradle clean task with bmuschko/gradle-docker-plugin
<p>I'm trying to create a Gradle task that will run a clean, a build, and then run a buildDockerImage task from the bmuschko/gradle-docker-plugin plugin. I can successfully run the clean task, build task, and buildDockerImage task in separate commands in the command line but when I try to create a singe task that does all three I get an error: </p>

<pre><code>.../config-server/build/docker/state/DockerBuildImage_Decorated (No such file or directory)
</code></pre>

<p>It looks like the gradle-docker-plugin is trying to add some sort of log file to the /build/docker/state directory but that directory is not present when I run clean, build, and buildDockerImage in a single task. The directory is present however when I run these as separate commands in the CLI. </p>

<hr>

<h3>This Works</h3>

<p>If I don't try to clean... it works correctly and the docker image gets created:</p>

<pre><code>import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
task buildDockerImage(type: DockerBuildImage) {
  doFirst {
    copy {
      from 'src/main/resources/docker/Dockerfile'
      into 'build/libs'
    }
  }

  inputDir = project.file('build/libs')
  tag = alexFabian + "/" + jar.baseName
}

task myBuildDockerImage(type: Task, dependsOn: ['build' ,'buildDockerImage']) {
  buildDockerImage.mustRunAfter build
}
</code></pre>

<p>My build directory looks like : </p>

<pre><code>/classes
/dependency-cache
/docker
/libs
/reports
/resources
/test-results
/tmp 
</code></pre>

<hr>

<h3>This Fails</h3>

<p>But when I add in a dependency on the 'clean' task... the buildDockerImage task fails because it can't find the /build/docker directory</p>

<pre><code>import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
task buildDockerImage(type: DockerBuildImage) {
  doFirst {
    copy {
      from 'src/main/resources/docker/Dockerfile'
      into 'build/libs'
    }
  }

  inputDir = project.file('build/libs')
  tag = afabian + "/" + jar.baseName
}

task myBuildDockerImage(type: Task, dependsOn: ['clean', 'build' ,'buildDockerImage']) {
  build.mustRunAfter clean
  buildDockerImage.mustRunAfter build
}
</code></pre>

<p>Now my build/ directory looks like this (missing the /docker directory): </p>

<pre><code>/classes
/dependency-cache
/libs
/reports
/resources
/test-results
/tmp
</code></pre>

<p>And I get this error :</p>

<pre><code>Execution failed for task ':buildDockerImage'.
&gt; .../config-server/build/docker/state/DockerBuildImage_Decorated (No such file or directory)
</code></pre>

<p>I've used Maven in the past and new to Gradle so my current understanding is limited. </p>

<ul>
<li>Using gradle (wrapper) : 2.11  </li>
<li>Using gradle-docker-plugin : com.bmuschko:gradle-docker-plugin:2.6.6</li>
</ul>

<p>Any help is appreciated! </p>