Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maven: openrewrite should support AddModule / RemoveModule #4759

Open
cunningt opened this issue Dec 9, 2024 · 3 comments
Open

Maven: openrewrite should support AddModule / RemoveModule #4759

cunningt opened this issue Dec 9, 2024 · 3 comments
Labels
question Further information is requested recipe Requested Recipe

Comments

@cunningt
Copy link

cunningt commented Dec 9, 2024

What problem are you trying to solve?

OpenRewrite has recipes that add and remove plugins / dependencies / etc. Openrewrite should also be able to add or remove a <module/> to a pom's <modules/>

What precondition(s) should be checked before applying this recipe?

Describe the situation before applying the recipe

For AddModule - the situation before applying the recipe might be

<modules>
    <module>foo</module>
</modules>

Describe the situation after applying the recipe

For AddModule - the situation after applying the recipe to add a "bar" module would be

<modules>
    <module>foo</module>
    <module>bar</module>
</modules>

Have you considered any alternatives or workarounds?

Any additional context

Are you interested in contributing this recipe to OpenRewrite?

@timtebeek
Copy link
Contributor

hi @cunningt ! What kind of recipes are you looking to compose using any Add/RemoveModule recipes?

By themselves any such Add/RemoveModule recipes are unlikely to produce anything that meaningfully works; those modules would need to be matched up with recipes to add/remove the associated pom files, as well as potentially other associated sources. The targeting for any such recipes would also have to be very specific, as you'd likely only want to add this to a root pom.xml, not any nested sub pom.xmls.

Taking the above into account, those constraints then quickly morph into an imperative recipe that as a small part changes a pom.xml, in likely restricted cases, as opposed to something that can easily be composed in a declarative recipe and be of reusable value.

Any details you can provide about your intended use would be helpful to shape any recipes to build, or perhaps nudge towards an imperative recipe for the specific use case you're after.

@timtebeek timtebeek added question Further information is requested recipe Requested Recipe labels Dec 9, 2024
@cunningt
Copy link
Author

Use case : applying frequent changes and enhancements downstream to a pom.xml file where the pom.xml file is quite volatile upstream. Managing the changes through a .patch file doesn't work well because of frequent and inevitable merge conflicts.

rewrite provides 90% of what I'd need here. It can add properties, dependencies, plugins, and dependencyManagement entries without having to worry about merge conflicts. I know use as a patching tool isn't really the intended purpose of rewrite, but it can do it pretty well.

Add/Remove modules would really be helpful in this - and I agree that by itself it wouldn't completely solve the issue, I still would need to copy the module directory - but I'd love it if rewrite could handle more of the pom.xml changes I'm trying to make and the ability to add/remove modules would help.

@timtebeek
Copy link
Contributor

Thanks for that added context! In this case I'd perhaps then still lean towards at least starting out those recipes outside openrewrite/rewrite, as any such recipes by themselves are not yet something anyone can run in isolation and expect to work well. The potential then to have to field support questions on a recipe that requires knowledge of what it can and can't do is not ideal. Do you already have a place for any such custom recipes? I know colleagues of yours for instance maintain apache/camel-upgrade-recipes separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested recipe Requested Recipe
Projects
Status: No status
Development

No branches or pull requests

2 participants