Inheriting common dependencies from parent project in child projects


(tulsoba) #1

I have 3 products that all have some common dependencies and some “local” dependencies. In maven you would typically create a multi-module project like:

parent
 -> product_one
 -> product_two
 -> product_three

in the parent project all common dependencies for the product_* projects are specified and each of the products local dependencies are specified in its own project. How do I do this in gradle?

I have looked at multi-module projects in gradle using a settings.xml file to specify the submodules but how do I specify that sub-modules should inherit dependencies from some “abstract” parent?


(Jon Austen) #2

My project is configured that way but I am making a lot of changes to my build.gradle file today, so that all projects aren’t sharing the same build.gradle file, and so you might want to look at the January 22nd version of my root projects build.gradle file. https://github.com/djangofan/WebDriverTestingTemplate

NOTE: By the way, if any Gradle experts out there look at my build.gradle files and see anything that can be improved, PLEASE let me know.

It has been rough going so far but slowly learning.


(tulsoba) #3

Thanks. As I understand its just a matter of having an “allprojects” scope in the parent containing the common dependencies:

allprojects {
            dependencies {
        compile group: 'commons-collections', name: 'commons-collections', version: '3.+'
        ...
    }
      }

and then these will be available by the subprojects.

I am a bit confused about how you have organized the physical folders though. As I understand its organized like this:

WebDriverTestingTemplate-21dxxx
   -> Core
         -> bing
         -> google

why do you have 3 levels?


(Peter Niederwieser) #4

There is also ‘subprojects { … }’.