Hi, gradle allows to define plugins or other build behavior in the buildSrc folder of a gradle project. What I would like is to clone out multiple plugin projects from e.g. github into an application gradle project, and use and extend them there. Currently that is a bit of a hassle, because I seem to be able to only check out one such project at a time into buildSrc directly, and cannot have multiple or subprojects in buildSrc.
So as an example, I would like to have a folder structure like this
- myApp
-- src
--- ...
-- buildSrc
--- gradle-version-plugin (cloned from https://github.com/ben-manes/gradle-versions-plugin)
---- src
----- ...
--- gradle-node-plugin (cloned from https://github.com/srs/gradle-node-plugin)
---- src
----- ...
--- grails-gradle-plugin (https://github.com/grails/grails-gradle-plugin)
---- src
----- ...
And possibly some additional private plugins in the making.
I know I could have those projects independent and publish themto a local maven repo, and use them from there, but this makes for much slower development cycles when I ampatching stuff that goes wrong in the root myApp project.
I tried setting up a multiproject build in buildSrc using
myApp/buildSrc/setting.grade: include ‘gradle-versions-plugin’ myApp/buildSrc/build.gradle: // empty myApp/buildSrc/gradle-versions-plugin myApp/build.gradle: apply plugin ‘versions’
This actually builds the versions plugin in buildSrc, but then I get: > Plugin with id ‘versions’ not found.
I guess I could try copying the resulting files from myApp/buildSrc/gradle-versions-plugin/build/libs to
myApp/buildSrc/build/libs
but I thought it might be a good addition for gradle to either make it by default,or provide the ideal way to achieve what I want inthe documentation.
This way it will be easier for people to provide patches to custom plugins in the wild, improving the gradle ecosystem faster.
BTW: My current recipe is:
buildSrc/build.gradle
allprojects {
// make sure subprojects have jar task at config time
apply plugin: 'java'
}
/**
* gradle expects to read exploded files in build/resources and build/classes
*/
task copyDist(dependsOn: subprojects.jar) << {
subprojects.each {project ->
copy {
from "$project.buildDir/classes"
into "$buildDir/classes"
}
copy {
from "$project.buildDir/resources"
into "$buildDir/resources"
}
}
}
build.dependsOn(copyDist)
And a settings.gradle, e.g. myApp/buildSrc/setting.grade: include ‘gradle-versions-plugin’