Including a standalone multi-project inside another multi-project

(Shawn Bryan) #1

I’ve been bashing my head against this problem and have not found a solution here nor on SO. My situations is relatively straight forward. I have an existing multi-project build, lets call it ‘legacy’, that for various reasons cannot be modified*. I also have a new multi-project build, lets call it ‘root’, that I would like to include legacy in as a sub-project. The directory structure looks like this:

  • root
    | - build.grade
    | - settings.gradle
    • A
      | - build.gradle
    • B
      | - build.gradle
      • legacy
        | -build.gradle
        | settings.gradle
        • C
          | - build.gradle
        • D
          | - build.gradle

Important file contents:

  • C/build.gradle = …compile project(':D')
  • legacy/settings.gradle = include 'C' include 'D'

No matter what I configure for root/settings.gradle I either get
Project with path ':D' could not be found in project ':B:legacy:C'
or the whole legacy tree is ignored

Is there any way to make the legacy branch and root play nicely?

* Legacy cannot be drastically changed, but if there is a simple solution that would allow legacy to continue operating as a standalone project (it is currently a git submodule of root) then that could be entertained

Thank you,

(Sterling Greene) #2

What you’re describing could be accomplished with a composite build.

This is the only way if you want the legacy build to remain completely untouched and standalone. You can reference dependencies from the legacy build in the root build by using external dependencies that are automatically substituted for project dependencies.

(Shawn Bryan) #3

Wow I was barking up the wrong tree with the multi-project approach. The composite build worked perfectly. Thank you!