Main Tutorials

Maven – How to force re-download project dependencies?

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.

Terminal

$ mvn dependency:purge-local-repository

[INFO] Scanning for projects...
[INFO]
[INFO] --------------< com.mkyong.examples:maven-code-coverage >---------------
[INFO] Building maven-code-coverage 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:purge-local-repository (default-cli) @ maven-code-coverage ---
Downloading from central: https://repo.maven.apache.org/maven2/org/junit/jupiter/junit-jupiter-engine/5.3.1/junit-jupiter-engine-5.3.1.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/junit/jupiter/junit-jupiter-engine/5.3.1/junit-jupiter-engine-5.3.1.pom (2.4 kB at 2.1 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.pom

//...

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.086 s
[INFO] Finished at: 2018-11-20T15:22:28+08:00
[INFO] ------------------------------------------------------------------------

References

  1. Maven dependency:purge-local-repository

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
4 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
kevin
3 years ago

How is different from deleting .m2 contents and running maven install again

Ithink
2 years ago
Reply to  kevin

.m2 contains the dependencies of any mvn project that you built on your machine, I suppose this plugin deletes only the ones involved in the project where you run the command

Mohammed Zayadi
4 years ago

thanks a lot dear 🙂

kevin
3 years ago

How is it different from deleting .m2 folder contents and building again.