I got a maven project with a main module and multiple submodule. I would like to know if there is a simple way to retrieve all the modules changed between two commits.
Asked
Active
Viewed 1,484 times
2 Answers
2
For what it worth, almost 3 years after the question:
I designed on a heuristic based on git diff, based on the fact that maven artifacts are ruled by convention.
- Extract all files changes with
git diff --name-status <commit1> <commit2>
- Sort out, added files, updated files and deleted files
- From these info, if the file looks like a/b/src/main/... or c/src/test, by maven convention, impacted modules are a/b and c. If the file looks like d/e/pom.xml, easy! the module is d/e.
Of course, this cannot handle changes such as a/b/c/README.md. Is it in a, a/b or a/b/c ?
I use this heuristic to list all modules to recompile for CI builds. If one of the files could not be classified by the above algorithm, I just rebuild the whole project.
Cheers

Kineolyan
- 723
- 8
- 24
0
git diff <commit1> <commit2> -- **/pom.xml *.pom.xml
will give you the changes that affected the main module pom file and submodules.

Mykola Gurov
- 8,517
- 4
- 29
- 27
-
Thanks, but if some files of the module are modified, but not the pom, the module will not be in the resulted list I think. – Teocali Jan 23 '15 at 08:23
-
so you want a tool that would map changes in the sources to the structure of the maven submodules? Doesn't your IDE show you changes in the filesystem this way? – Mykola Gurov Jan 23 '15 at 11:29