rewrite-maven-plugin icon indicating copy to clipboard operation
rewrite-maven-plugin copied to clipboard

Support Reading `<configuration>` Tag from settings.xml in `MavenMojoProjectParser.buildSettings()` so that config like connection timeout can be passed to rewrite-maven module

Open skazaruddin opened this issue 1 year ago • 3 comments

Description:

Currently, the rewrite-maven module does not support server configuration details from the tag in the settings.xml file because the MavenMojoProjectParser class in the "rewrite-maven-plugin" does not read this configuration while creating the MavenSettings object before setting the MavenExecutionContextView. As a result, during runtime the operations that depend on these configurations do not function as expected, even though the "rewrite-maven" module has unit tests for it. e.g. reading timeouts from the tag.

Link to the Code:

https://github.com/openrewrite/rewrite-maven-plugin/blob/7e86a021a44645340f92592b9fc244e6e47ea3f9/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java#L663

Proposed Enhancement:

Enhance the MavenMojoProjectParser.buildSettings() method to read and incorporate the <configuration> tag from the settings.xml file while creating the MavenSettings object. This will ensure that all server configurations, including timeouts specified in the tag, are correctly utilized at runtime.

skazaruddin avatar Aug 03 '24 22:08 skazaruddin

hi! We ought to be parsing the configured timeout after this PR

  • https://github.com/openrewrite/rewrite/pull/4302

Note that we do not support all configuration options there, but a singular <timeout> should work. Is that not working for you?

Proactively closing this issue; let me know if I misunderstood & we'll reopen! A clear example of what input ought to be parsed if not already ought to help then.

timtebeek avatar Aug 07 '24 17:08 timtebeek

Hi @timtebeek , It's not working for me and the reason is the "rewrite-maven-plugin" is not reading the <timeout> from <configuration> tag inside <server> tag in settings.xml. Ideally, the MavenMojoParser should read the timeout field, then create ServerConfiguration object and pass it in below mentioned line, so that the Server object in MavenSettings will the timeout value.

https://github.com/openrewrite/rewrite-maven-plugin/blob/7e86a021a44645340f92592b9fc244e6e47ea3f9/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java#L704

Then, the pull request will work fine, as it will receive, the MavenSettings object with timeout value inside Configuration object.

skazaruddin avatar Aug 08 '24 15:08 skazaruddin

Thanks for the feedback. Perhaps an example file or even a PR that fixes this could help then, as I'm still a bit confused.

timtebeek avatar Aug 08 '24 15:08 timtebeek