Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle: How to configure multiproject setup with side-by-side projects

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?

like image 407
kungfoo Avatar asked Aug 09 '11 11:08

kungfoo


People also ask

What is a multi module project Gradle?

A multi-project build in Gradle consists of one root project, and one or more subprojects. A basic multi-project build contains a root project and a single subproject. This is a structure of a multi-project build that contains a single subproject called app : Example 1.


Video Answer


1 Answers

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!

like image 199
TheKaptain Avatar answered Oct 22 '22 17:10

TheKaptain