Only injects properties into every reactor project once by jeantil · Pull Request #700 · git-commit-id/git-commit-id-maven-plugin

Context

Enabling injectAllReactorProjects in large and old reactor projects allows to avoid repeatedly parsing the git history to retrieve the information.

In the apache/james-project enabling this property allowed to lower the time spent in git-commit-id from 39s[1] to 2s[2].

However, looking at the verbose logs one can see that the plugin keeps injecting the properties into every reactor project for every project where the plugin runs.

This commit aims to avoid reinjecting keys which have already been set in the context.

[1] https://ge.apache.org/s/xumcl7ztpkmhw/timeline?collapse-all&outcome=success,failed&view=by-type
[2] https://ge.apache.org/s/gpnevfknmdv5a/timeline?collapse-all&hide-timeline&outcome=success,failed&view=by-type

Contributor Checklist

  • Added relevant integration or unit tests to verify the changes
  • Update the Readme or any other documentation (including relevant Javadoc)
  • Ensured that tests pass locally: mvn clean package
  • Ensured that the code meets the current checkstyle coding style definition: mvn clean verify -Pcheckstyle -Dmaven.test.skip=true -B

I'm not saying the fix is perfect, but hopefully it illustrates the issue. If you want a sample project to reproduce you can look at https://github.com/apache/james-project/ enabling verbose output on git-commit-id you will be able to see that for every single project the plugin reinjects all the properties in the 273 projects of the reactor ... effectively setting the properties 273*273 =74529 times.
The performance impact is not huge since its all in memory accesses but it still feels quite wasteful