Unable to find buildSrc dependencies for task rules

I am testing some task rules. I created a task rule in buildSrc. Added that to the build.gradle but my import fails.

Error message is : Could not compile build file ‘/home/suhail/projects/apconic/TestGradle/build.gradle’. > startup failed:

build file ‘/home/suhail/projects/apconic/TestGradle/build.gradle’: 16: unable to resolve class org.gradle.examples.rules.GenerateSetupRule

@ line 16, column 15.

tasks.addRule(new org.gradle.examples.rules.GenerateSetupRule(project))

^

1 error

My build.gradle file is below

apply plugin: 'java'
  sourceCompatibility = 1.5
version = '1.0'
  repositories {
    mavenCentral()
}
  dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'
    compile 'org.codehaus.groovy:groovy-all:2.3.6'
  }
  tasks.addRule(new org.gradle.examples.rules.GenerateSetupRule(project))

The rule file is in buildSrc/src/main/groovy/org/gradle/example/rules

package org.gradle.examples.rules
  import
org.gradle.api.Rule
  class GenerateSetupRule implements Rule {
    def project
      GenerateSetupRule(project) {
        this.project = project
    }
      String getDescription() {
        return 'Rule usage : <GenerateWS230_Feature_Mode>'
    }
      void apply(String taskName) {
        if(taskName.startsWith('GenerateWS')) {
            project.task(taskName) {
                println 'this is generation task'
            }
        }
    }
}

Seems like the file is in the wrong dir (‘example’ vs. ‘examples’).

I removed the package and now the rule class sits at the default package location. Still the issue is there.

Now the error is

Error:(21, 0) Cause: startup failed: build file ‘/home/suhail/projects/apconic/TestGradle/build.gradle’: 21: unable to resolve class GenerateSetupRule

@ line 21, column 15.

tasks.addRule(new GenerateSetupRule(project))

^

1 error

Well sorry for bothering you guys. Found the problem. Intellij saved my files without Groovy extension and thus they were not compiled.