Running Rewrite on a Maven project without modifying the build
In this tutorial, we will apply a Rewrite recipe to a source code repository built with Maven without modifying the build itself. The instructions for this differ slightly depending on whether or not the recipe has configuration parameters. Please note that you will need to have Maven installed in order to run the shell commands.
Running a recipe without configuration parameters
If the recipe you're trying to run does not have any required configuration parameters, then you can run the recipe by executing a shell command.
Our recipe documentation includes the specific shell commands to run for any recipe without configuration parameters. You may find it easier to copy and run the provided command instead of manually creating it.
If the recipe comes from the core Rewrite library (such as with Remove Unused Imports) then you can run the following command and replace org.openrewrite.java.RemoveUnusedImports with the path to the recipe you're wanting to run:
If the recipe comes from a different library (such as with Migrate to Jakarta EE 9) then you can run the following command and replace org.openrewrite.recipe:rewrite-migrate-java:LATEST with the artifact coordinates of your recipe and org.openrewrite.java.migrate.jakarta.JavaxMigrationToJakarta with the path to the recipe you're wanting to run: