title: How to compile single class dependency in gradle outside the main project
body: <p>I have a gradle project that contains only Selenium/TestNG test classes.  They are executed against a deployed war application.  All works fine and now I'm adding a java utility that will query the test base and print list of tests that belong to a given TestNG group.  The utility should be compiled and executed separate from the main project, as users may want to query the test base before test execution.</p>
  
  <p>I added the following to build.gradle:</p>
  
  <pre><code>task listgroups(dependsOn:'buildUtil' ) &lt;&lt;{
      ant.java(classname: 'util.TestGroupScanner', fork: true,
              classpath: "src/test/java")
  }
  
  task buildUtil {
      compile {
          source = "src/test/java/util"
      }
  }
  </code></pre>
  
  <p>However, when calling listgroups task, I'm getting the following error:</p>
  
  <pre><code>C:\console-bg1&gt;g listgroups
  
  FAILURE: Build failed with an exception.
  (...)
  
  * What went wrong:
  A problem occurred evaluating root project 'console-bg1'.
  &gt; Could not find method compile() for arguments [build_4emu7duna2isgubc1k8uts8k9
  8$_run_closure6_closure11@d210ab] on root project 'console-bg1'.
  </code></pre>
  
  <p>I'm not sure how to resolve this issue and needless to say, haven't found an answer online so far.  Any pointers appreciated.</p>