OpenRewriteRecipe transform allows to apply any Open Rewrite Recipe to a set of files and gather the results.
NOTE: At the time of writing, only Java related recipes are supported. The engine leverages version
7.0.0 of Open Rewrite and parses java files using the grammar for Java 11.
type: OpenRewriteRecipe recipe: <string> # Full qualified classname of the recipe options: <string>: <SpEL expression> # Keys and values depend on the class of the recipe <string>: <SpEL expression> # Refer to the documentation of said recipe ...
Let's apply the ChangePackage Recipe to a set of java files in the
com.acme package and move them to the value of
#companyPkg. This is way more powerful than using RewritePath and ReplaceText, as it understands the syntax of files and will correctly deal with imports, fully vs non-fully qualified names, etc.
chain: - include: ["**/*.java"] - type: OpenRewriteRecipe recipe: org.openrewrite.java.ChangePackage options: oldFullyQualifiedPackageName: "'com.acme'" newFullyQualifiedPackageName: "#companyPkg" recursive: true