mvn rewrite:run
- Run the configured recipes and apply the changes locally.mvn rewrite:runNoFork
- Run the configured recipes and apply the changes locally. This variant does not fork the Maven life cycle and can be a more efficient choice when using Rewrite within a CI workflow when combined with other Maven goals.mvn rewrite:dryRun
- Generate warnings to the console for any recipe that would make changes and generates a diff file in each maven modules' target
folder.mvn rewrite:dryRunNoFork
- Generate warnings to the console for any recipe that would make changes and generates a diff file in each maven modules' target
folder. This variant does not fork the Maven life cycle and can be a more efficient choice when using Rewrite within a CI workflow when combined with other Maven goals.mvn rewrite:discover
- Generate a report of available recipes found on the classpath.mvn rewrite:cyclonedx
- Generate a CycloneDx bill of materials outlining the project's dependencies, including transitive dependencies.rewrite
name-spaced properties can be used for substituting plugin properties-Drewrite.activeRecipes=org.example.R1, org.example.R2
-Drewrite.activeStyles=org.example.Style
-Drewrite.recipeArtifactCoordinates=org.example:your-recipe:1.0
rewrite:run
and rewrite:dryRun
are configured to fork Maven's life cycle and are a better choice when running recipes via a stand-alone goal (mvn rewrite:run
) because this will trigger all the necessary life-cycle goals prior to running rewrite's plugin. However, when using rewrite within the context of an integration build (mvn deploy rewrite:run
) it may be more efficient to use the non-forking variants, as these will not cause duplicate life cycle phases to be called.NoPluginFoundForPrefixException
. The root cause for this varies from pom.xml to pom.xml. In any case, as a quick fix to get unstuck, try referencing the fully-qualified rewrite-maven-plugin coordinates instead of the shorthand prefix. That is, try using mvn org.openrewrite.maven:rewrite-maven-plugin:GOAL
(such as mvn org.openrewrite.maven:rewrite-maven-plugin:run
, etc.) rather than mvn rewrite:GOAL
.activeRecipes
- Explicitly turns on recipes by name (the name given in the specs.openrewrite.org/v1beta/recipe
resource). No recipe is run unless explicitly turned on with this setting. You can set activeRecipes
ad-hoc directly on the command-line using -Drewrite.activeRecipes=an.example.Recipe0,an.example.Recipe1
. For example, ./mvnw rewrite:run -Drewrite.activeRecipes=an.example.Recipe0
.activeStyles
- Explicitly turns on a style by name (the name given in the specs.openrewrite.org/v1beta/style
resource). No style is applied unless explicitly turned on with this setting. This can be invoked ad-hoc directly on the command-line using -Drewrite.activeStyles=an.example.Style0,an.example.Style1
. For example, ./mvnw rewrite:run -Drewrite.activeStyles=an.example.Style0
.configLocation
- Where to look for an OpenRewrite YML configuration file somewhere in the project directory (or really anywhere on disk). If you want to customize this, prefixing the file name with the Maven property ${maven.multiModuleProjectDirectory}
is a handy way of ensuring that each module resolves the same configuration file relative to the root directory of the repository. This configLocation
is (unless an absolute path is given) evaluated for each module relative to that module's project directory.dependencies
- To make pre-packaged OpenRewrite recipes available to the Maven plugin, add them as plugin dependencies.failOnDryRunResults
- Boolean flag toggling whether rewrite:dryRun
should throw an exception and non-zero exit code if changes are detected. Default is false
.exclusions
- Skips parsing for any paths matching these exclusions. Evaluated as a PathMatcher glob pattern, where "**" matches any number of directories and "*" matches a single directory or filename.pomCacheDirectory
- The directory where OpenRewrite will cache pom.xml and meta-data. The default value is ~/.rewrite-cache
pomCacheEnabled
- This flag determines if OpenRewrite will cache pom.xml and meta-data using an on-disk cache. The default is true
sizeThresholdMb
- Threshold over which non-Java sources are ignored during parsing. The default threshold is 10Mb.skipMavenParsing
- When enabled, skip parsing Maven pom.xml
s, and any transitive poms, as source files. This can be an efficiency improvement in certain situations. Default is false
. For example, -DskipMavenParsing=true
.compile
, provided
, and test
scopes for visitors, recipes, and styles and will automatically discover recipes on the project classpath.rewrite:discover
goal.mvn rewrite:run
to run the active recipes and apply the changes. This will write changes locally to your source files on disk. Afterward, review the changes, and when you are comfortable with the changes, commit them. The run
goal generates warnings in the build log wherever it makes changes to source files.git diff
to see what changes were made, review, and commit them.mvn rewrite:dryRun
to dry-run the active recipes and print which visitors would make changes to which files to the build log. This does not alter your source files at all. This goal can be used to preview the changes that would be made by a recipe.rewrite:dryRun
outputs a report in the form of a patch
file, by default under target/site/rewrite/rewrite.patch
, containing changes that would be made if you were to run rewrite:run
. This file can be used with git
or diff
to view or apply the potential changes. For example, git diff . target/site/rewrite/rewrite.patch
.dryRun
can be used as a "gate" in a continuous integration environment by failing the build if dryRun
detects changes to be made and failOnDryRunResults
is set to true
:dryRun
can be configured to bind dryRun
to desired maven phases. For example, the following configuration is sufficient to have mvn verify
also run rewrite:dryRun
:mvn rewrite:discover
to list the recipes that the OpenRewrite Maven plugin has found on your classpath and the recipes that you have activated in your plugin configuration.rewrite:cyclonedx
to generate a CycloneDx bill of materials (BOM) outlining all of the project's dependencies, including transitive dependencies. The BOM will be written to target/<module name>-<version>-cyclonedx.xml.~/.rewrite-cache
. RocksDB is a high-performance, embedded database that is maintained by Facebook. The database engine is written in C++ and is used by the plugin via a JNI wrapper that has no transitive dependencies.~/.rewrite-cache
) and you can choose an alternate location by using the plugin's pomCacheDirectory
configuration property.pomCacheEnabled
can be set to false
in which case the plugin will use an in-memory cache instead. This will make running recipes slower when a project had deep dependency trees.