Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable failOnDryRunResults #163

Merged
merged 3 commits into from
May 6, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/main/java/org/openrewrite/maven/RewriteDryRunMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ public class RewriteDryRunMojo extends AbstractRewriteMojo {
@Parameter(property = "reportOutputDirectory", defaultValue = "${project.reporting.outputDirectory}/rewrite")
private File reportOutputDirectory;

/**
* Whether to throw an exception if there are any result changes produced.
*/
@Parameter(property = "failOnDryRunResults", defaultValue = "false")
private boolean failOnDryRunResults;

@Override
public void execute() throws MojoExecutionException {
ResultsContainer results = listResults();
Expand Down Expand Up @@ -96,6 +102,10 @@ public void execute() throws MojoExecutionException {
getLog().warn("Report available:");
getLog().warn(indent(1, patchFile.normalize().toString()));
getLog().warn("Run 'mvn rewrite:run' to apply the recipes.");

if (failOnDryRunResults) {
throw new MojoExecutionException("Result changes detected. Please see result file for more information.");
aegershman marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
}