Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to retrieve the list of maven module changed between two commits in git

Tags:

git

maven

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.

like image 410
Teocali Avatar asked Nov 10 '22 20:11

Teocali


1 Answers

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.

  1. Extract all files changes with git diff --name-status <commit1> <commit2>
  2. Sort out, added files, updated files and deleted files
  3. 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

like image 141
Kineolyan Avatar answered Nov 15 '22 06:11

Kineolyan