Questions tagged [openrewrite]
OpenRewrite is a software product that automates refactoring of code. Use this tag for questions regarding the OpenRewrite product.
64
questions
0
votes
1
answer
32
views
Migrate from Log4j2 to Logback not working using OpenRewrite recipe
Following the instructions on https://docs.openrewrite.org/recipes/java/logging/logback/log4jtologback I've added the plugin and dependencies to my pom.xml. I had to exclude many artifacts because of ...
-2
votes
0
answers
40
views
"Cannot find symbol" errors using OpenRewrite
The problem is when I use this recipe
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>5.8.1</...
0
votes
1
answer
38
views
org/openrewrite/maven/RewriteRunMojo : Unsupported major.minor version 52.0
I am using OpenRewrite on my project, in IntelliJ.
This is the maven configuration for the plugin
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-...
0
votes
1
answer
25
views
Where are the instructions for running OpenRewrite receipes when my build is not in maven or gradle
I have a build that uses ant
I want to run some OpenRewrite reciepes against it
Previously there was this page that described how I could do that (it was there a week ago):
https://docs.openrewrite....
2
votes
0
answers
69
views
How to get OpenRewrite running without build tool plugins (i.e. standalone)
The description at Running Rewrite without build tool plugins suggests that OpenRewrite can be run on any Java project without requiring that project being a Maven or Gradle project. However, I could ...
0
votes
1
answer
54
views
First recipe : helloworld exercise
Working on the new recipe which is the helloworld exercise in the openrewrite docs .Getting an error while running the recipe . Any help will be appreciated .
https://docs.openrewrite.org/authoring-...
0
votes
2
answers
113
views
Why isn't my parent pom getting updated with openrewrite recipe?
I am using the recipe to upgrade spring boot version
https://docs.openrewrite.org/recipes/java/spring/boot3/upgradespringboot_3_0
Nothing is getting in pom.xml but I see build success and changes ...
0
votes
1
answer
21
views
Do we have org.openrewrite.build.recipe-library plugin available for maven project
Below are the plugins available for Gradle project. Do we have same plugin if I want to opt Maven project instead of Gradle:-
plugins {
id("java")
id("org.openrewrite.rewrite&...
0
votes
1
answer
42
views
Only Run OpenRewrite on VCS changed files
Is there a way we can specify only files that are modified on local to be modified. Like in some IDEs we have make changes to only VCS changed files, is it possible to only run rewrite on VCS changed ...
0
votes
0
answers
34
views
Unable to load Recipe: java.lang.IllegalArgumentException: Cannot construct instance
I am trying to create own OpenRewrite recipes by follow up recipe-development-environment instruction but getting below error while running my recipe:-
[ERROR] Recipe validation error in com.sk.app....
0
votes
1
answer
28
views
OpenRewrite recipe for adding a maven dependency to a specific pom.xml in multi modular project environment
I have few multi module projects where each modules has their own pom.xml , Also parent folder has pom.xml
Do we have recipe to add maven dependency in specified pom.xml only? Because If I simply ...
0
votes
0
answers
23
views
openrewrite: The type de.danielbechler.diff.ObjectDiffer cannot be resolved
When writing a Java recipe for openrewrite using maven, the class ObjectDiffer cannot be resolved:
The type de.danielbechler.diff.ObjectDiffer cannot be resolved. It is indirectly referenced from ...
0
votes
0
answers
178
views
OpenRewrite recipe specified in rewrite.yml with values for all mandatory properties fails because the recipe does not receive the values
I am trying to replicate SayHelloRecipe example from the OpenRewrite documentation. My recipe is as follows:
package my.package.recipes;
import com.fasterxml.jackson.annotation.JsonCreator;
import ...
0
votes
0
answers
19
views
OpenRewrite: Example for MergeYaml recipe with objectIdentifyingProperty and acceptTheirs properties
Is there any example available for MergeYaml recipe where acceptTheirs and objectIdentifyingProperty are used.
Official documentation not elaborate much on these options:-
type: specs.openrewrite.org/...
0
votes
1
answer
31
views
How can I specify org.openrewrite.java.logging.SystemPrintToLogging options?
I would very much appreciate a sample maven or YAML configuration for the four options this rewrite recipe supports, primarily addLogger and logger ... having been struggling with it for quite some ...
0
votes
0
answers
15
views
Can we use some filter along with Json path while using Mergeyaml recipe
I have to add some addition key-value pair in my YAML file. But Mergeyaml offers only JsonPath expression used to find matching keys. Can we apply some filter or condition along with Json path like if ...
0
votes
1
answer
59
views
Can we skip unit-test case updates while running OpenRewrite recipes
My requirement is to modify Junit test cases manually after running OpenRewrite recipe command. Can we can run with dryRun or run maven commands with something like -Dmaven.test.skip=true ?
I tried ...
1
vote
1
answer
139
views
Is there a way to combine Openrewrite yaml recipes and custom recipes into a single recipe for execution?
I like to create a single Openrewrite migration jar that includes custom recipes and rewrite.yml recipes.
I would like it to be executed using only a one liner maven call without altering the current ...
1
vote
1
answer
62
views
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
35
views
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,
...
0
votes
2
answers
53
views
Why WebMvcConfigurerAdapter class is not replaced by openrewrite while upgrading to spring boot 3.1
WebMvcConfigurerAdapter is deprecated of course and I know what to use instead of it. But my question is 'was the replacement not taken care in the recipe'
Similarly I see that OrderImpl class from ...
0
votes
0
answers
32
views
OpenRewrite: recipes example for adding a new key: value pair if a specific template matches in yaml
I have multiple yaml files, but we have to add a addition parameter only if specific template matches. Ex:
stages:
- template: templates/my-java-service-v1.yaml@codeway
parameters:
...
5
votes
2
answers
2k
views
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....
0
votes
1
answer
33
views
OpenRewrite: AddCommentToMavenDependencymaven recipe not working with given POM
I am trying to use AddCommentToMavenDependency recipe to add a comment line inside a dependency declaration. But I think I am not able to provide the correct xpath, please correct.
recipeList:
- org....
0
votes
1
answer
585
views
When updating from spring boot 2.7 to 3 with openrewrite I get a Java heap space error
I am trying to migrate from Spring Boot 2.7 to 3 using openrewrite.recipe:rewrite-spring:5.0.3
I am using Java 17 and running the plugin in the command line like this:
mvn -U org.openrewrite.maven:...
0
votes
1
answer
206
views
openRewrite: Unable to configure org.openrewrite.java.spring.framework.UpgradeSpringFrameworkDependencies
Getting below warning error while running UpgradeSpringBoot_3_0 recipe through maven command line.
mvn -U org.openrewrite.maven:rewrite-maven-plugin:dryRun -Drewrite.recipeArtifactCoordinates=org....
0
votes
0
answers
87
views
OpenRewrite: Add dependencies in Maven POM
I am trying to add a Spring cloud dependencies through OpenRewrite recipe:-
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-aws-starter</...
0
votes
1
answer
19
views
Facing Error while creating a custom recipe to add log level guard
I am trying to create a snippet using Java parser to add a if block.
Expression condition = JavaParser.buildSnippet(
String.format("if (logger.%sEnabled())", logLevel)
).get(0);
For ...
0
votes
1
answer
88
views
OpenRewrite: Can we have recipe to change Java or Spring library Import
Can we change import in java class, ex:
import org.springframework.security.oauth2.client.OAuth2RestTemplate;
to
import org.springframework.web.client.RestTemplate;
We have one ChangePackage recipe ...
0
votes
1
answer
144
views
OpenRewrite: recipes example for adding a new key: value pair in yaml
I want to append a new key: value pair in one of .yaml file as below:-
stages:
- template: myproject/scops-java-service-v1.yaml@codeway
parameters:
**newKey: newValue**
lintingParams:
...
3
votes
1
answer
303
views
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 <recipe>org.openrewrite.java.migrate.Java8toJava11</recipe>
When we execute the maven goal it fails with this error:
org.openrewrite.config....
0
votes
1
answer
88
views
Openrewrite systemouttologging recipe not working
https://docs.openrewrite.org/recipes/java/logging/systemouttologging
I am trying to apply the follwing recipe on a gradle project, but the recipe doesnt apply changes to my files.
Here is the build....
0
votes
1
answer
127
views
Openrewrite exclude class/method from replacing
I recently started using the openrewrite and wanted to know if there is any way we can exclude a class or method from replacing with a any recipe. I have some unit test that is specifically used to ...
2
votes
0
answers
404
views
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=...
1
vote
1
answer
50
views
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
...
-1
votes
1
answer
116
views
OpenRewrite: Enabling local Maven repository during JUnit testing of a recipe?
I wrote an OpenRewrite recipe which changes Maven pom.xml from containing this:
<dependency>
<groupId>a</groupId>
<artifactId>b</artifactId>
<version>1.0.0<...
2
votes
0
answers
459
views
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 ...
0
votes
1
answer
269
views
Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:5.2.1:run failed:
I encountered an error when trying to execute rewrite-maven-plugin version 5.2.1 on my project:
[ERROR] Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:5.2.1:run (default-cli) on ...
0
votes
1
answer
298
views
How can I fix the NoSuchMethodError while using the open-rewrite plugin for migrating Spring Boot 1.5.x to 2.7.x?
Error while trying to migrate srping boot 1.5.x to 2.7.x using open-rewrite
Using this plugin
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>...
0
votes
1
answer
284
views
Open Rewrite :Refactoring with declarative YAML recipes
I have been following the instructions Refactoring with declarative YAML recipes.
In my case project "A" is a multi-module maven build. I added a module "functional" that has an ...
0
votes
2
answers
196
views
OpenRewrite NullPointer while adding a maven dependency
I am running a recipe on Mac OS from the command line using rewrite plugin version 4.46.0
The project is a multi module maven.
mvn -U org.openrewrite.maven:rewrite-maven-plugin:run -e -Drewrite....
0
votes
1
answer
63
views
OpenRewrite: What is a "quark"?
When I run a recipe I see messages like this one:
Parsing as quark .../my_big_cucumber.feature as its size 12Mb exceeds size threshold 10Mb
What does this message mean? I also see the message for json ...
1
vote
2
answers
252
views
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
{
// ...
1
vote
1
answer
303
views
Write an Openrewrite java recipe test ignoring compilation errors
Is it possible to write an Openrewrite java recipe test ignoring compilation errors due to unknown class types not included in JavaParser classpath?
Example:
@Test
void requiredRequestParam() {...
0
votes
2
answers
1k
views
Error while running openrewrite UpgradeSpringBoot_3_0
I upgraded my repo to 2.7.1 using UpgradeSpringBoot_2_7 and project built successfully.
Now when i try to upgrade to SpringBoot 3.0.x , rewrite:run fails with error :
Unexpected EOF in prolog
at [row,...
1
vote
1
answer
77
views
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
...
2
votes
1
answer
367
views
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....
0
votes
1
answer
118
views
Is there any Recipe to move a file from one location to another?
for a smooth migration I'm looking for a recipe in Open-Rewrite to move a file (in that case a configuration File which always has the same name) from one location (for example C:\project\mymodule\...
0
votes
1
answer
176
views
OpenRewrite: The contents of a quark are unknown, so the charset is unknown
I want to execute the migration of my source code from Java8 to Jave11 using the OpenRewrite plugin and the recipe of the following link:https://docs.openrewrite.org/reference/recipes/java/migrate/...
0
votes
1
answer
54
views
Can OpenRewrite work with Ant/Ivy-based projects?
There are instructions for Gradle and Maven, but would this work with projects based on Ant and Ivy? If so, how? If not, is that something on the roadmap?