Gradle - multiple project and git repositories

Viewed 5323

We have 3 projects and a 4th one that is shared among them.

A multiple project in gradle requires one to create a wrapper project and include all the sub projects in it.

Each of our sub projects are being worked on by different team members and we use git as an svn.

Our concern before going into gradle is the fact that we will only have 1 git repository that consists of the wrapper project with all sub projects instead of 4 different repos, each for each sub project.

1) Are we missing something?

2) Is it possible to create 4 repos on a multi project?

3) One of our requirements is to deploy a single war (for example only webapp #1 out of the 4)--does using the multi project template make it possible?

2 Answers

I stumbled across this question on the same quest, and only later somebody pointed out another option to me (it's really a variant of the third choice listed under ad 1 in https://stackoverflow.com/a/20678444/1016514), which seems like an elegant hack:

You keep the subprojects in separate Git repos, and from within your root project point to them by setting the respective rootDir properties. This requires a fixed checkout layout, obviously, but that would usually be the case anyway.

The approach is described here: https://medium.com/codequest/gradle-multi-project-build-substituting-jar-dependencies-with-local-projects-4a5323f8680b

Update with Gradle 7.3+: this will now yield a warning, and likely not work after some point in the future:

Subproject ':xyz' has location '...\xyz' which is outside of the project root.
This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0.
Consult the upgrading guide for further information: 
https://docs.gradle.org/7.3.1/userguide/upgrading_version_7.html#deprecated_flat_project_structure
Related