You can have a build.gradle in buildSrc that does the same thing, I believe. Are you having problems with that and do you have a small project to recreate?
Looking at your code snippet, I notice a few things you could improve. Because you’re adding to the main classpath during the execution (vs configuration) phase, you could run into ordering problems.
A more Gradle-idiomatic looking example might look like this:
configurations {
bundlecfg
}
task extractJarBundle(type: Copy, dependsOn: configurations.bundlecfg) {
from { configurations.bundlecfg.collect { zipTree(it) } }
into "${buildDir}/lib"
}
dependencies {
bundlecfg 'group:bundle:someVersion'
compile fileTree(tasks.extractJarBundle.outputs.files.singleFile) {
builtBy tasks.extractJarBundle
include "**/*.jar"
}
}
This uses the ‘builtBy’ property of the file collections to auto-wire things together (compileJava needs configurations.compile which needs extractJarBundle which needs configurations.bundlecfg).