openrewrite / rewrite-maven-plugin

OpenRewrite's Maven plugin.
https://openrewrite.github.io/rewrite-maven-plugin/plugin-info.html
Apache License 2.0
143 stars 74 forks source link

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

Open skazaruddin opened 3 months ago

skazaruddin commented 3 months ago

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.

timtebeek commented 3 months ago

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

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.

skazaruddin commented 3 months ago

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.

timtebeek commented 3 months ago

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.