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

[MNG-8141] Model Builder report issues during build #1569

Merged
merged 5 commits into from
Jun 10, 2024

Conversation

cstamas
Copy link
Member

@cstamas cstamas commented Jun 8, 2024

And ArtifactDescriptorReader should not "toss away" but report WARNings (as in case of ERROR or FATAL MB throws).

Part 1: port ArtifactDescriptorReader to not lose WARNs
Part 2: make model builder report Profile ID duplications as model WARNs


https://issues.apache.org/jira/browse/MNG-8141

And ArtifactDescriptorReader should not "toss away" but
report WARNings (as in case of ERROR or FATAL MB throws).

Part 1: port ArtifactDescriptorReader to not loose WARNs

---

https://issues.apache.org/jira/browse/MNG-8141
@cstamas cstamas self-assigned this Jun 8, 2024
@michael-o
Copy link
Member

lose, not loose

@cstamas
Copy link
Member Author

cstamas commented Jun 8, 2024

@gnodet pls take a peek:

  • 1st commit: "clean" port of 3.9.x change
  • 2nd commit: could not find any better place for this check, if you have better ideas, I am all ears

@cstamas
Copy link
Member Author

cstamas commented Jun 8, 2024

@gnodet also, re caching, I think you are wrong (so resolver does builds same model for same GAV asked for different GACEVs), I mean it DOES cache raw models, but lineage, normalization, profile evaluation etc... all that is repeated (basically only XML parsing from file is spared).
But am really unsure "who's fault" is this: resolver or ArtifactDescriptorReader?

EDIT: Am pretty much sure ArtifactDescriptorReader is it. Resolver itself is "agnostic" (no idea about Maven universe), and even have no (and should not have) logic that tells "POM of a Maven GACEV artifact is on coordinates GApomV". Moreover, this indirection is done in ArtifactDescritptorReader as that is Maven specific implementation of ArtifactDescriptorReader resolver component.

Copy link
Contributor

@gnodet gnodet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this will need to be ported to maven-api-impl

@gnodet
Copy link
Contributor

gnodet commented Jun 10, 2024

@gnodet also, re caching, I think you are wrong (so resolver does builds same model for same GAV asked for different GACEVs), I mean it DOES cache raw models, but lineage, normalization, profile evaluation etc... all that is repeated (basically only XML parsing from file is spared). But am really unsure "who's fault" is this: resolver or ArtifactDescriptorReader?

EDIT: Am pretty much sure ArtifactDescriptorReader is it. Resolver itself is "agnostic" (no idea about Maven universe), and even have no (and should not have) logic that tells "POM of a Maven GACEV artifact is on coordinates GApomV". Moreover, this indirection is done in ArtifactDescritptorReader as that is Maven specific implementation of ArtifactDescriptorReader resolver component.

Right, only file and raw models are cached, but even if the effective model is computed twice, no resolver request / disk access should be performed, as it should start from the already loaded raw model.

@@ -816,6 +817,15 @@ private Model readEffectiveModel(
// profile activation
profileActivationContext.setProjectProperties(modelv4.getProperties());

// profile check
HashSet<String> profileIds = new HashSet<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this be done in the ModelValidator ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should a validateProfiles method be added to the ModelValidator ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validator does validate profiles. But for these "far" POMs we use consequently "min" level, that does NOT.
In Mvn3 the idea was to detect this duplication while processing (as profiles do affect build a lot, can add extra properties, dependencies, and failure to properly evaluate them can lead to mysterious failures).
We can move ID validation to Min level, yes, as it currently validate very few things.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like these changes (having validation in validator), so am tempted to introduce this change in 3.9 line as well...

Apply changes to related api impl classes as well.
@michael-o michael-o removed their request for review June 10, 2024 08:13
@cstamas
Copy link
Member Author

cstamas commented Jun 10, 2024

Reproducer looks like this:
https://gist.github.com/cstamas/14db1a530cb5c2d705ee95554b882c97

In DEBUG messages are:
https://gist.github.com/cstamas/e2d32d1ca9702d49785e2e36c34556b3

(which surprised me, as they exactly pinpoint the problems at file line level, unlike 3.9.x)

@cstamas cstamas marked this pull request as ready for review June 10, 2024 10:06
cstamas added a commit that referenced this pull request Jun 10, 2024
No (logic) change, merely moved the new code to proper place (validation) to not piggy back onto processing: this is much cleaner.

---

https://issues.apache.org/jira/browse/MNG-8141

Inspired by suggestions in master PR #1569
@cstamas cstamas merged commit bea3e72 into apache:master Jun 10, 2024
13 checks passed
@cstamas cstamas deleted the MNG-8141 branch June 10, 2024 11:04
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants