Allow configuration of HTTP timeouts for maven repositories
What's changed?
Changed maven downloader to allow configuration of connection/read timeouts
What's your motivation?
https://maven.apache.org/guides/mini/guide-http-settings.html#connection-timeouts
Anything in particular you'd like reviewers to focus on?
No
Anyone you would like to review specifically?
No
Have you considered any alternatives or workarounds?
No
Any additional context
N/A
Checklist
- [x] I've added unit tests to cover both positive and negative cases
- [x] I've read and applied the recipe conventions and best practices
- [x] I've used the IntelliJ IDEA auto-formatter on affected files
Nice addition @ammachado ! I'm tagging @sambsnyd for an additional review as we're adding fields to tree classes, and he reworked parts of the Maven repository handling recently.
Also copying the details on the failed test to save others a click
MavenPomDownloaderTest > centralIdOverridesDefaultRepository() FAILED
java.lang.AssertionError:
Expecting elements:
[MavenRepository(id=local, uri=file:///home/runner/.m2/repository, releases=true, snapshots=true, knownToExist=true, username=null, *** connectTimeout=null, readTimeout=null, deriveMetadataIfMissing=false),
MavenRepository(id=central, uri=https://repo.maven.apache.org/maven2, releases=true, snapshots=false, knownToExist=true, username=null, *** connectTimeout=null, readTimeout=null, deriveMetadataIfMissing=true)]
to be exactly 1 times URI https://internalartifactrepository.yourorg.com/
at org.openrewrite.maven.internal.MavenPomDownloaderTest.centralIdOverridesDefaultRepository(MavenPomDownloaderTest.java:115)
Nice addition @ammachado ! I'm tagging @sambsnyd for an additional review as we're adding fields to tree classes, and he reworked parts of the Maven repository handling recently.
Also copying the details on the failed test to save others a click
MavenPomDownloaderTest > centralIdOverridesDefaultRepository() FAILED java.lang.AssertionError: Expecting elements: [MavenRepository(id=local, uri=file:///home/runner/.m2/repository, releases=true, snapshots=true, knownToExist=true, username=null, *** connectTimeout=null, readTimeout=null, deriveMetadataIfMissing=false), MavenRepository(id=central, uri=https://repo.maven.apache.org/maven2, releases=true, snapshots=false, knownToExist=true, username=null, *** connectTimeout=null, readTimeout=null, deriveMetadataIfMissing=true)] to be exactly 1 times URI https://internalartifactrepository.yourorg.com/ at org.openrewrite.maven.internal.MavenPomDownloaderTest.centralIdOverridesDefaultRepository(MavenPomDownloaderTest.java:115)
As a suggestion, can you consider publishing the test reports on a failed build? Perhaps using a custom action for it (for example, https://github.com/marketplace/actions/junit-report-action).
As a suggestion, can you consider publishing the test reports on a failed build? Perhaps using a custom action for it (for example, https://github.com/marketplace/actions/junit-report-action).
Yes I'd been eyeing https://github.com/gradle/actions/tree/main/setup-gradle#build-reporting earlier today, as part of our upgrade in https://github.com/openrewrite/gh-automation/ . It's been a pain point of mine as well to have to go into the logs.
What's the motivation here? Does this solve a problem you are running into?
Not my PR but I am watching as I also have an issue that would be solved with this.
During execution the plugin downloads maven-metadata.xml files. My company's internal proxy of Maven Central is very slow for downloads of these files. I cannot get the wider and obvious root cause fixed. The files do download eventually, however in the current implementation there is no way to set the timeout as the custom code to download the maven-metadata.xml files in the plugin does not respect the <configuration> declarations for a <server> specified here.
Not my PR but I am watching as I also have an issue that would be solved with this.
During execution the plugin downloads
maven-metadata.xmlfiles. My company's internal proxy of Maven Central is very slow for downloads of these files. I cannot get the wider and obvious root cause fixed. The files do download eventually, however in the current implementation there is no way to set the timeout as the custom code to download themaven-metadata.xmlfiles in the plugin does not respect the<configuration>declarations for a<server>specified here.
That's exactly the issue that originated this change.
Thanks a lot @ammachado ! Should help to conform to the user's configured session, as we've seen more variation in artifact repository performance than we had expected folks would tolerate in their day to day work. 🙃