RewriteRunner
Programmatic entry point for running OpenRewrite recipes from library code.
Encapsulates the same orchestration pipeline that the CLI uses:
Try the official Gradle/Maven OpenRewrite plugin via PluginRecipeRunner.
Load ToolConfig (from Builder.configFile if supplied, otherwise defaults).
Resolve recipe JARs from Maven coordinates via RecipeArtifactResolver.
Load the requested recipe via RecipeLoader.
Build the Lossless Semantic Tree (LST) for the project via LstBuilder.
Execute the recipe via RecipeRunner.
Optionally write changed files to disk (controlled by Builder.dryRun).
Obtain an instance through the Builder:
val runner = RewriteRunner.builder()
.projectDir(Paths.get("/path/to/project"))
.activeRecipe("org.openrewrite.java.format.AutoFormat")
.build()
val result = runner.run()Java usage:
RunResult result = RewriteRunner.builder()
.projectDir(Paths.get("/path/to/project"))
.activeRecipe("org.openrewrite.java.format.AutoFormat")
.build()
.run();This class is thread-safe for concurrent run calls only when each call operates on a different Builder.projectDir. Sharing the same project directory across concurrent runs is not supported.
Diagnostics — including per-file parse failures from every parser the LST pipeline ran — are exposed on RunResult.executionDiagnostics. Inspect ExecutionDiagnostics.parseFailures to see which files OpenRewrite could not handle; the build does not abort on per-file failures, so the recipe still runs against whatever was successfully parsed.