title: How to execute a task of type 'JavaExec' before compileJava
body: <p>I need to execute a java class which has a main method in it before compiling the code. This is what I have tried so far:</p>
  
  <pre><code>task runSimple(type: JavaExec) {
      main = 'jjrom.ObjectGen'
      classpath = sourceSets.main.runtimeClasspath
      File prop1 = file(propFilePath)
      args '-sqlserver', '-force', prop1.path
      println "I'm done executing."
  }
  compileJava {
      dependsOn runSimple
  }
  </code></pre>
  
  <p>When I execute this script with the command "gradle compileJava" , I get this error message:</p>
  
  <p>I'm done executing.</p>
  
  <p>FAILURE: Build failed with an exception.</p>
  
  <p>What went wrong: Circular dependency between the following task: :classes --- :compileJava --- :runSimple --- :classes (*)</p>