spring-projects / spring-rewrite-commons

Apache License 2.0
9 stars 11 forks source link

Add Maven launcher using Maven Invoker #71

Closed fabapp2 closed 8 months ago

fabapp2 commented 8 months ago

Add a new MavenInvocationRewriteRecipeLauncher to run OpenRewrite recipes using Maven Invoker.

InvocationResult result = MavenInvocationRewriteRecipeLauncher
            .applyRecipes(
                             "org.openrewrite.java.RemoveUnusedImports", 
                             "org.openrewrite.java.format.AutoFormat"
                         )
            .onDir(baseDir)
            .withBuildConfig(
                             BuildConfig.builder()
                                .skipTests(true)
                                .withMemory("64M", "256M")
                                .build()
                         )
            .withOutputListener(line -> handleLine(line)
            .dryRun();