title: Gradle JavaExec task fails with Circular dependency between the following tasks
body: <p>I have a JavaExec task which runs a Java class to generate files.  The source code generator needs to search CLASSPATH to find certain classes it uses to determine what to generate.  It needs the current project's classes to be in CLASSPATH.</p>
  
  <p>I have this task:</p>
  
  <pre><code>task showClasspath(type: JavaExec) {
      main = "com.my.codegen.Main"
      classpath = sourceSets.main.runtimeClasspath
      classpath += project(":CodeGen").sourceSets.main.runtimeClasspath
      args "generate",
  }
  </code></pre>
  
  <p>When I run this task I get "Circular dependency between the following tasks:".  So obviously I'm referring classpath back to itself. </p>
  
  <p>If I use this task then the project classes are not in CLASSPATH:</p>
  
  <pre><code>task showClasspath(type: JavaExec) {
      main = "com.my.codegen.Main"
      classpath += project(":CodeGen").sourceSets.main.runtimeClasspath
      args "generate",
  }
  </code></pre>
  
  <p>I've been going around in circles for hours on this and could really use some help.</p>
  
  <p>Thanks in advance!</p>