Maven (error) clean up the local warehouse

I am running the following command in maven project directory:

clean target

mvn clean -U

Clean up the maven packages in the local warehouse that the project depends on

mvn dependency:purge-local-repository


Will it delete (and re-download?) all dependencies that already exist in my local repository for  that specific project  (i.e. the directory I'm in) or will it delete  the entire  contents of my local repository?

Best answer

By default,  purge-local-repository  will remove from the local repository all files associated with versions of every dependency (including transitive) of the project it runs on:

Remove the project dependencies from the local repository, and optionally re-resolve them.


A few factors that come into play are:
  • By default, the plugin cleans up transitive dependencies; this is  configurable scoped via actTransitively  .
  • By default, all artifacts purged from the local repository are re-resolved; this is  configurable scoped via reResolve  .
  • The actual files purged from the local repository correspond to all files associated with the version of the artifact that was purged. For example, if dependencies  foo:bar:1.0are cleared,  foo/bar/1.0/* all files under path will be removed. This can  be configured  via the resolutionFuzziness version parameter (its default value  ):
  • artifactId A value of will clear all files under the Artifact ID path of the cleaned Artifact. In the example above, foo/bar/** all files under will be purged (thus, all versions deleted).
  • groupId A value of will purge all files under the path to the group ID of the Artifact to purge. In the example above, foo/** all files under will be purged (thus, all versions for all Artifact IDs will be deleted).
  • file A value of will only clean files for the Artifact being cleared. In the example above, only files  bar-1.0.jar*will be deleted (this includes any they may have  sha1). It does not clean up the associated POM files.
  • You can see which artifacts will be cleaned up by using  list  to print a list of all dependencies for your project. Target:
    mvn dependency:list
    Optionally add  excludeTransitive  to this command, if you decide not to clear transitive dependencies.

Demo:

 

Guess you like

Origin blog.csdn.net/qq_61324603/article/details/130334787
Recommended