openrewrite / rewrite

Automated mass refactoring of source code.
https://docs.openrewrite.org
Apache License 2.0
2.03k stars 300 forks source link

[Rewrite8 migration][ERROR] java.lang.NoSuchMethodError: org.openrewrite.java.MethodMatcher.matches(...) #3377

Closed jdelobel closed 1 year ago

jdelobel commented 1 year ago

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.

  <plugin>
                <groupId>org.openrewrite.maven</groupId>
                <artifactId>rewrite-maven-plugin</artifactId>
                <version>5.2.4</version>
                <configuration>
                    <activeRecipes>
                        [all my custom recipe]
                    </activeRecipes>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.openrewrite.recipe</groupId>
                        <artifactId>rewrite-migrate-java</artifactId>
                        <version>2.0.2</version>
                    </dependency>
                    <dependency>
                        <groupId>org.openrewrite.recipe</groupId>
                        <artifactId>rewrite-testing-frameworks</artifactId>
                        <version>2.0.2</version>
                    </dependency>
                    <dependency>
                        <groupId>com.my.org</groupId>
                        <artifactId>springboot-migration</artifactId>
                        <version>1.0.0-SNAPSHOT</version>
                    </dependency>
                </dependencies>
            </plugin>

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?

[ERROR] The recipe produced an error. Please report this to the recipe author.                                                                                                                                                                
[INFO] ------------------------------------------------------------------------                                                                                                                                                               
[INFO] Reactor Summary for modules pom 5.9.6-SNAPSHOT:                                                                                                                                                                                        
[INFO]                                                                                                                                                                                                                                        
[INFO] modules pom ........................................ SUCCESS [ 15.308 s]                                                                                                                                                               
[INFO] conf ............................................... SUCCESS [  1.308 s]                                                                                                                                                               
[INFO] wsserver ........................................... SUCCESS [02:09 min]                                                                                                                                                               
[INFO] batch .............................................. FAILURE [16:58 min]                                                                                                                                                               
[INFO] ------------------------------------------------------------------------                                                                                                                                                               
[INFO] BUILD FAILURE                                                                                                                                                                                                                          
[INFO] ------------------------------------------------------------------------                                                                                                                                                               
[INFO] Total time:  19:25 min                                                                                                                                                                                                                 
[INFO] Finished at: 2023-06-30T02:31:30+02:00                                                                                                                                                                                                 
[INFO] ------------------------------------------------------------------------                                                                                                                                                               
[ERROR] Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:5.2.4:run (default-cli) on project my_project: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:5.2.4:run failed: Error while v
isiting modules\wsserver\src\main\java\myorg\MyOrgClass.java: java.lang.NoSuchMethodError: org.openrewrite.java.MethodMatcher.matches(Lorg/openrewrite/java/tree/J$MethodInvocation;)
Z                                                                                                                                                                                                                                             
[ERROR]   org.openrewrite.staticanalysis.BigDecimalRoundingConstantsToEnums$1.visitMethodInvocation(BigDecimalRoundingConstantsToEnums.java:80)                                                                                               
[ERROR]   org.openrewrite.staticanalysis.BigDecimalRoundingConstantsToEnums$1.visitMethodInvocation(BigDecimalRoundingConstantsToEnums.java:62)                                                                                               
[ERROR]   org.openrewrite.java.tree.J$MethodInvocation.acceptJava(J.java:3706)                                                                                                                                                                
[ERROR]   org.openrewrite.java.tree.J.accept(J.java:59)                                                                                                                                                                                       
[ERROR]   org.openrewrite.TreeVisitor.visit(TreeVisitor.java:278)                                                                                                                                                                             
[ERROR]   org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:361)                                                                                                                                                                      
[ERROR]   org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1284)                                                                                                                                                            
[ERROR]   org.openrewrite.java.JavaVisitor.visitMethodInvocation(JavaVisitor.java:849)                                                                                                                                                        
[ERROR]   ...                                                                                                                                                                                                                                 
[ERROR] -> [Help 1]                                                                                                                                                                                                                           
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:5.2.4:run (default-cli) on project my_project: Execution default-cli of goal org.openrewrite.maven:rewr
ite-maven-plugin:5.2.4:run failed: Error while visiting modules\wsserver\src\main\java\myorg\MyOrgClass.java: java.lang.NoSuchMethodError: org.openrewrite.java.MethodMatcher.matches
(Lorg/openrewrite/java/tree/J$MethodInvocation;)Z                                                                                                                                                                                             
  org.openrewrite.staticanalysis.BigDecimalRoundingConstantsToEnums$1.visitMethodInvocation(BigDecimalRoundingConstantsToEnums.java:80)                                                                                                       
  org.openrewrite.staticanalysis.BigDecimalRoundingConstantsToEnums$1.visitMethodInvocation(BigDecimalRoundingConstantsToEnums.java:62)                                                                                                       
  org.openrewrite.java.tree.J$MethodInvocation.acceptJava(J.java:3706)                                                                                                                                                                        
  org.openrewrite.java.tree.J.accept(J.java:59)                                                                                                                                                                                               
  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:278)                                                                                                                                                                                     
  org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:361)                                                                                                                                                                              
  org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1284)                                                                                                                                                                    
  org.openrewrite.java.JavaVisitor.visitMethodInvocation(JavaVisitor.java:849)                                                                                                                                                                
  ...                                                                                                                                                                                                                                         
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:306)                                                                                                                                                     
    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)                                                                                                                                                             
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:5.2.4:run failed: Error while visiting modules\wsserver\src\main\java\com\myorg\MyOrgClass.java: java.lang.NoSuchMethodError: org.openrewrite.java.MethodMatcher.matches(Lorg/openrewrite/java/tree/J$MethodInvocation;)Z                                                                        
  org.openrewrite.staticanalysis.BigDecimalRoundingConstantsToEnums$1.visitMethodInvocation(BigDecimalRoundingConstantsToEnums.java:80)                                                                                                       
  org.openrewrite.staticanalysis.BigDecimalRoundingConstantsToEnums$1.visitMethodInvocation(BigDecimalRoundingConstantsToEnums.java:62)                                                                                                       
  org.openrewrite.java.tree.J$MethodInvocation.acceptJava(J.java:3706)                                                                                                                                                                        
  org.openrewrite.java.tree.J.accept(J.java:59)                                                                                                                                                                                               
  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:278)                                                                                                                                                                                     
  org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:361)                                                                                                                                                                              
  org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1284)                                                                                                                                                                    
  org.openrewrite.java.JavaVisitor.visitMethodInvocation(JavaVisitor.java:849)                                                                                                                                                                
  ...                                                                                                                                                                                                                                         
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)                                                                                                                                     
    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)                                                                                                                                                             
Caused by: java.lang.RuntimeException: Error while visiting modules\wsserver\src\main\java\myorg\MyOrgClass.java: java.lang.NoSuchMethodError: org.openrewrite.java.MethodMatcher.mat
ches(Lorg/openrewrite/java/tree/J$MethodInvocation;)Z                                                                                                                                                                                         
  org.openrewrite.staticanalysis.BigDecimalRoundingConstantsToEnums$1.visitMethodInvocation(BigDecimalRoundingConstantsToEnums.java:80)                                                                                                       
  org.openrewrite.staticanalysis.BigDecimalRoundingConstantsToEnums$1.visitMethodInvocation(BigDecimalRoundingConstantsToEnums.java:62)                                                                                                       
  org.openrewrite.java.tree.J$MethodInvocation.acceptJava(J.java:3706)                                                                                                                                                                        
  org.openrewrite.java.tree.J.accept(J.java:59)                                                                                                                                                                                               
  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:278)                                                                                                                                                                                     
  org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:361)                                                                                                                                                                              
  org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1284)                                                                                                                                                                    
  org.openrewrite.java.JavaVisitor.visitMethodInvocation(JavaVisitor.java:849)                                                                                                                                                                
  ...                                                                                                                                                                                                                                         
    at org.openrewrite.maven.AbstractRewriteMojo$ResultsContainer$1.lambda$preVisit$0 (AbstractRewriteMojo.java:406)                                                                                                                          
    at java.util.Optional.ifPresent (Optional.java:159)                                                                                                                                                                                       
    at org.openrewrite.maven.AbstractRewriteMojo$ResultsContainer$1.preVisit (AbstractRewriteMojo.java:403)                                                                                                                                   
    at org.openrewrite.maven.AbstractRewriteMojo$ResultsContainer$1.preVisit (AbstractRewriteMojo.java:399)                                                                                                                                   
    at org.openrewrite.maven.AbstractRewriteMojo_ResultsContainer_1_JavaVisitor.preVisit (AbstractRewriteMojo_ResultsContainer_1_JavaVisitor.zig:102)                                                                                         
    at org.openrewrite.TreeVisitor.visit (TreeVisitor.java:275)                                                                                                                                                                               
    at org.openrewrite.TreeVisitor.visitAndCast (TreeVisitor.java:361)                                                                                                                                                                        
    at org.openrewrite.java.JavaVisitor.visitRightPadded (JavaVisitor.java:1284)                                                                                                                                                              
    at org.openrewrite.java.JavaVisitor.visitMethodInvocation (JavaVisitor.java:849)                                                                                                                                                          
    at org.openrewrite.java.tree.J$MethodInvocation.acceptJava (J.java:3706)                                                                                                                                                                  
    at org.openrewrite.java.tree.J.accept (J.java:59)                                                                                                                                                                                         
    at org.openrewrite.TreeVisitor.visit (TreeVisitor.java:278)                                                                                                                                                                               
    at org.openrewrite.TreeVisitor.visitAndCast (TreeVisitor.java:361)                                                                                                                                                                        
    at org.openrewrite.java.JavaVisitor.visitRightPadded (JavaVisitor.java:1284)                                                                                                                                                              
    at org.openrewrite.java.JavaVisitor.lambda$visitContainer$33 (JavaVisitor.java:1337)                                                                                                                                                      
    at org.openrewrite.internal.ListUtils.map (ListUtils.java:176)                                                                                                                                                                            
    at org.openrewrite.java.JavaVisitor.visitContainer (JavaVisitor.java:1337)                                                                                                                                                                
    at org.openrewrite.java.JavaVisitor.visitNewClass (JavaVisitor.java:943)                                                                                                                                                                  
    at org.openrewrite.java.tree.J$NewClass.acceptJava (J.java:4195)                                                                                                                                                                          
    at org.openrewrite.java.tree.J.accept (J.java:59)                                                                                                                                                                                         
    at org.openrewrite.TreeVisitor.visit (TreeVisitor.java:278)                                                                                                                                                                               
    at org.openrewrite.TreeVisitor.visitAndCast (TreeVisitor.java:361)                                                                                                                                                                        
    at org.openrewrite.java.JavaVisitor.visitRightPadded (JavaVisitor.java:1284)                                                                                                                                                              
    at org.openrewrite.java.JavaVisitor.lambda$visitContainer$33 (JavaVisitor.java:1337)                                                                                                                                                      
    at org.openrewrite.internal.ListUtils.map (ListUtils.java:176)                                                                                                                                                                            
    at org.openrewrite.java.JavaVisitor.visitContainer (JavaVisitor.java:1337)                                                                                                                                                                
    at org.openrewrite.java.JavaVisitor.visitNewClass (JavaVisitor.java:943)                                                                                                                                                                  
    at org.openrewrite.java.tree.J$NewClass.acceptJava (J.java:4195)                                                                                                                                                                          
    at org.openrewrite.java.tree.J.accept (J.java:59)                                                                                                                                                                                         
    at org.openrewrite.TreeVisitor.visit (TreeVisitor.java:278)                                                                                                                                                                               
    at org.openrewrite.TreeVisitor.visitAndCast (TreeVisitor.java:361)                                                                                                                                                                        
    at org.openrewrite.java.JavaVisitor.visitLeftPadded (JavaVisitor.java:1312)                                                                                                                                                               
    at org.openrewrite.java.JavaVisitor.visitVariable (JavaVisitor.java:1212)                                                                                                                                                                 
    at org.openrewrite.java.tree.J$VariableDeclarations$NamedVariable.acceptJava (J.java:5582)                                                                                                                                                
    at org.openrewrite.java.tree.J.accept (J.java:59)                                                                                                                                                                                         
    at org.openrewrite.TreeVisitor.visit (TreeVisitor.java:278)                                                                                                                                                                               
    at org.openrewrite.TreeVisitor.visitAndCast (TreeVisitor.java:361)                                                                                                                                                                        
    at org.openrewrite.java.JavaVisitor.visitRightPadded (JavaVisitor.java:1284)                                                                                                                                                              
    at org.openrewrite.java.JavaVisitor.lambda$visitVariableDeclarations$27 (JavaVisitor.java:895)                                                                                                                                            
    at org.openrewrite.internal.ListUtils.map (ListUtils.java:176)                                                                                                                                                                            
    at org.openrewrite.java.JavaVisitor.visitVariableDeclarations (JavaVisitor.java:895)                                                                                                                                                      
    at org.openrewrite.java.tree.J$VariableDeclarations.acceptJava (J.java:5472)                                                                                                                                                              
    at org.openrewrite.java.tree.J.accept (J.java:59)                                                                                                                                                                                         
    at org.openrewrite.TreeVisitor.visit (TreeVisitor.java:278)                                                                                                                                                                               
    at org.openrewrite.TreeVisitor.visitAndCast (TreeVisitor.java:361)                                                                                                                                                                        
    at org.openrewrite.java.JavaVisitor.visitRightPadded (JavaVisitor.java:1284)                                                                                                                                                              
    at org.openrewrite.java.JavaVisitor.lambda$visitBlock$4 (JavaVisitor.java:367)                                                                                                                                                            
    at org.openrewrite.internal.ListUtils.map (ListUtils.java:176)                                                                                                                                                                            
    at org.openrewrite.java.JavaVisitor.visitBlock (JavaVisitor.java:366)                                                                                                                                                                     
    at org.openrewrite.java.tree.J$Block.acceptJava (J.java:767)                                                                                                                                                                              
    at org.openrewrite.java.tree.J.accept (J.java:59)                                                                                                                                                                                         
    at org.openrewrite.TreeVisitor.visit (TreeVisitor.java:278)                                                                                                                                                                               
    at org.openrewrite.TreeVisitor.visitAndCast (TreeVisitor.java:361)                                                                                                                                                                        
    at org.openrewrite.java.JavaVisitor.visitMethodDeclaration (JavaVisitor.java:817)                                                                                                                                                         
    at org.openrewrite.java.tree.J$MethodDeclaration.acceptJava (J.java:3448)                                                                                                                                                                 
    at org.openrewrite.java.tree.J.accept (J.java:59)                                                                                                                                                                                         
    at org.openrewrite.TreeVisitor.visit (TreeVisitor.java:278)                                                                                                                                                                               
    at org.openrewrite.TreeVisitor.visitAndCast (TreeVisitor.java:361)                                                                                                                                                                        
    at org.openrewrite.java.JavaVisitor.visitRightPadded (JavaVisitor.java:1284)                                                                                                                                                              
    at org.openrewrite.java.JavaVisitor.lambda$visitBlock$4 (JavaVisitor.java:367)                                                                                                                                                            
    at org.openrewrite.internal.ListUtils.map (ListUtils.java:176)                                                                                                                                                                            
    at org.openrewrite.java.JavaVisitor.visitBlock (JavaVisitor.java:366)                                                                                                                                                                     
    at org.openrewrite.java.tree.J$Block.acceptJava (J.java:767)                                                                                                                                                                              
    at org.openrewrite.java.tree.J.accept (J.java:59)                                                                                                                                                                                         
    at org.openrewrite.TreeVisitor.visit (TreeVisitor.java:278)                                                                                                                                                                               
    at org.openrewrite.TreeVisitor.visitAndCast (TreeVisitor.java:361)                                                                                                                                                                        
    at org.openrewrite.java.JavaVisitor.visitClassDeclaration (JavaVisitor.java:454)                                                                                                                                                          
    at org.openrewrite.java.tree.J$ClassDeclaration.acceptJava (J.java:1217)                                                                                                                                                                  
    at org.openrewrite.java.tree.J.accept (J.java:59)                                                                                                                                                                                         
    at org.openrewrite.TreeVisitor.visit (TreeVisitor.java:278)                                                                                                                                                                               
    at org.openrewrite.TreeVisitor.visitAndCast (TreeVisitor.java:361)                                                                                                                                                                        
    at org.openrewrite.java.JavaVisitor.lambda$visitCompilationUnit$10 (JavaVisitor.java:467)                                                                                                                                                 
    at org.openrewrite.internal.ListUtils.map (ListUtils.java:176)                                                                                                                                                                            
    at org.openrewrite.java.JavaVisitor.visitCompilationUnit (JavaVisitor.java:467)                                                                                                                                                           
    at org.openrewrite.java.tree.J$CompilationUnit.acceptJava (J.java:1520)                                                                                                                                                                   
    at org.openrewrite.java.tree.J.accept (J.java:59)                                                                                                                                                                                         
    at org.openrewrite.TreeVisitor.visit (TreeVisitor.java:278)                                                                                                                                                                               
    at org.openrewrite.maven.AbstractRewriteMojo$ResultsContainer.getRecipeErrors (AbstractRewriteMojo.java:410)                                                                                                                              
    at org.openrewrite.maven.AbstractRewriteMojo$ResultsContainer.getFirstException (AbstractRewriteMojo.java:390)                                                                                                                            
    at org.openrewrite.maven.AbstractRewriteRunMojo.execute (AbstractRewriteRunMojo.java:56)                                                                                                                                                  
    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)                                                                                                                                                             
[ERROR]                                                                                                                                                                                                                                       
[ERROR]                                                                                                                                                                                                                                       
[ERROR] For more information about the errors and possible solutions, please read the following articles:                                                                                                                                     
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException                                                                                                                                                    
[ERROR]                                                                                                                                                                                                                                       
[ERROR] After correcting the problems, you can resume the build with the command                                                                                                                                                              

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

timtebeek commented 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!

jdelobel commented 1 year ago

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)
timtebeek commented 1 year ago

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.

jdelobel commented 1 year ago

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.

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);
timtebeek commented 1 year ago

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.

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

jdelobel commented 1 year ago

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.

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

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

timtebeek commented 8 months ago

The above issue has been resolved in