Thomas Chan
02/07/2025, 8:18 AMA
with composite build child projects X
and Y
.
A
, X
and Y
are all version controlled with git and has their own git repositories.
X
and Y
are git submodules for A
.
This set up makes development very easy and the structure is quite clean.
Trouble is, now we have to add a shared library S
which both X
and Y
depends on.
Is there an elegant way to do this while still using git submodules and gradle composite builds?Thomas Chan
02/07/2025, 8:31 AMX
and Y
share the same copy of S
.
2. Use git worktree to achieve the same as (1).
3. Make S
a regular (non-composite) build, then X
and Y
simply includes its artifact.Thomas Chan
02/07/2025, 8:32 AMVampire
02/07/2025, 8:50 AMThomas Chan
02/07/2025, 9:00 AMThomas Chan
02/07/2025, 9:33 AMX
Y
S
, "publish" them to maven local repository.
Then temporarily set `A`'s dependency to maven local repository during development?Vampire
02/07/2025, 9:48 AM../the-submodule
then include that build, otherwise not", because the dependency declaration is the same either way, so when normally building the project you use published versions and for local development you could use composite build or something like that.Thomas Chan
02/07/2025, 10:13 AM...as you pin a submodule to a specific commit and if you pin it to one but then not push the submodule but the parent it is not found at other computers, or if you push the parent and then try to push the submodule but first have to rebase onto incoming changes the commit ID changes and thus the parent also again does not find the commit in the submodule at other computers and so on.This limitation is usually worked around by 1. always pushing the library project first before the parent project, and 2. push commits on the library project as frequently as possible. And yes it does have some issues if rebase is used, but in those cases we could amend the commit on the parent project, so that it points to the new rebased commit of the library project. The issue in this is that if many commits in the parent project have changed, it would be a pain to change all of them. 🤔
Thomas Chan
02/07/2025, 10:13 AMThomas Chan
02/07/2025, 10:46 AMincludegit
cannot solve the issue with duplicated copies of S
, for example when both X
and Y
use includegit
to checkout S
, where it would result in a copy of S
under X
and another copy under Y
. Which is reasonable because X
and Y
could point at different revisions of S
.
The use local copies method might solve this local.git.jdoctor
, but then we lose information on which version of S
is being used on X
and Y
Vampire
02/07/2025, 1:36 PM