Skip to content

Conversation

cstamas
Copy link
Member

@cstamas cstamas commented Aug 29, 2025

And some other cleanup. Fixed highest strategy (introduced in 2.0.0). Added UT with some examples to compare differences of behaviour of two strategies (nearest vs highest). And finally, there is some minor cleanup in demo snippets, better naming local reposes.

This PR now makes Resolver able to:

  • dynamically choose conflict resolver based on session config (def is new "path")
  • dynamically choose version selection strategy for conflict resolution, based on session config (def is "nearest")
  • dynamically choose skipper type: versionless (default) or versioned (must be used with "highest")

Fixes #1562
Fixes #1566

@cstamas cstamas self-assigned this Aug 29, 2025
@cstamas
Copy link
Member Author

cstamas commented Aug 29, 2025

Example:

------------------------------------------------------------
GetDependencyHierarchyWithConflictsStrategies

org.eclipse.aether.util.graph.transformer.ConfigurableVersionSelector$**Nearest**@25f38edc

tree:
demo:demo:jar:1.0
\- com.squareup.okhttp3:okhttp:jar:4.12.0 [compile]
   +- com.squareup.okio:okio:jar:3.6.0 [compile]
   |  \- com.squareup.okio:okio-jvm:jar:3.6.0 [compile]
   |     +- org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.9.10 [compile] (conflicts with 1.8.21)
   |     \- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.9.10 [compile]
   \- org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.8.21 [compile]
      +- org.jetbrains.kotlin:kotlin-stdlib:jar:1.8.21 [compile]
      |  +- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.8.21 [compile] (conflicts with 1.9.10)
      |  \- org.jetbrains:annotations:jar:13.0 [compile]
      \- org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.8.21 [compile]
         \- org.jetbrains.kotlin:kotlin-stdlib:jar:1.8.21 [compile] (nearer exists)

cp:
demo:demo:jar:1.0
com.squareup.okhttp3:okhttp:jar:4.12.0 (compile)
com.squareup.okio:okio:jar:3.6.0 (compile)
com.squareup.okio:okio-jvm:jar:3.6.0 (compile)
org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.9.10 (compile)
org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.8.21 (compile)
org.jetbrains.kotlin:kotlin-stdlib:jar:1.8.21 (compile)
org.jetbrains:annotations:jar:13.0 (compile)
org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.8.21 (compile)

org.eclipse.aether.util.graph.transformer.ConfigurableVersionSelector$**Highest**@255b53dc

tree:
demo:demo:jar:1.0
\- com.squareup.okhttp3:okhttp:jar:4.12.0 [compile]
   +- com.squareup.okio:okio:jar:3.6.0 [compile]
   |  \- com.squareup.okio:okio-jvm:jar:3.6.0 [compile]
   |     +- org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.9.10 [compile]
   |     |  +- org.jetbrains.kotlin:kotlin-stdlib:jar:1.9.10 [compile]
   |     |  |  +- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.9.10 [compile] (nearer exists)
   |     |  |  \- org.jetbrains:annotations:jar:13.0 [compile]
   |     |  \- org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.9.10 [compile]
   |     |     \- org.jetbrains.kotlin:kotlin-stdlib:jar:1.9.10 [compile] (nearer exists)
   |     \- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.9.10 [compile]
   \- org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.8.21 [compile] (conflicts with 1.9.10)

cp:
demo:demo:jar:1.0
com.squareup.okhttp3:okhttp:jar:4.12.0 (compile)
com.squareup.okio:okio:jar:3.6.0 (compile)
com.squareup.okio:okio-jvm:jar:3.6.0 (compile)
org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.9.10 (compile)
org.jetbrains.kotlin:kotlin-stdlib:jar:1.9.10 (compile)
org.jetbrains:annotations:jar:13.0 (compile)
org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.9.10 (compile)
org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.9.10 (compile)

@cstamas cstamas added this to the 2.0.11 milestone Aug 29, 2025
@cstamas cstamas marked this pull request as ready for review September 1, 2025 15:51
@cstamas cstamas added the enhancement New feature or request label Sep 1, 2025
@cstamas cstamas linked an issue Sep 1, 2025 that may be closed by this pull request
@slawekjaranowski
Copy link
Member

We have introduce new definitions as GACE / GACEV - what does ments, how to extends such shortcuts?

@cstamas
Copy link
Member Author

cstamas commented Sep 1, 2025

Thr notion of "GAV" is well known, so is "GACEV" IMO. This basically parameterizes the new BF collector skipper, how to "key" artifacts (GACE - versionless, GACEV - versioned, full coordinates), as GACE (original code had that) is basically "premature optimization" assuming "nearest" version selection strategy is used (skipper will skip collecting artifact if same key match was already collected "higher" in graph -- hence presumption of nearest).

In other words, if nearest used; no change needed. If highest, one need to set skipper as well (either to GACEV or disable it fully), as in demo code:
https://github.com/apache/maven-resolver/pull/1565/files#diff-7e8980b475480d14c787e6eef289ae8781b0532b9eba101bd558ccd06f32a2e0R68-R71

@cstamas
Copy link
Member Author

cstamas commented Sep 1, 2025

So yes, configuration are "knobs" exposed to users, but users must know what is doing, which knob he wants to press and what are the consequences (or extra requirements) for that know. I do not want to make these configuration params inter-dependent, we can make it once in 2.1 or 3.0 (where feature would be interlocked with other feature and so on).

@cstamas
Copy link
Member Author

cstamas commented Sep 1, 2025

Renaming skipper options to: "versionless" (default), "versioned" and "false" (to keep skipper off if someone configured it earlier; unchanged).

…h/transformer/ConfigurableVersionSelector.java
@cstamas cstamas merged commit 45f3d8b into apache:master Sep 2, 2025
8 checks passed
@cstamas cstamas deleted the nearest-highest branch September 2, 2025 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New BF collector Skipper implementation prematurely optimizes Follow Up for ConflictResolver improvements
3 participants