My colleague developed an interesting little problem for gradle and I’m trying to explain it to him. I have done a search, and found some similar, I didn’t find something that solves the problem. Here it is:
caseTwo has three subprojects, alpha, bravo, and charlie
alpha depends on charlie
charlie depends on bravo
if your run gradle hello, you see the expected results:
gradle hello
:bravo:hello
Hello, I'm bravo
:charlie:hello
Hello, I'm charlie
:alpha:hello
Hello, I'm alpha
But, these projects also have a compile dependency
alpha has a compile dependency on charlie.jar
charlie has a compile dependency on bravo.jar
if you run gradle build, you get an error:
gradle build
:bravo:compileJava UP-TO-DATE
:charlie:compileJava UP-TO-DATE
:alpha:compileJava
FAILURE: Build failed with an exception.
* What went wrong:
Could not find group:extlibs,
module:charlie, version:.
Required by:
caseTwo:alpha:unspecified
=========================
The caseThree jar is very similar, but uses alphabetic ordering
bravo dependsOn alpha
charlie dependsOn bravo
gradle hello shows the dependencies:
:alpha:hello
Hello, I’m alpha
:bravo:hello
Hello, I’m bravo
:charlie:hello
Hello, I’m charlie
gradle build runs to completion.
====================================
It looks to me like dependsOn is broken… maybe somewhere in the engine it resorts to alphabetic ordering… what do you think? Am I missing something? Is there a different way to do this?
Here’s the build.gradle file for case two:
subprojects {
apply plugin: 'java'
task hello << {Task task ->
println "Hello, I'm $task.project.name"
}
}
Here’s the build.gradle in alpha
repositories {
flatDir name: 'extlibs', dirs: ["../charlie/build/libs"]
}
dependencies {
dependsOn(':charlie')
compile 'extlibs:charlie'
}
Thanks in advance and let me know if I’m leaving something useful out.