Skip to content

[MNG-7471] 3.9.x Make Resolver util and connector-basic provided#732

Closed
cstamas wants to merge 2 commits intomaven-3.9.xfrom
mng-7471-make-resolver-provided
Closed

[MNG-7471] 3.9.x Make Resolver util and connector-basic provided#732
cstamas wants to merge 2 commits intomaven-3.9.xfrom
mng-7471-make-resolver-provided

Conversation

@cstamas
Copy link
Copy Markdown
Member

@cstamas cstamas commented May 4, 2022

Problem: resolver spi, impl and connector-basic has changes in 1.8.0 (SPI interface RepositoryLayout got new method, that is implemented in connector-basic, and code from impl is using it). But, Maven core exports only resolver api, spi and impl packages, while the rest is at mercy of a plugin. This means ,that these artifacts (api, spi and impl) will always come from Maven core, whatever version plugin declares, while the "rest" (connector-basic and util) will be of version that plugin declares. The current state hence prevented ANY KIND of changes on SPI interfaces that would be implemented in connector-basic (which is the case in Resolver 1.8.0).

Solution: make all these resolver artifacts "provided" (to behave like maven-core or maven-plugin-api is behaving): simply put, whatever resolver artifact plugin depends on, it should NOT use it's own version, but the version from Maven. This ensures that api-spi-impl-connector-basic as "aligned" and are same version.

Details:

The change is to make util is exportedArtifact AND exportedPackage, while connector-basic is only exportedArtifact.

Reasoning:

  • exportedArtifact -- prevents "own" artifact to be added to realm
  • exportedPackage -- makes it "visible" in realm

So, this basically prevents bad versions of util and connector-basic
enter the plugin realm (as they will be not added to it), while
util remains "visible" to plugins, as the intent was, most
common due GenericVersions etc.

This change also results in simpler expectations to plugin developers:
resolver libraries should really behave like maven-core or maven-compat:
when plugin declares dependency on these (w/ scope provided as best
practice), they really get version of these that are of version that
maven runs in, not version they declare. So same thing happens now with
resolver: you will get same version of resolver that maven uses your plugin
runs in.

Before this change, it was a mixed bag: api, spi and impl was from maven,
while util and connector-basic was version you pulled in as dep.


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

The util is exportedArtifact AND exportedPackage
The connector-basic is only exportedArtifact.

Reasoning:
* exportedArtifact -- prevents "own" artifact to be added to realm
* exportedPackage -- makes it "visible" in realm

So, this basically prevents bad versions of util and connector-basic
enter the plugin realm (as they will be not added to it), while
util remains "visible" to plugins, as the intent was, most
common due GenericVersions etc.
@cstamas cstamas self-assigned this May 4, 2022
@cstamas cstamas changed the title [MNG-7471] Make Resolver util and connector-basic provided [MNG-7471] 3.9.x Make Resolver util and connector-basic provided May 4, 2022
@cstamas cstamas requested review from gnodet and michael-o May 4, 2022 13:29
@michael-o
Copy link
Copy Markdown
Member

What does this logically change and the reasoning?

@cstamas
Copy link
Copy Markdown
Member Author

cstamas commented May 6, 2022

What does this logically change and the reasoning?

Did you read PR description fully? 😄

@michael-o
Copy link
Copy Markdown
Member

Now I did. Honestly, I have no clue here. I totally trust your judgement.

@cstamas cstamas marked this pull request as ready for review May 11, 2022 10:07
@michael-o
Copy link
Copy Markdown
Member

Stupid question: Do we need an IT which proves that these changes are required?

@cstamas
Copy link
Copy Markdown
Member Author

cstamas commented May 11, 2022

Stupid question: Do we need an IT which proves that these changes are required?

apache/maven-integration-testing#158

@cstamas
Copy link
Copy Markdown
Member Author

cstamas commented May 11, 2022

The CI failed on macOS as for some reason Bootstrap failed, and hence, many unrelated ITs failed as well (as things were not present in local repo)

@slawekjaranowski
Copy link
Copy Markdown
Member

The CI failed on macOS as for some reason Bootstrap failed, and hence, many unrelated ITs failed as well (as things were not present in local repo)

reason:

transfer failed for https://repo1.maven.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom: Operation timed out (Read failed)

try re-run filed build

@cstamas
Copy link
Copy Markdown
Member Author

cstamas commented May 11, 2022

reason:...

Whatever the reason is, it is unrelated to change in this PR, that was my point. Probably some networking issue on GH side...

@slawekjaranowski
Copy link
Copy Markdown
Member

Whatever the reason is, it is unrelated to change in this PR, that was my point. Probably some networking issue on GH side...

exactly GH issue ...

@michael-o
Copy link
Copy Markdown
Member

Testing again...

cstamas added a commit that referenced this pull request May 11, 2022
Problem: resolver spi, impl and connector-basic has changes in 1.8.0 (SPI interface RepositoryLayout got new method, that is implemented in connector-basic, and code from impl is using it). But, Maven core exports only resolver api, spi and impl packages, while the rest is at mercy of a plugin. This means ,that these artifacts (api, spi and impl) will always come from Maven core, whatever version plugin declares, while the "rest" (connector-basic and util) will be of version that plugin declares. The current state hence prevented ANY KIND of changes on SPI interfaces that would be implemented in connector-basic (which is the case in Resolver 1.8.0).

Solution: make all these resolver artifacts "provided" (to behave like maven-core or maven-plugin-api is behaving): simply put, whatever resolver artifact plugin depends on, it should NOT use it's own version, but the version from Maven. This ensures that api-spi-impl-connector-basic as "aligned" and are same version.

Details:

The change is to make util is exportedArtifact AND exportedPackage, while connector-basic is only exportedArtifact.

Reasoning:
* exportedArtifact -- prevents "own" artifact to be added to realm
* exportedPackage -- makes it "visible" in realm

So, this basically prevents bad versions of util and connector-basic
enter the plugin realm (as they will be not added to it), while
util remains "visible" to plugins, as the intent was, most
common due GenericVersions etc.

This change also results in simpler expectations to plugin developers:
resolver libraries should really behave like maven-core or maven-compat:
when plugin declares dependency on these (w/ scope provided as best
practice), they really get version of these that are of version that
maven runs in, not version they declare. So same thing happens now with
resolver: you will get same version of resolver that maven uses your plugin
runs in.

Before this change, it was a mixed bag: api, spi and impl was from maven,
while util and connector-basic was version you pulled in as dep.
cstamas added a commit that referenced this pull request May 11, 2022
Problem: resolver spi, impl and connector-basic has changes in 1.8.0 (SPI interface RepositoryLayout got new method, that is implemented in connector-basic, and code from impl is using it). But, Maven core exports only resolver api, spi and impl packages, while the rest is at mercy of a plugin. This means ,that these artifacts (api, spi and impl) will always come from Maven core, whatever version plugin declares, while the "rest" (connector-basic and util) will be of version that plugin declares. The current state hence prevented ANY KIND of changes on SPI interfaces that would be implemented in connector-basic (which is the case in Resolver 1.8.0).

Solution: make all these resolver artifacts "provided" (to behave like maven-core or maven-plugin-api is behaving): simply put, whatever resolver artifact plugin depends on, it should NOT use it's own version, but the version from Maven. This ensures that api-spi-impl-connector-basic as "aligned" and are same version.

Details:

The change is to make util is exportedArtifact AND exportedPackage, while connector-basic is only exportedArtifact.

Reasoning:
* exportedArtifact -- prevents "own" artifact to be added to realm
* exportedPackage -- makes it "visible" in realm

So, this basically prevents bad versions of util and connector-basic
enter the plugin realm (as they will be not added to it), while
util remains "visible" to plugins, as the intent was, most
common due GenericVersions etc.

This change also results in simpler expectations to plugin developers:
resolver libraries should really behave like maven-core or maven-compat:
when plugin declares dependency on these (w/ scope provided as best
practice), they really get version of these that are of version that
maven runs in, not version they declare. So same thing happens now with
resolver: you will get same version of resolver that maven uses your plugin
runs in.

Before this change, it was a mixed bag: api, spi and impl was from maven,
while util and connector-basic was version you pulled in as dep.
@cstamas
Copy link
Copy Markdown
Member Author

cstamas commented May 11, 2022

Merged manually:
maven-3.9.x 4de3947
master a83ed86

@cstamas cstamas closed this May 11, 2022
@cstamas cstamas deleted the mng-7471-make-resolver-provided branch May 11, 2022 14:10
cstamas added a commit to apache/maven-integration-testing that referenced this pull request May 11, 2022
…#158)

An IT for Maven 3.9+ that "exercise" both resolver transport: wagon and native (so we have 2 tests both forcing transport with `-Dmaven.resolver.transport` one wagon (which is default, but setting is there to be explicit) and once native.

It builds a project that needs a plugin (to pull it will use set transport), and that plugin will use resolver as well to resolve set artifact. If any of these fails, maven project fails.

Related fix: apache/maven#732 (jn maven-3.9.x and master)
@gnodet gnodet mentioned this pull request May 24, 2023
@rbourbonnavarro
Copy link
Copy Markdown

Hi @cstamas, why was the package of maven-resolver-connector-basic not exported as the one of maven-resolver-util was? I have a use case where I'm setting up the RepositorySystem with the DefaultServiceLocator and I can't add the BasicRepositoryConnectorFactory as the implementation for RepositoryConnectorFactory because I don't have access to it.
How is the right way to achieve this in Maven 3.9?

@cstamas
Copy link
Copy Markdown
Member Author

cstamas commented Jun 9, 2023

Service locator is deprecated, will be removed, so stay away from it. See instead this https://github.com/maveniverse/mima

gnodet pushed a commit to gnodet/maven that referenced this pull request Nov 20, 2024
…apache#158)

An IT for Maven 3.9+ that "exercise" both resolver transport: wagon and native (so we have 2 tests both forcing transport with `-Dmaven.resolver.transport` one wagon (which is default, but setting is there to be explicit) and once native.

It builds a project that needs a plugin (to pull it will use set transport), and that plugin will use resolver as well to resolve set artifact. If any of these fails, maven project fails.

Related fix: apache#732 (jn maven-3.9.x and master)
@jira-importer
Copy link
Copy Markdown

Resolve #9282

@olamy olamy mentioned this pull request Apr 2, 2026
8 tasks
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.

6 participants