What is the difference between inheritance and configuration injection?

The Gradle docs state (49.9):

Properties and methods declared in a project are inherited to all its subprojects. This is an alternative to configuration injection. But we think that the model of inheritance does not reflect the problem space of multi-project builds very well. In a future edition of this user guide we might write more about this.

I understand what configuration injection is doing in principle, but I’d like to understand more about the distinctions from inheritance, and why it’s a better fit for multi-project builds.

Can anyone give me a few bullets on this?


Configuration injection is an equally concise yet more flexible and explicit mechanism than configuration inheritance (as used by build tools like Maven). Instead of applying all configuration to all subprojects, it allows you to apply any configuration to any set of subprojects. This lets you accurately express commonalities and differences between projects.

Thanks, Peter. I reviewed the docs and see that I missed the discussion on applying configuration to a single project (I only noticed allprojects and subprojects). That’s clearer now.

You can apply configuration to any subset of projects.

One other difference is that configuration can be injected from any direction, not just parent

→ child.