Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force re-download of release dependency using Maven

People also ask

How do I force Maven to download?

Force maven to fetch dependencies from the remote repository while building the project. We can use -U/--update-snapshots flag when building a maven project to force maven to download dependencies from the remote repository.

How do I force Maven to download dependencies in Eclipse?

You can right-click on your project then Maven > Update Project..., then select Force Update of Snapshots/Releases checkbox then click OK.

How do I redownload Maven dependencies in Intellij?

Press Ctrl + Shift + A to find actions, and input "reload", you will find the "Reload All Maven Projects". On a Mac, use ⌘ + ⇧ + A instead.


You cannot make Maven re-download dependencies, but what you can do instead is to purge dependencies that were incorrectly downloaded using mvn dependency:purge-local-repository

See: http://maven.apache.org/plugins/maven-dependency-plugin/purge-local-repository-mojo.html

This looks up the list of all transitive dependencies of the current project, deletes them, then redownloads them. You can even add it as a plugin into your pom if you want to run it with every build.


I just deleted my ~/.m2/repository and that forced a re-download ;)


Based on Ali Tokmen answer. I managed to force delete a single specific local dependency with the following command:

mvn dependency:purge-local-repository -DmanualInclude=com.skyfish:utils

With this, it removes utils from my .m2/repository and it always re-download the utils JAR dependency when I proceed to run mvn clean install. If you want something more programmatic possibly also see the -Dinclude=... option.


I think following command may help you!


mvn -U clean install

Project right click-> Maven -> Update Project and check the checkboxes as in the screen shot. It will update releases as well :)

enter image description here