Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultProjectBuilder enhancements #402

Closed
wants to merge 18 commits into from
Closed

DefaultProjectBuilder enhancements #402

wants to merge 18 commits into from

Conversation

gnodet
Copy link
Contributor

@gnodet gnodet commented Nov 27, 2020

While initially working on MNG-7027, I came across several issues, so I'm raising this PR in order to gather feedback.
I've split the changes in small commits in order to make reviewing them easier.
There are 2 big important (and non trivial) commits though: 331e402 and aa285f2. Those have comments in the commit, but I can explain more if needed.

This PR is layered on top of #399 and #391 to avoid conflicts.

@gnodet
Copy link
Contributor Author

gnodet commented Nov 28, 2020

On top of that, I'm going to check if caching of effective models can be done. This requires tracking which properties / profiles are used, but it looks doable. It may not be very interesting for stock maven, but it would certainly be for mvnd.

@gnodet
Copy link
Contributor Author

gnodet commented Jan 7, 2021

@rfscholte could you have a quick look and see if that's something that could be merged at some point ? I don't want to waste time if there's no interest at all.
The 2 big and non trivial commits are 331e402 and aa285f2.
I'm willing to rebase if there's a chance it could be included.

@gnodet
Copy link
Contributor Author

gnodet commented Jan 8, 2021

@rfscholte the commit I pointed you at and on which you commented aa285f2#r45727670 yesterday was outdated. I've rebased on top of the recent changes in master. The related commit is now 22582b6. The answer to the question should be in the commit comment:

The checks were previously done after the cache hit, but they are now a duplication of the checks performed in readParentLocally.
Doing caching is useless as the first time, the version range will be resolved and stored in the Parent and caching happens during the call to readRawModel anyway.

@gnodet
Copy link
Contributor Author

gnodet commented Jan 8, 2021

I'll investigate the integration test failures asap.

@rfscholte
Copy link
Contributor

Probably related is MNG-7063: if trying to read the same file multiple times (in this case {{dependency-reduced-pom.xml}}, it'll be picked up from cache. In this case the model shouldn't have been cached.
Would that be solved with these changes?

@rfscholte
Copy link
Contributor

I've written a unittest for MNG-7063. With this PR it succeeds again. This looks very promising.

@gnodet
Copy link
Contributor Author

gnodet commented Jan 15, 2021

I'll get back on this PR next week.

@gnodet
Copy link
Contributor Author

gnodet commented Jan 19, 2021

@rfscholte I've rebased and fix the integration tests.

@rfscholte
Copy link
Contributor

I just had another look at this. It looks to me that this commit has become too big. We should split it into 2 pieces:

  • rewriting JUnit tests using maven-test-support.
  • Remove double cache, which would fix MNG-7063.

# Conflicts:
#	maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
# Conflicts:
#	maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
The root of the problem is MNG-5312 which is a performance issue because a ModelCache was not always involved during a model build.  This lead to MNG-6030 (memory consumption issue because of the usage of multiple caches). The fix for MNG-6030 lead to MNG-6311 (problem with changes not being picked up in M2E).
The root problem is that the fix for MNG-5312 was wrong.  The caches and its data should be managed at the RepositorySystemSession level, especially as the data is related to a given session parameters (maven global settings).
This commit brings back the cache at the session level, and a default cache is now set on the session by the MavenCli.  The cache is used later by DefaultArtifactDescriptorReader and DefaultProjectBuilder to build a DefaultModelCache.

* use the cache on the MavenExecutionRequest
* get rid of the hack for  MNG-6530.
* MavenCli configures a cache for the whole execution request
* merge ReactorModelCache into DefaultModelCache

# Conflicts:
#	maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
#	maven-core/src/main/java/org/apache/maven/project/ReactorModelCache.java
# Conflicts:
#	maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
# Conflicts:
#	maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
# Conflicts:
#	maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
# Conflicts:
#	maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
The checks were previously done after the cache hit, but they are now a duplication of the checks performed in readParentLocally.
Doing caching is useless as the first time, the version range will be resolved and stored in the Parent and caching happens during the call to readRawModel anyway.

# Conflicts:
#	maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
# Conflicts:
#	maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
@gnodet
Copy link
Contributor Author

gnodet commented Feb 12, 2021

I just had another look at this. It looks to me that this commit has become too big. We should split it into 2 pieces:

  • rewriting JUnit tests using maven-test-support.
  • Remove double cache, which would fix MNG-7063.

Done.
Fwiw, #432 is about the junit 5.

@rfscholte
Copy link
Contributor

ok, let me check that one first

@rfscholte
Copy link
Contributor

Merged with 619973b which fixes MNG-7063. Thanks for this PR!

@rfscholte rfscholte closed this Feb 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants