NOTE: You can open this sample in an link:{userManualPath}/gradle_ides.html#gradle_ides[IDE that supports Gradle].

== Declaring the dependencies substituted by an included build

By default, Gradle will configure each included build in order to determine the dependencies it can provide. The algorithm for doing this is very simple: Gradle will inspect the `group` and `name` for the projects in the included build, and substitute project dependencies for any matching external dependency.

In `dependencySubstitution` terms, the default substitutions are:
```
dependencySubstitution {
    ... for each project in included build ...
    substitute module("${project.group}:${project.name}") using project(":${project.name}")
}
```

== Declaring substitutions for included build

There are times when the default substitutions determined by Gradle are not sufficient, or they are not wanted in a particular composite. For these cases it is possible to explicitly declare the substitutions for an included build.

Take for example a single-project build 'unpublished', that produces a java utility library but does not declare a value for the `group` attribute:

====
include::sample[dir="kotlin/anonymous-library",files="build.gradle.kts[]"]
include::sample[dir="groovy/anonymous-library",files="build.gradle[]"]
====

When this build is included in a composite, it will attempt to substitute for the dependency module `undefined:unpublished` ('undefined' is the default value for `project.group`, and 'unpublished' is the root project name). Clearly this isn't going to be very useful in a composite build.

In order to use the `unpublished` library as-is in a composite build, the composing build can explicitly declare the substitutions that it provides.

====
include::sample[dir="kotlin",files="settings.gradle.kts[tags=composite_substitution]"]
include::sample[dir="groovy",files="settings.gradle[tags=composite_substitution]"]
====

With this configuration, the composite build will substitute any dependency on `org.sample:number-utils` with a dependency on the root project of `anonymous-library`.
