rewrite icon indicating copy to clipboard operation
rewrite copied to clipboard

"Add Maven Parent" recipe

Open rcsilva83 opened this issue 1 year ago • 3 comments

What problem are you trying to solve?

I need to add a parent POM to my projects.

Describe the solution you'd like

I'd like a recipe for that as there already has one for changing the Maven parent.

Have you considered any alternatives or workarounds?

Using text recipe

Additional context

Are you interested in contributing this feature to OpenRewrite?

I can try :)

rcsilva83 avatar Jun 07 '24 20:06 rcsilva83

hi @rcsilva83 ! Thanks for the suggestion. For this one I'd assume the implementation would be rather similar to Change Maven Parent https://github.com/openrewrite/rewrite/blob/28e7b125655fa507d68f80ed1dafa2dee38a38fa/rewrite-maven/src/main/java/org/openrewrite/maven/ChangeParentPom.java#L44

Perhaps we can start with a draft PR with some unit tests, and then I'll help guide you through what's needed beyond that.

Tests are also a great way to think through and codify how you'd want to handle certain cases, like:

  • should we match just any pom.xml file? Or only matching certain criteria?
  • How to handle an existing parent? Is that the same for multi module projects?

timtebeek avatar Jun 07 '24 20:06 timtebeek

Hi @timtebeek

I'm trying to build the project on my machine but I'm having issues:

A problem occurred configuring project ':tools:language-parser-builder'.
> Cannot find a Java installation on your machine matching this tasks requirements: {languageVersion=17, vendor=any, implementation=vendor-specific} for WINDOWS on x86_64.
   > No locally installed toolchains match and toolchain download repositories have not been configured.

I'm running with JDK21 but it I run with JDK17 I have the same problem with languageVersion=21. I'm trying to configure org.gradle.java.installations.paths on gradle.properties but nothing changed...

Can you help me with this?

rcsilva83 avatar Jun 07 '24 20:06 rcsilva83

hi! That's curious; are you using any non standard paths for your installed JDKs? I know Gradle does some discovery that might fail to detect your JDK paths.

You might be able to work around this though by following these instructions to not load troublesome modules: https://github.com/openrewrite/rewrite/blob/28e7b125655fa507d68f80ed1dafa2dee38a38fa/IDE.properties.tmp#L1-L7

We also have some more general IDE setup instructions on these pages.

  • https://docs.openrewrite.org/reference/building-openrewrite-from-source
  • https://docs.openrewrite.org/authoring-recipes/recipe-development-environment

Hope that helps!

timtebeek avatar Jun 07 '24 21:06 timtebeek

  • Fixed in https://github.com/openrewrite/rewrite/pull/4289; thanks again!

timtebeek avatar Jul 28 '24 20:07 timtebeek