Closed jdelobel closed 1 year ago
Hi @jdelobel ; You'll want to upgrade your rewrite modules to https://github.com/openrewrite/rewrite-testing-frameworks/releases/tag/v2.0.4 https://github.com/openrewrite/rewrite-migrate-java/releases/tag/v2.0.4
These specifically fix the NoSuchMethodError: org.openrewrite.java.MethodMatcher.matches(Lorg/openrewrite/java/tree/J$MethodInvocation;)
you've reported, either directly, or through their transitive dependencies.
You could also use https://github.com/openrewrite/rewrite-recipe-bom/releases/tag/v2.0.5 in com.my.org:springboot-migration
to transitively supply those new versions of rewrite-migrate-java
and rewrite-testing-frameworks
, such that you only ever have to update the BOM for future changes.
Hope that helps! I'll proactively close this issue since we've seen a few similar reports over the past couple days. Let me know if the above does not work for you!
Hi @timtebeek,
Thanks. With this new version, the process end with success! But my recipe which use FindAndReplace
recipe does not generates the expected result.
FYI, i want to replace some content in a file that contains template semantic like ${}
Moreover, the unit tests on this template work and generate the expected result with the previous open-rewrite version (but not with the new :)).
We can found this stack in debug mode:
[DEBUG]
java.lang.IllegalArgumentException: named capturing group is missing trailing '}'
at java.util.regex.Matcher.appendReplacement (Matcher.java:841)
at java.util.regex.Matcher.replaceAll (Matcher.java:955)
at org.openrewrite.text.FindAndReplace$1.visit (FindAndReplace.java:139)
at org.openrewrite.text.FindAndReplace$1.visit (FindAndReplace.java:108)
at com.my.org.deployment.AddJenkinsSpringBootDeployment$2.visit (AddJenkinsSpringBootDeployment.java:131)
at com.myorg.AddJenkinsSpringBootDeployment$2.visit (AddJenkinsSpringBootDeployment.java:110)
at org.openrewrite.TreeVisitor.visit (TreeVisitor.java:184)
at org.openrewrite.ScanningRecipe$1.visit (ScanningRecipe.java:112)
at org.openrewrite.ScanningRecipe$1.visit (ScanningRecipe.java:94)
at org.openrewrite.RecipeScheduler$RecipeRunCycle.lambda$editSources$3 (RecipeScheduler.java:231)
at io.micrometer.core.instrument.AbstractTimer.recordCallable (AbstractTimer.java:175)
at org.openrewrite.table.RecipeRunStats.recordEdit (RecipeRunStats.java:56)
at org.openrewrite.RecipeScheduler$RecipeRunCycle.lambda$editSources$4 (RecipeScheduler.java:228)
at org.openrewrite.RecipeScheduler$RecipeRunCycle.lambda$mapForRecipeRecursively$5 (RecipeScheduler.java:330)
at org.openrewrite.internal.InMemoryLargeSourceSet.lambda$edit$0 (InMemoryLargeSourceSet.java:61)
at org.openrewrite.internal.ListUtils.map (ListUtils.java:176)
at org.openrewrite.internal.InMemoryLargeSourceSet.edit (InMemoryLargeSourceSet.java:60)
at org.openrewrite.RecipeScheduler$RecipeRunCycle.mapForRecipeRecursively (RecipeScheduler.java:323)
at org.openrewrite.RecipeScheduler$RecipeRunCycle.editSources (RecipeScheduler.java:201)
at org.openrewrite.RecipeScheduler.scheduleRun (RecipeScheduler.java:76)
at org.openrewrite.Recipe.run (Recipe.java:284)
at org.openrewrite.Recipe.run (Recipe.java:280)
at org.openrewrite.Recipe.run (Recipe.java:276)
at org.openrewrite.maven.AbstractRewriteMojo.runRecipe (AbstractRewriteMojo.java:253)
at org.openrewrite.maven.AbstractRewriteMojo.listResults (AbstractRewriteMojo.java:230)
at org.openrewrite.maven.AbstractRewriteRunMojo.execute (AbstractRewriteRunMojo.java:55)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:301)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:211)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:165)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:157)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:121)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:127)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Looks like it's failing on the final line here https://github.com/openrewrite/rewrite/blob/e315f935c007212ecb85b39b9a310b0a5dd0fea8/rewrite-core/src/main/java/org/openrewrite/text/FindAndReplace.java#L133-L139
That'll depend on the arguments you pass into FindAndReplace
; I suspect an issue with the find
argument which you might want to double check, or very against the handling in FindAndReplace
.
That'll depend on the arguments you pass into
FindAndReplace
; I suspect an issue with thefind
argument which you might want to double check, or very against the handling inFindAndReplace
.
The regexp feature added in FindAndReplace
fails if the text content contains any regexp syntax (like ${}
)
So I will dont use this recipe but i will use directly:
...
PlainText propertiesFileToPLainText = PlainTextParser.convert(sourceFile);
return propertiesFileToPLainText.withText(finalContent);
That'll depend on the arguments you pass into
FindAndReplace
; I suspect an issue with thefind
argument which you might want to double check, or very against the handling inFindAndReplace
.The regexp feature added in
FindAndReplace
fails if the text content contains any regexp syntax (like${}
)
Hmm ; not sure what exactly is failing you here, could you provide an example perhaps phrased as a unit test? https://github.com/openrewrite/rewrite/blob/a5bbc9fee363762a29a7f074ccc3c7b35781b6b4/rewrite-core/src/test/java/org/openrewrite/text/FindAndReplaceTest.java#L59-L86
That'll depend on the arguments you pass into
FindAndReplace
; I suspect an issue with thefind
argument which you might want to double check, or very against the handling inFindAndReplace
.The regexp feature added in
FindAndReplace
fails if the text content contains any regexp syntax (like${}
)Hmm ; not sure what exactly is failing you here, could you provide an example perhaps phrased as a unit test?
There is the failling test:
class FindAndReplaceTest implements RewriteTest {
@DocumentExample
@Test
void testTemplateSyntaxIncontentShouldNotFails() {
rewriteRun(
spec -> spec.recipe(new FindAndReplace("This is text ${dynamic}.", "This is text ${dynamic}. Stuff", null, null, null, null, null)).cycles(1),
text(
"""
This is text ${dynamic}.
""",
"""
This is text ${dynamic}. Stuff
""",
spec -> spec.path("test.yml")
)
);
}
}
and the stack
Caused by: java.lang.IllegalArgumentException: No group with name {dynamic}
at org.openrewrite.text.FindAndReplace$1.visit(FindAndReplace.java:139)
at org.openrewrite.text.FindAndReplace$1.visit(FindAndReplace.java:108)
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:184)
at org.openrewrite.RecipeScheduler$RecipeRunCycle.lambda$editSources$3(RecipeScheduler.java:231)
at io.micrometer.core.instrument.AbstractTimer.recordCallable(AbstractTimer.java:147)
at org.openrewrite.table.RecipeRunStats.recordEdit(RecipeRunStats.java:56)
at org.openrewrite.RecipeScheduler$RecipeRunCycle.lambda$editSources$4(RecipeScheduler.java:228)
... 11 more
Sorry i cant do PR because my company block all push on github
The above issue has been resolved in
What version of OpenRewrite are you using?
I am using
How are you running OpenRewrite?
I am using the Maven plugin, and my project is a single module project.
What is the smallest, simplest way to reproduce the problem?
I dont know. I have a lot of recipe.
What is the full stack trace of any errors you encountered?
I think this error is due to https://github.com/openrewrite/rewrite-migrate-java/blob/927b01de8e8fd8f1ab68bc934a860043e0eba441/src/main/resources/META-INF/rewrite/java-version-11.yml#L39 (i use this yaml in my project and apparently
BigDecimalRoundingConstantsToEnums
no longer exists).Are you interested in contributing a fix to OpenRewrite