A task in a shared build script (and that task needs external dependencies) can't resolve its dependencies

I have a build script ‘build.gradle’ than contains the following working task definition:

buildscript {
    dependencies {
        classpath(group: 'org.ajoberstar', name: 'gradle-git', version: '0.6.3')
    }
}
  import org.ajoberstar.gradle.git.tasks.*
  task gitTag(type: GitTag) {
    tagName = "release/$version"
    message = "Release of ${version}"
}

Note: I do have a repository section in the buildscript closure but stripped it as it contains credentials, etc.

I want to move this to a sharable build script ‘gradle/gradle-git.gradle’(for creating a plugin later). As I do that and run ‘gradle gitTag’ gradle complains with ‘Could not find org.ajoberstar:gradle-git:0.6.3’.

I have tried various attempts to fix this in build.gradle by adding:

buildscript {
    apply from: "$rootDir/gradle/gradle-git.gradle"
}
apply from: "$rootDir/gradle/gradle-git.gradle"

Also I tried to move ‘gradle/gradle-git.gradle’ to ‘buildSrc/build.gradle’ but that didn’t substantially change my situation.

I didn’t find the user guide very clear on that. Do I have to publish this as a standalone plugin or can I still keep that just in a separate script? My build script already grows fairly big and I need to start working towards plugins. Yet I can’t take the effort to create standalone plugins (unless this is the only way).

I’m working with Gradle 1.10.

It’s a known limitation. The ‘buildscript’ block needs to go into the build script that applies the script plugin (or at least into the root project’s build script).