Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven retry dependency download if failed

Tags:

java

maven

During downloading dependencies by maven, one of it fails due to network issues:

Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-failsafe-plugin/2.16/maven-failsafe-plugin-2.16.pom
Plugin org.apache.maven.plugins:maven-failsafe-plugin:2.16 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-failsafe-plugin:jar:2.16

I would like to retry it for n times where n will be configurable. How can I do this?

like image 203
bercik Avatar asked Feb 03 '26 17:02

bercik


1 Answers

I had a similar problem in Gitlab CI/CD. This seems to have resolved the issue:

-Dmaven.wagon.http.retryHandler.count=3

Since version 3.2, the retry handler can be configured with system properties:

...

    • maven.wagon.http.retryHandler.count = number of retries for default or standard implementations.

Other HTTP client settings are described here: https://maven.apache.org/wagon/wagon-providers/wagon-http/

Edit: As keiki pointed out in the comments, 3 appears to be the default, so it's not clear how setting this value would help. Please comment with your experience.

like image 88
crenshaw-dev Avatar answered Feb 05 '26 05:02

crenshaw-dev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!