Question: Can composite build include another composite build? (Nested Composite Builds)

Yes, a composite build can include another composite build in Gradle, but there are some limitations to consider. Gradle allows you to include other builds using includeBuild, which links external builds into your project. However, when dealing with nested composite builds (where one composite build includes another), it's important to note that Gradle does not allow recursively nesting composite builds by default.

In other words:

  • You can include multiple independent builds into a composite build.
  • Nested composite builds (one composite build including another composite build) are NOT fully supported and could lead to issues with dependency resolution and configuration. (according to GPT)

Key Points:

  • Flat structure: It’s recommended to keep a flat structure when using composite builds, where each composite build includes independent projects directly.
  • Workaround: If you need to link multiple composite builds, you might need to manage them manually or rely on external tools, but this requires careful consideration of dependencies and task executions.

You can learn more about this in the official Gradle documentation on composite builds.

From official documentation:

When a composite build is included in another composite build, both builds have the same parent. In other words, the nested composite build structure is flattened. - ref


Backlinks