Organizing common dependencies accross multiple sourceSets

My project has multiple sourceSets (instead of subprojects) as below:

myproj
    src
        module1
            java
            resources
        module2
            java
        main
            java
        test
            java

Modules have common dependencies, for example module1, module2 and main all depend on Spring libraries. Now I specify the dependencies for each module like module1Compile, module2Compile which looks pretty redundant (to me). Is there any way to specify common dependencies accross the sourceSets? I am wondering if ‘configurations’ can be used to achieve some grouping among the sourceSets dependencies.

Thanks!

Your module1Compile, module2Compile, compile can all be set to extend some configuration expressing those common dependencies. Note that while your setup is certainly OK and will work with Gradle it is likely that your IDE setup will need some tweaks and will be only an approximation of Gradle’s view of your build. That would be one reason I’d favor to do the more common split into several modules rather than using sourceSets too extensively.

Thank you for the reply! I’ll try configurations for this.

It would be great if you please brief your favored way to organize multi-module projects, I am pretty newbie in Gradle.

Thanks again.

It would be great if you please brief your favored way to organize multi-module projects, I am pretty newbie in Gradle.