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

use-latest-versions or use-latest-releases changes versions to last version found in local repository, not in remote repo #677

Open
Dankur96 opened this issue Sep 8, 2022 · 9 comments

Comments

@Dankur96
Copy link

Dankur96 commented Sep 8, 2022

When I use goals "use-latest-versions" or "use-latest-releases" it changes versions of dependencies to the last versions found in local repository (version from maven-metadata-local.xml file in dependency directory).
The same situation occurs, when I use "display-dependency-updates" goal, it also checks for versions in local repository first.
Is it normal behaviour of this goal or should it always check remote repository for updates?

It can lead to mistakes, for example if you have two projects:

  1. core project which contains all "core dependencies"
  2. project, which uses these core dependencies
    In case I change locally version of dependency in core project to the HIGHER version than last version available in remote repository and do "maven install" in core project (what will make maven-metadata-local.xml file and create new dependency in .m2\repository), after using "use-latest-versions" it updates versions to these which has not been released and uploaded to remote repository.
    That will lead to errors in builds, etc.

What I expect is that "use-latest-versions" or "use-latest-releases" will pull latest versions directly from remote repository and change them in pom.xml file.

Is it normal behaviour of this plugin or some kind of bug?

@pzygielo

This comment was marked as off-topic.

@Dankur96
Copy link
Author

Dankur96 commented Sep 9, 2022

"-U" option works only if local repository contain lower version, than remote repo. Otherwise it will not work as expected.
As far as I know, -U option is not for forcing maven to check only remote repository, but to force check if remote repository contains higher version.

@andrzejj0
Copy link
Contributor

Looking into

@andrzejj0
Copy link
Contributor

andrzejj0 commented Sep 21, 2022

The mojo always checks both local as well as all remote repositories. In this it follows the maven-compat library, which it currenty uses. The current maven-core library has the same behaviour in that regard.

In that light, that it follows maven's behaviour, I don't think it's necessarily a bug.

In your particular problem, perhaps the new options, -Dmaven.version.ignore (soon to be renamed to -Dmojohaus.versions.ignore) could be helpful -- you can then exclude some version patterns, e.g. -SNAPSHOTS, from being considered.

See #454

@las66
Copy link

las66 commented Oct 4, 2022

I have the same problem. I need to build different versions of the project, so there are a lot of extra versions of dependencies locally. -Dmaven.version.ignore won't help here. I only need to check versions on the remote repository each time.

So far, the only workaround I've found is to first remove all versions of the dependencies I need from the local repository, and then use use-latest-versions.

But I don't like this way. Is there a normal way to scan versions of a remote repository only?

@andrzejj0
Copy link
Contributor

So basically something to be able to provide rules to disable repositories (here: local repo), but via command line, e.g. using user properties?

@las66
Copy link

las66 commented Oct 5, 2022

Yes

@slawekjaranowski
Copy link
Member

Now we use new Resolver API - we can check if we can provide a null or empty local repository for versions resolving.

Copy link

This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 30 days.

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

No branches or pull requests

5 participants