I am trying to set up a multi-project build, and I was hoping to set it up with maven-like build isolation, where each subproject (artifact builder) can be built without requiring any of its dependent code. Basically, I want to swap between using the jar/artifact dependency to using project dependencies when the user requests it.
I am starting to feel like I’m swimming upstream, so I figured it would be a good time to stop and ask.
The goal is, if you have the following file layout
parentDir\
ProjA\
build.gradle
src\
ProjB
build.gradle
src\
ProjC\
build.gradle
src\
settings.gradle
build.gradle
With a simple dependency graph of ProjC depending on ProjB depending on ProjA (And all three would depend on parent). It would be preferred when you build ProjC, it uses artifact (downloaded jar) versions of ProjB/A, unless the user indicates they would prefer upstream projects be built.
The reason for this is both convenience and build isolation: A developer working on ProjC shouldn’t necessary have to check out the whole code tree and build if they only care about their downstream projects. There may also be build setup (such as installing compilers/programs onto the build machine) which may be unnecessary for the downstream projects. No need to cause a downstream java developer to download a C++ compiler if they are only touching the java code.
As far as I can tell, there are two possible approaches
- Use the maven plugin and terminology, Each build would be independent (no cross-subproject dependencies). In order to build multiple projects, user would have to visit the upstream project, build/install it, and then visit the downstream project. To return to using the server, the user would have to clean her mvn cache.
1a) Do the same thing, but without using the maven plugin. Have the gradle builds be independent and publish to some sort of local cache. 2) Have the build only include the current project in the multi-project build by default, give the user the ability to pass in a property with the names of additional projects to compile, do some magic in the settings.gradle file to read that property and include the projects. Have a check at the artifact dependency section that only adds the dependencies if they were not passed in as compile-time projects by the user.
Since both of those feel a bit like hacking the build system to do something it doesn’t want to do, I was wondering if there is a more conventional way to achieve the effect?
I actually don’t require each of my projects to be completely independent, as it is in the maven-esque model, but there are certain logically components that really should be parts of separate builds. However, there will be some devs working cross-project who will want to build the entire codebase, and I also need to ensure their experience is not confusing or overly verbose. There doesn’t seem to be an easy way to invoke sequential separate gradle builds…