The same parent pom.xml is read multiple times during single ProjectBuilder#build invocation. This is a performance regression introduced in 3.2.3-SNAPSHOT. I do not know how much this affects real-world build performance.
ProjectBuilder#build(File,ModelSource,...) first constructs project model then
initializes MavenProject instance.
When project model is constructed, all local and remote parent pom.xml files
are read and stored in model cache during ModelBuilder#readParent. The cache uses GAV keys. Only parent models are stored in the cache. The model of the project being being is not cached.
When MavenProject instance is initialized, ProjectBuilder#build is called recursively to create parent MavenProject instances.
There are appears to be two problems
- ModelCache used to create original project Model is not passed to the
recursive ProjectBuilder#build invocation.
- ProjectBuilder#build does not use ModelCache for the project being built.
During recursive invocation, this means the cache is never used to load
parent pom.xml models cached during outer ProjectBuilder#build invocation.
The solution is to introduce additional short-lived model cached keyed by
pom.xml file location (project GAV is not known when ProjectBuilder#build is
called). Alternatively, introduce ProjectBuilder#buildParent that will use
the model cache.