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-7706] Deprecate 'localRepository' parameter expression #1009

Conversation

cstamas
Copy link
Member

@cstamas cstamas commented Feb 21, 2023

This PR deprecates the 'localRepository' mojo parameter expression, and Core will emit warning if used by any Mojo.


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

@cstamas
Copy link
Member Author

cstamas commented Feb 21, 2023

Ironically, ITs report this:

Error:  Failures: 
Warning: Tmng5576CdFriendlyVersions.testContinuousDeliveryFriendlyVersionsAreWarningFreeWithBuildConsumer:103->AbstractMavenIntegrationTestCase.assertFalse:703 [WARNING] Parameter 'localRepository' is deprecated core expression; Switch to '${repositorySystemSession}' and get LRM from there instead. ==> expected: <false> but was: <true>
Warning: Tmng5576CdFriendlyVersions.testContinuousDeliveryFriendlyVersionsAreWarningFreeWithoutBuildConsumer:71->AbstractMavenIntegrationTestCase.assertFalse:703 [WARNING] Parameter 'localRepository' is deprecated core expression; Switch to '${repositorySystemSession}' and get LRM from there instead. ==> expected: <false> but was: <true>
[INFO] 
Error:  Tests run: 890, Failures: 2, Errors: 0, Skipped: 84

@cstamas
Copy link
Member Author

cstamas commented Feb 22, 2023

Before this is merged, we need to do something with ITs:

  • either fix IT plugins, but am afraid that will start unrolling a snow ball of changes
  • fix the failing 2 IT to be more specific about warning it listens for...

@@ -40,7 +40,7 @@
* <tr><td><code>session</code></td> <td></td> <td>the actual {@link MavenSession}</td></tr>
* <tr><td><code>session.*</code></td> <td>(since Maven 3)</td><td></td></tr>
* <tr><td><code>localRepository</code></td> <td></td>
* <td>{@link MavenSession#getLocalRepository()}</td></tr>
* <td>{@link MavenSession#getLocalRepository()} DEPRECATED: Avoid use of {@link org.apache.maven.artifact.repository.ArtifactRepository} type. If you need access to local repository, switch to '${repositorySystemSession}' expression and get LRM from it instead.</td></tr>
Copy link

Choose a reason for hiding this comment

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

I think some Plugin deleopers might have no clue what LRM is, probabbly also give a link to the wiki/jira/... that explains some details.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated javadoc, added link to the issue. Issue updated with "how to fix" https://issues.apache.org/jira/browse/MNG-7706

cstamas added a commit to cstamas/maven-integration-testing that referenced this pull request Feb 23, 2023
The MNG-7706 deprecates ancient ArtifactRepository type use to
get access to local repository, and issues warning as for any
other deprecated Mojo parameters.

But alas, in ITs the MNG-5576 completely unrelated IT there is
an assertion to have WARNING-free log. This IT uses the
IT-plugins/IT-plugin-expression EvalMojo, that in turn
uses the deprecated `${localRepository}` parameter (but
does not use it). Result is, Maven 3.9.1 emits a WARNING
about use of deprecated parameter and the IT fails.

Further inspection shows, that while EvalMojo injects
ArtifactRepository for local repository, there is only
one IT that actually uses it, the MNG-4305, but even that
one is interested in basedir of the local repository only.
So to say, the use of deprecated ArtifactRepository is
not needed at all.

Fix:
* change EvalMojo to not expose in context the localRepository
  (w/ type ArtifactRepository), but a new expression `localRepositoryBasedir`
  only, that is injected in non-deprecated way.
* adjusted MNG-4305 to use new epxression instead to use object reflection in
  template to get basedir from ArtifactRepository
* This makes the originally failing MNG-5576 pass, as warning due EvalMojo
  is gone.

See
https://issues.apache.org/jira/browse/MNG-7706
apache/maven#1009
cstamas added a commit to apache/maven-integration-testing that referenced this pull request Feb 23, 2023
The MNG-7706 deprecates ancient ArtifactRepository type use to get access to local repository, and issues warning as for any other deprecated Mojo parameters.

But alas, in ITs the MNG-5576 completely unrelated IT there is an assertion to have WARNING-free log. This IT uses the IT-plugins/IT-plugin-expression EvalMojo, that in turn uses the deprecated `${localRepository}` parameter (but does not use it). Result is, Maven 3.9.1 emits a WARNING about use of deprecated parameter and the IT fails.

Further inspection shows, that while EvalMojo injects ArtifactRepository for local repository, there is only one IT that actually uses it, the MNG-4305, but even that one is interested in basedir of the local repository only. So to say, the use of deprecated ArtifactRepository type is not needed at all.

Fix:
* change EvalMojo to not expose in context the localRepository (w/ type ArtifactRepository), but a new expression `localRepositoryBasedir` only, that is injected in non-deprecated way (in real life repoSysSession would be injected, but in IT we keep all super-safe and use Object types).
* adjusted MNG-4305 to use new epxression instead to use object reflection in template to get basedir from ArtifactRepository
* This makes the originally failing MNG-5576 pass, as warning due EvalMojo is gone.

See
https://issues.apache.org/jira/browse/MNG-7706
apache/maven#1009
This PR deprecates the 'localRepository' mojo parameter expression,
and Core will emit warning if used by any Mojo.

---

https://issues.apache.org/jira/browse/MNG-7706
@cstamas cstamas force-pushed the maven-3.9.x-MNG-7706-deprecate-localRepository-expr branch from b7fc8d8 to f55f5cb Compare February 23, 2023 12:55
@cstamas cstamas merged commit 95ceb71 into apache:maven-3.9.x Feb 23, 2023
@cstamas cstamas deleted the maven-3.9.x-MNG-7706-deprecate-localRepository-expr branch February 23, 2023 14:49
cstamas added a commit to cstamas/maven that referenced this pull request Feb 23, 2023
)

This PR deprecates the 'localRepository' mojo parameter expression, and Core will emit warning if used by any Mojo.

---

https://issues.apache.org/jira/browse/MNG-7706
cstamas added a commit that referenced this pull request Feb 23, 2023
…1012)

This PR deprecates the 'localRepository' mojo parameter expression, and Core will emit warning if used by any Mojo.

---

https://issues.apache.org/jira/browse/MNG-7706
@inad9300
Copy link

In practical terms, what does this mean for people with <localRepository> in their settings.xml? What are we supposed to do now?

@cstamas
Copy link
Member Author

cstamas commented Mar 31, 2023

As description says "This PR deprecates the 'localRepository' mojo parameter expression". Has nothing to do with settings.xml. Don't mix the two.

@cstamas
Copy link
Member Author

cstamas commented Mar 31, 2023

Moreover, please use mailing lists for these sort of questions, not old/closed pull requests https://maven.apache.org/mailing-lists.html

@inad9300
Copy link

I upgrade to 3.9.x, I see a warning, and I have a single place where I use "localRepository". Maybe make messages more clear, make release notes more clear, and upgrade your communication channels to something more usable.

@cstamas
Copy link
Member Author

cstamas commented Mar 31, 2023

This is a project maintained by volunteers, hence you can contribute as well! Feel free to produce as many quality patches and other improvements project-wise as you like! We will be glad to review them 😺

@cstamas
Copy link
Member Author

cstamas commented Mar 31, 2023

Created https://issues.apache.org/jira/browse/MNG-7754

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants