How to refresh Maven artifacts that has been redeployed?

69 views Asked by At

I've configured my nexus repository with the Allow Redeploy deployment policy and now I need to refresh my local repository to reflect release redeployments (getting the artifacts uploaded by other users, without version change, after they were downloaded to my local repo)

Is there a way to do that?

I've tried by using the maven-dependency-plugin:

mvn dependency:resolve -DoverWriteReleases=true

But the local repository is not refreshed

I'd also like to refresh my full local repo (not only one project's dependencies) but it seems the resolve goal requires a project to be run

Thanks in advance

2

There are 2 answers

1
Antonio Petricca On

Sometimes I need to do the same, so a fast, simple and stupid :), but working solution is:

rm -rf ~/.m2/repository

Later, each project maven build will download fresh copies of the artifacts.

As alternative you could remove only your own repository subtree:

rm -rf ~/.m2/repository/my/own/domain/artifact/

That pseudo solution has a further advantage: to free the disk space occupied by old artifacts versions I will never use again.

0
Santiago Ruiz On

After a long and rich discussion I can be sure that refreshing (checking for changes and downloading new content only) is not possible with Maven releases

The problem is in the lack of metadata about the last update of the component in the local repo

Snapshots are the only way to do that because they have a file (maven-metadata-local.xml) that allow the comparison with the remote content

Releases are, then, inmutable by design as was commented by Mr Steel and as I certainly know now

Thanks, commenters, for your time and patience