Aggregate Dependencies from subproject Configuration

(Niclas Hedhman) #1

I have a project that consists of many, relatively independent subprojects.
Each subproject has a configuration called ‘feature’ and “compileOnly.extendsFrom feature”

Now, the rootProject needs a configuration that contains the dependencies of all the subprojects ‘feature’ configurations.

Any way I can think of will either have an empty dependency set, or that the rootProject.configurations.feature is not allowed to be modified “after it has been resolved”. Also, not able to find anything in this forum, SO or Google in general.

Any help would be much appreciated.

(Paul Merlin) #2

Hi Niclas !

Let’s say your root project has a configuration named allFeatures, just for clarity.

You could do something like this:

dependencies {
  allFeatures project(path: ':path:of:projectA', configuration: 'feature')
  allFeatures project(path: ':path:of:projectB', configuration: 'feature')
  // and so on

or, if listing all sub-projects is not possible:

dependencies {
  project.subprojects { p ->
    allFeatures project(path: p.path, configuration: 'feature')

In case I did not answer your question, is there any chance you could provide a small reproducer project with exactly what you’re trying to achieve?