How to force re-download Gradle Dependencies


If you have a Java Project based on Gradle Build and you want to re-download all the dependencies that you have defined in your build.gradle file, then all you need to do is run the below command in command-line/terminal.


Steps:

  1. Open Command-Line/Terminal in your IDE (Eclipse/VSCode/IntelliJ)
  2. Move to the location of your project where you have the gradlew file.
  3. Now run the below gradle command
  4. ./gradlew build --refresh-dependencies
  5. Once the build is complete run your project to verify.

Note: The --refresh-dependencies option tells Gradle to ignore all cached entries for resolved modules and artifacts.

It’s a common misconception to think that using --refresh-dependencies will force download of dependencies. This is not the case: Gradle will only perform what is strictly required to refresh the dynamic dependencies. This may involve downloading new listing or metadata files, or even artifacts, but if nothing changed, the impact is minimal.

Reference: https://docs.gradle.org/current/userguide/dependency_management.html


Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright Β© Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap