Is there a way in the root build.gradle
to access the dependencies declared in the subproject build.gradle
files? I've tried the following --
subprojects.each { p ->
println "subproject: ${p.name}"
p.configurations.each { c ->
println " ${c}"
c.dependencies.each { d ->
println " ${d}"
}
}
}
but I guess because the root build.gradle
is getting executed first, the submodule dependency declarations haven't run yet, because all I get is:
subproject: foo
subproject: bar
subproject: baz
(I'm trying to write a multi-module build.gradle
for building a bunch of related modules that don't know they're part of a multi-module project, or can be part of many different multi-module proejcts. My plan was to go through the submodule dependencies programmatically and add a corresponding project
dependency to each one -- hoping to do something a little like Pieter Niederweiser's elastic-deps example but without having to modify the subproject buildfiles. In a single-module project seems like Gradle is smart enough to use project dependencies to resolve the Maven/Ivy dependencies, if they overlap.)
ETA: If there's a way to declare at the top level a block of code that all subprojects will run at some point after they've declared their dependencies, that might do it.