1

I like to setup a usual multi project build with gradle. The project structure looks like the following:

root/
  build.gradle
  settings.gradle
  share/
    build.gradle
  domain/
    build.gradle
  web/
    build.gradle

As you might guess, domain depends on share and web depends on share and domain.

There are two ways to descripe this dependenies:

  1. specify the dependencies for all sub projects in root/build.gradle
  2. specify the dependencies per sub project in root/{sub_project}/build.gradle

I prefer the second option because a project should know its dependencies. Is there anything wrong about this approach? I ask because the most examples found in the internet and in the gradle documentation uses approach 1.

scheffield
  • 6,618
  • 2
  • 30
  • 31
  • It's not clear to me what you mean by 1. It could mean to declare common dependencies in `allprojects` (which is fine), or it could mean to only use a single build script for configuring multiple projects (I prefer to have a separate build script for each project). – Peter Niederwieser Oct 09 '13 at 15:43

1 Answers1

2

Both are correct approaches, the project we're building using gradle uses the second approach, keeps the knowledge of the domain localized and easy to change.

Hiery Nomus
  • 17,429
  • 2
  • 41
  • 37