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-8615] [MNG-8616] Maven core extensions handling improvements #2147

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

cstamas
Copy link
Member

@cstamas cstamas commented Mar 5, 2025

It all started with MNG-8615 to not swallow DI problems while loading core extensions. Then tried to add origin as well, but it turns out there is lack of context. Then turned out models are not location tracking. Then came MNG-8616 as Maven was too rigid and did not apply precedence for extensions making project hopping problematic, if not impossible...

Changes:

  • do not swallow DI issues happened during core extension loading; belly up instead.
  • report which extension caused DI issue
  • make core extension models and IO location tracking
  • alter CLI api to carry all extensions "by origin" (project, user, installation)
  • parser should be plain dumb, all it does is load extensions in precedence order and validates them (validity: they must be GA unique)
  • DI capsule performs now "selection" of extensions (based on precedence) and loads them as before
  • finally: we have now DEBUG logs which all extensions were considered and which were effectively loaded, something I missed a lot
  • new UTs revealed MavenInvokerUT problem: ClassWorlds were not cleaned up properly

Behavioural change since 4.0.0-rc-3:

  • conflict within same source (same file) makes Maven fail - as before
  • conflict spanning across sources is warning only; precedence is applied to select extension to be loaded

https://issues.apache.org/jira/browse/MNG-8615
https://issues.apache.org/jira/browse/MNG-8616

@cstamas cstamas requested review from gnodet and kwin March 5, 2025 18:51
@cstamas cstamas self-assigned this Mar 5, 2025
cstamas and others added 2 commits March 5, 2025 22:10
…exusContainerCapsuleFactory.java

Co-authored-by: Konrad Windszus <[email protected]>
Copy link
Member

@michael-o michael-o left a comment

Choose a reason for hiding this comment

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

@cstamas cstamas changed the title [MNG-8615] Maven should fail on DI failure [MNG-8615] [MNG-8616] Maven core extensions handling improvements Mar 6, 2025
@cstamas cstamas requested review from michael-o and kwin March 6, 2025 12:42
@cstamas
Copy link
Member Author

cstamas commented Mar 6, 2025

Example of conflict and DEBUG output:

[DEBUG] Configured core extensions:
[DEBUG] * USER:
[DEBUG]   - eu.maveniverse.maven.mimir:extension:0.4.0 -> /home/cstamas/.m2/extensions.xml:3
[DEBUG] * PROJECT:
[DEBUG]   - eu.maveniverse.maven.mimir:extension:0.4.0 -> /home/cstamas/Worx/apache-maven/maven/.mvn/extensions.xml:3
[WARNING] Found 1 extension conflict(s):
[WARNING] * Conflicting extension eu.maveniverse.maven.mimir:extension: /home/cstamas/Worx/apache-maven/maven/.mvn/extensions.xml:3 vs /home/cstamas/.m2/extensions.xml:3
[WARNING] 
[WARNING] Order of core extensions precedence is project > user > installation. Selected extensions are:
[WARNING] * eu.maveniverse.maven.mimir:extension:0.4.0 configured in /home/cstamas/Worx/apache-maven/maven/.mvn/extensions.xml:3
[DEBUG] Selected core extensions:
[DEBUG] * eu.maveniverse.maven.mimir:extension:0.4.0: /home/cstamas/Worx/apache-maven/maven/.mvn/extensions.xml:3

cstamas added 2 commits March 6, 2025 14:31
As mimir had a bug that prevented it from starting :)
ClassRealm was not closed, but left to GC. This was not a problem before
but with extensions is, as JUnit would delete directories but
is prevented doing so on Windoze.
@cstamas cstamas marked this pull request as ready for review March 6, 2025 14:43
@gnodet
Copy link
Contributor

gnodet commented Mar 6, 2025

Example of conflict and DEBUG output:

[DEBUG] Configured core extensions:
[DEBUG] * USER:
[DEBUG]   - eu.maveniverse.maven.mimir:extension:0.4.0 -> /home/cstamas/.m2/extensions.xml:3
[DEBUG] * PROJECT:
[DEBUG]   - eu.maveniverse.maven.mimir:extension:0.4.0 -> /home/cstamas/Worx/apache-maven/maven/.mvn/extensions.xml:3
[WARNING] Found 1 extension conflict(s):
[WARNING] * Conflicting extension eu.maveniverse.maven.mimir:extension: /home/cstamas/Worx/apache-maven/maven/.mvn/extensions.xml:3 vs /home/cstamas/.m2/extensions.xml:3
[WARNING] 
[WARNING] Order of core extensions precedence is project > user > installation. Selected extensions are:
[WARNING] * eu.maveniverse.maven.mimir:extension:0.4.0 configured in /home/cstamas/Worx/apache-maven/maven/.mvn/extensions.xml:3
[DEBUG] Selected core extensions:
[DEBUG] * eu.maveniverse.maven.mimir:extension:0.4.0: /home/cstamas/Worx/apache-maven/maven/.mvn/extensions.xml:3

Why do we consider a conflict if the extension is the same (same GAV + same config) ?
That's not really a conflict. A conflict would be a different version or different config imho.

@cstamas
Copy link
Member Author

cstamas commented Mar 6, 2025

Why do we consider a conflict if the extension is the same (same GAV + same config) ? That's not really a conflict. A conflict would be a different version or different config imho.

We consider it as "conflict" for simplicity sake: I'd not go down the route to have "model builder" for extensions, and "build" the model out of 3 sources. Even if same GAV of extension, project one may have different config due some requirement while user wide another config, etc.

I'd keep handling them dead simple: they are considered as "blob" (atom?) keyed by GA and no merging or building or whatsoever magic happens, basically rules are simple:

  • one XML file must be GA unique (having two different entries Vs for same GA is most probably error; nor Maven can handle that)
  • across 3 possible sources precedence wins

@gnodet
Copy link
Contributor

gnodet commented Mar 6, 2025

Why do we consider a conflict if the extension is the same (same GAV + same config) ? That's not really a conflict. A conflict would be a different version or different config imho.

We consider it as "conflict" for simplicity sake: I'd not go down the route to have "model builder" for extensions, and "build" the model out of 3 sources. Even if same GAV of extension, project one may have different config due some requirement while user wide another config, etc.

I'd keep handling them dead simple: they are considered as "blob" (atom?) keyed by GA and no merging or building or whatsoever magic happens, basically rules are simple:

  • one XML file must be GA unique (having two different entries Vs for same GA is most probably error; nor Maven can handle that)
  • across 3 possible sources precedence wins

Yeah, I fully agree we don't need merging or whatever. I was simply thinking about a slightly less dead simple approach: for a given GA, either there's a single entry or V + config is the same.

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.

4 participants