Multi-Project w/ Multi-Repo


(Jonathan Herriott) #1

Hi, I’m in a situation right now where multiple teams commit to multiple different projects all on independent repos where some depend on other projects (and so pull them in via maven). They push their own artifacts up to maven for other teams to consume. Seems normal enough. The issue is, all these libraries have to be pulled down and built into a single artifact, so all versions must match across the board. The room for error here is pretty big when you consider transitive dependencies and a build system not set up to recompile libraries that depend on a changed library. Part of the issue is we tend to use SNAPSHOTS, which I will probably associated with the fact that people constantly need to change/add things in libraries and transitive libraries. It’s not unusual for a feature set to include multiple PR in multiple libraries where they all have to be committed as a set or the build will break.

I’ve had the luck of dealing with android’s repo tool in the past and would like to try and introduce this to my teams. Ideally, I’d like to do pull all the projects in like so:

final-artifact/
    teamA/                 # Assume teamA library depends on teamB's library
        lib/                    # I Actually only want to pull this in and nothing else
        build.gradle
        settings.gradle
    teamB/
        lib/                   # Same here
        build.gradle
        settings.gradle
    build.gradle
    settings.gradle

so in my root settings.gradle, I’m defining the following:
include ‘:teamA-lib’, ‘:teamB-lib’
project(’:teamA-lib’).projectDir=newFile(’${rootDir}/teamA/lib’)
project(’:teamB-lib’).projectDir=newFile(’${rootDir}/teamB/lib’)

Then in teamA/lib/build.gradle I am trying to set the dependency like so:
compile project(’:teamB-lib’)
however, this doesn’t appear to work if teamA/settings.gradle exists

Any help would be appreciated on how I can do this without removing each project’s settings.gradle.


(Jonathan Herriott) #2

I read up on composite builds, so I will attempt that, however, I don’t know how it deals with replacing transitive dependencies and replacing them as well. I guess I’ll find out shortly.