I’m trying to create a gradle multi project build for a hierarchy of projects. They aren’t java projects, and I don’t know of any other plugin type that would fit either. I want to take advantage of gradle’s support for dependencies and build order.
My problem is that when I build a project, I can’t get gradle to trigger a build of the projects I am depending on.
Let’s say I have projects proj-a and proj-b that all need to build something. proj-b is dependent on proj-a building first: proj-b -> proj-a
If I build proj-b, I want proj-a to automatically build first. I’ve tried creating this as a multi project build, but I can’t get it working. This is what i’ve got so far:
// settings.gradle
include ( 'proj-a', 'proj-b')
// build.gradle
subprojects {
task buildStuff(type: Jar) << {
println "buildStuff for $project.name"
}
configurations {
compile
}
artifacts {
compile buildStuff
}
}
project(':proj-b') {
dependencies {
compile project(path: ':proj-a', configuration: 'compile')
}
}
project(':proj-a') {
}
I thought that this would mean that proj-b is dependent on proj-a’s “compile” configuration, which in turn is supposed to run task “buildStuff”. I thought that this would mean that when I run “buildStuff” on proj-b, it would trigger running “buildStuff” on proj-a, but I’m obviously not getting it.
The actual results are:
If I run ’ gradle dependencies’ for proj-b, I get: ‘’’ compile — gradle-deps:proj-a:unspecified ‘’’
And if I run ‘gradle buildStuff’ in proj-b, I get: ‘’’ :proj-b:buildStuff buildStuff for proj-b ‘’’
My expectation here was that “:proj-a:buildStuff” would be built before “:proj-b:buildStuff”, but it isn’t.
What am I getting wrong here? Am I missing some detail, or have I completely misunderstood project dependencies and configuratons?
Any tips on how I change my scripts to get this working?