How do you depend on all projects beneath a subdir without naming each project?

We have a multi-project build with a bunch of libraries stored in a subdirectory:


Is it possible declare all of the lib projects as compile dependencies in the war project gradle file without naming each one individually?

You could simply iterate over the collection of subprojects.

dependencies {

subprojects.each {

compile project(it.path)



How would I turn the directory of libraries into a collection of subprojects?

Also, would I have to change the settings.gradle in the root directory?

If so, would I just add the text “libraries”, or would it be something different?

Yes, you have to change settings.gradle in order to include those subproject in your multi-project build. If you wanted to do it in a way that didn’t involve explicitly listing each library you could do something like this:

new File(rootDir, ‘libraries’).eachDir {

include “:libraries:$