I am running the following command from within a maven project directory:
mvn dependency:purge-local-repository
What is the expected behavior?
Will it delete (and re-download?) all the dependencies already existing in my local repo for that particular project (i.e. whose directory I am in) or will it delete all the contents of my local repo?
In Maven, you can use Apache Maven Dependency Plugin, goal dependency:purge-local-repository to remove the project dependencies from the local repository, and re-download it again.
It only cleans the project. Show activity on this post. Show activity on this post. With the help of Purging local repository dependencies you need to do that.
Maven's local repository is a directory on the local machine that stores all the project artifacts. When we execute a Maven build, Maven automatically downloads all the dependency jars into the local repository. Usually, this directory is named .
By default, purge-local-repository
will remove from the local repository all the files associated to the version of each dependency (including transitive) of the project it is ran on:
Remove the project dependencies from the local repository, and optionally re-resolve them.
The several factors coming into play are:
actTransitively
parameter.reResolve
parameter.foo:bar:1.0
is purged, all the files under the path foo/bar/1.0/*
will be removed. This is configurable through the resolutionFuzziness
parameter (whose default value is version
):
artifactId
would purge all the files under the path to artifact id of the artifact being purged. In the example above, all files under foo/bar/**
would be purged (so, all versions are removed).groupId
would purge all the files under the path to group id of the artifact being purged. In the example above, all files under foo/**
would be purged (so, all versions for all artifact ids are removed).file
would only purge the file for the artifact being purged. In the example above, only the files bar-1.0.jar*
will be removed (this includes any sha1
they could have). It would not purge the associated POM file.You can see which artifacts are going to be purged by printing the list of all dependencies for the project with the list
goal:
mvn dependency:list
optionally adding excludeTransitive
to this command, if you decide not to purge transitive dependencies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With