I’m trying to include an external gradle script that holds the whole buildscript block like this:
apply from: "lib/gradle/buildscript.gradle"
apply plugin: "myplugin"
where buildscript.gradle is:
buildscript {
repositories {
def libDir = new File(project.projectDir.canonicalPath, '../Build/lib'
flatDir dirs: libDir
}
dependencies {
classpath 'my.group:mylib:1.0'
}
}
However, I’m getting an error in the build saying "Plugin with id ‘myplugin’ not found.
If I move the entire block into the main build.gradle it works fine, but I really want to hide as much of the plumbing as possible from devs, and making it maintainable over multiple projects from one place. I can also move the “apply plugin: ‘myplugin’” line into buildscript.gradle and it works too.
I’ve tried doing as suggested on http://forums.gradle.org/gradle/topics/inherit_inject_buildscript_dependencies_into_custom_script_within_subproject and having format:
buildscript {
apply from: "path/to/buildscript.gradle", to: buildscript
}
and removing the surrounding “buildscript { }” from that file, however, any properties I reference in buildscript.gradle (like “project.projectDir”) come back with “Could not find property ‘project’ on repository container.”
In this particular case, I can make everything relative without referencing project.projectDir at all, so I can get away with it. But is this just a limitation of the method or a lack of understanding by me?
So I’m trying to find the best way to combine both styles to minimize the copy paste over many projects.
cheers,