Composite builds with inverse dependency substitution


(Ingo Kegel) #1

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('com.foo:bar') with project(':bar')
    }
}

to settings.gradle, any usages of module “com.foo:bar” 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, “com.foo:bar” 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?


(Stefan Oehme) #2

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 project.group and project.name 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.

Cheers,
Stefan