title: Using groovy classes within Gradle build
body: <p>I'm trying to run a Groovy class from within my build.gradle file. I'm following the direction in <a href="http://www.gradle.org/docs/current/userguide/groovy_plugin.html">the use guide</a> however I get an error.</p>
  
  <p>The build file is:</p>
  
  <pre><code>apply plugin: 'java'
  apply plugin: 'groovy'
  
    main {
      java {
        srcDirs = ["$projectDir/src/java"]
      }
      groovy {
        srcDirs = ["$projectDir/src/groovy"]
      }
    }
  
      dependencies {
          compile 'org.codehaus.groovy:groovy-all:2.2.0', files(....)
      }
  
      task fooTask &lt;&lt; {
          groovyClass groovyClass = new groovyClass()
          groovyClass.foo()
      }
  </code></pre>
  
  <p>The groovy class is very simple:</p>
  
  <pre><code>    public class groovyClass {
  
              public void foo() {
                      println 'foo'
              }
      }
  </code></pre>
  
  <p>However when I try to run <strong>gradlew compile fooTask</strong> I get the following error:</p>
  
  <p><strong>unable to resolve class groovyClass</strong></p>
  
  <p>Any idea why?</p>
  
  <p>Thanks</p>