The anatomy of a multimodule build
Usually, a multimodule project works by having a root directory that contains all modules in subdirectories. To tell Gradle how the project is structured, and which directories contain modules, you need to provide a settings.gradle
file in the root of the project. Each module can then provide its own build.gradle
file. We already learned how settings.gradle
and the build.gradle
files work in Chapter 2, Basic Build Customization, so here we will just focus on how to use them for multimodule projects.
This is what a multimodule project could look like:
project ├─── setting.gradle ├─── build.gradle ├─── app │ └─── build.gradle └─── library └─── build.gradle
This is the simplest and most straightforward way to set up a project with multiple modules. The settings.gradle
file declares all the modules in the project and looks like this:
include ':app', ':library'
This makes sure that the app and library modules are included in the build configuration. All you...