19

We have an old project that is set up like this:

.
├── customizationProject
│   ├── ejb
│   └── services
├── projectA
│   ├── ejb
│   └── shared
├── projectB
│   └── ejb
└── projectC
    ├── ejb
    └── services

The idea is that the customizationProject is where the final assembly of the delivered application happends, there might in fact be multiple customizationProjects and they might include multiple configurations. That, however is not the problem I'm tyring to solve.

I want to make the customizationProject the logical root project of the gradle projects. How do I configure the individual projects, so that they a) know they're part of a multiproject build b) can be properly executed, with different scopes, e.g. just running the tests of one subproject, while also allowing all tests to be executed accross all the projects?

kungfoo
  • 1,297
  • 1
  • 14
  • 27
  • This project is currently built using a shaky ant script, that knows nothing about dependencies. I want to migrate it to gradle... – kungfoo Aug 09 '11 at 11:24

1 Answers1

23

This is a fairly easy structure to support with Gradle. Add a settings.gradle file to your customizationProject directory with this content:

includeFlat 'projectA', 'projectB', 'projectC'

And you can confirm the project structure from the command line:

$ gradle projects
:projects

------------------------------------------------------------
Root Project
------------------------------------------------------------

Root project 'customizationProject'
+--- Project ':projectA'
+--- Project ':projectB'
\--- Project ':projectC'

The description of the includeFlat method is available in the Gradle documentation.

Hope that helps!

jirislav
  • 340
  • 6
  • 16
TheKaptain
  • 1,011
  • 9
  • 10
  • 4
    Important note: You need to run gradle in the directory `customizationProject` (where the settings.gradle file is), otherwise it won't find the projects. – robinst Jan 06 '12 at 16:36
  • 1
    Remember to add a lines for each project in your dependencies section like: compile (project(':projectA')) – Thomas Schütt Oct 12 '18 at 08:17