Composite builds with inverse dependency substitution

Composite builds work for me as described in the documentation, where dependencies in the composite project are replaced with projects from the included project. Meaning, that if I add

includeBuild('../foo') {
    dependencySubstitution {
        substitute module('') with project(':bar')

to settings.gradle, any usages of module “” in the composite project are replaced by the project “:bar” from the included “foo” project.

However, I would like to do the inverse, i.e. replace dependencies in the included project with projects from the composite project. In the above case, “” would be used in the included “foo” project and should be replaced by the project “:bar” from the composite project.

This does not work for me. Is that possible to achieve this?

Hey Ingo,

Substitution works in any direction. Currently there is no way to define the provided substitutions of the main build. But maybe you don’t need to in your case. If and match groupId:artifactId, then substitutions works out of the box.

Otherwise you can create a composite that includes both your builds and then define manual substitutions there.