Questions tagged [openrewrite]

OpenRewrite is a software product that automates refactoring of code. Use this tag for questions regarding the OpenRewrite product.

OpenRewrite enables large-scale distributed source code refactoring.

OpenRewrite is hosted on GitHub: https://github.com/openrewrite
There is also a documentation site: https://docs.openrewrite.org/

43 questions
3
votes
1 answer

Unable to call primary constructor for Recipe class org.openrewrite.github.AddCronTrigger in org.openrewrite.java.migrate.Java8toJava11

I'm having some trouble trying the org.openrewrite.java.migrate.Java8toJava11 When we execute the maven goal it fails with this error: org.openrewrite.config.RecipeIntrospectionException[m: [1;31mUnable to call primary constructor…
2
votes
0 answers

When updating from spring boot 2.5 to 2.7 with openrewrite I get a NoSuchMethodError

Hopefully somebody can help me :) I am trying to update a project from spring boot 2.5 to spring boot 2.7 with the openrewrite recipe. After trying this several times I keep getting the same error message. I tried excluding the exact module this…
Niek7301
  • 21
  • 1
2
votes
1 answer

NoSuchMethodError while running org.openrewrite.java.testing.junit5.JUnit5BestPractices recipe

I have an existing project, want to upgrade test cases to Junit5. Tried to run below command mvn -U org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-testing-frameworks:RELEASE …
Nagendra Busam
  • 235
  • 1
  • 5
  • 19
2
votes
1 answer

How can I exclude files from beeing parsed by rewriteRun

I want to use the recipe AddOrUpdateAnnotationAttribute for adding parameters to a Java annotation. This is part of the package org.openrewrite.java, so I've added only the following dependency in my init.gradle: dependencies { …
MGK
  • 101
  • 5
2
votes
1 answer

What is the sequence of recipe execution when defining multiple active recipes

In my init.gradle file, I have defined 2 active recipes. rewrite { activeRecipe("org.openrewrite.java.testing.mockito.Mockito1to4Migration", "com.myorg.openrewrite.Mockito1to4Migration") } When running gradle -I init.gradle…
MGK
  • 101
  • 5
2
votes
2 answers

Upgrading Micronaut 2.X to 3.X using OpenRewrite superclass access check failed

I have the Micronaut 2.5.12 application and trying to upgrade to the 3.x using OpenRewrite plugins { id("com.github.johnrengelman.shadow") version "7.0.0" id("io.micronaut.application") version "1.5.0" id 'maven-publish' …
San Jaisy
  • 15,327
  • 34
  • 171
  • 290
1
vote
1 answer

Do we have recipe for AWS SDK1 to SDK2 migration

As Java-17 onwards AWS SDK-1 is not fully supported. Do we have already recipe for SDK1 to SDK2 migration or any plan to have it in coming weeks?
1
vote
0 answers

How I can add an array parameter to an annotation in openrewrite?

I'm trying to dynamically add arguments to an array parameter an in annotation. I'm writing my own recipe. Expected result: @Import({ TestConfiguration.class, XyzConfiguration.class, AbcConfiguration.class, ... }) I can add new…
dk1337
  • 11
  • 1
1
vote
1 answer

How can I make Gradle pick the right guava variant?

I'm trying to use the OpenRewrite plugin in my Java project and it requires guava. Gradle is unable to choose between two variants because the plugin doesn't check attribute org.gradle.jvm.environment. The two variants are androidRuntimeElements and…
1
vote
0 answers

OpenRewrite recipe don't do anything

I am executing this mvn command on root level of my project. The project has many submodules and APIs. mvn -U org.openrewrite.maven:rewrite-maven-plugin:run \ -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-migrate-java:RELEASE…
Spring
  • 11,333
  • 29
  • 116
  • 185
1
vote
1 answer

OpenRewrite: Do we have recipes available for .Docker File change?If not then what approach we should follow to change Docker file through OpenRewrite

docker file update through openrewrite if possible. I am willing to to update Java version in docker file through OpenRewrite. **FROM amazoncorretto:17** USER root RUN yum update -y RUN yum upgrade -y RUN yum update - ------ -----
1
vote
2 answers

OpenRewrite - recipe to change formatting of curly brackets

I started to playing with OpenRewrite and what I need is to use OpenRewrite to change the formatting of curly braces (for all the Java classes and interfaces). So from this: public class Foo { // something here } to have this: public class Foo…
PetrS
  • 1,110
  • 14
  • 38
1
vote
1 answer

Should JavaVisitor.maybeRemoveImport also remove imports of outer class?

If you pass an inner class to maybeRemoveImport then imports of the outer class are not removed. Is this intended or could this be a helpful extension of the method? An example: I have this code import javax.ws.rs.core.Response; public class…
1
vote
1 answer

How to replace static imports of class constants in OpenRewrite?

I want to replace static imports of class constants with other class constants. Example: Original code import javax.ws.rs.*; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; class ControllerClass { @Produces(APPLICATION_JSON) …
1
vote
1 answer

Rewrite java packages and groupid/artifact names of super pom project

I'm trying to use openrewrite to refactor one of my projects which is a hierachical maven project (super POM with submodules). Basically I want to replace 1 package name with a new package name (fe. org.myproject to com.myproject) and refactor also…
Cob Olus
  • 11
  • 1
1
2 3