Skip to content

Commit 59404e5

Browse files
committed
Declare to throw MojoExecutionException & MojoFailureException
1 parent fa57b83 commit 59404e5

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

src/main/java/org/openrewrite/maven/AbstractRewriteBaseRunMojo.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import io.micrometer.core.instrument.Metrics;
1919
import org.apache.maven.artifact.DependencyResolutionRequiredException;
2020
import org.apache.maven.plugin.MojoExecutionException;
21+
import org.apache.maven.plugin.MojoFailureException;
2122
import org.apache.maven.plugins.annotations.Parameter;
2223
import org.codehaus.plexus.classworlds.realm.ClassRealm;
2324
import org.jspecify.annotations.Nullable;
@@ -102,7 +103,7 @@ protected Path repositoryRoot() {
102103
return maybeBaseDir;
103104
}
104105

105-
protected ResultsContainer listResults(ExecutionContext ctx) throws MojoExecutionException {
106+
protected ResultsContainer listResults(ExecutionContext ctx) throws MojoExecutionException, MojoFailureException {
106107
try (MeterRegistryProvider meterRegistryProvider = new MeterRegistryProvider(getLog(),
107108
metricsUri, metricsUsername, metricsPassword)) {
108109
Metrics.addRegistry(meterRegistryProvider.registry());
@@ -226,7 +227,7 @@ private static void updateOption(Recipe recipe, Field field, @Nullable String op
226227
String.format("Unable to convert option: %s value: %s to type: %s", name, optionValue, type));
227228
}
228229

229-
protected LargeSourceSet loadSourceSet(Path repositoryRoot, Environment env, ExecutionContext ctx) throws DependencyResolutionRequiredException, MojoExecutionException {
230+
protected LargeSourceSet loadSourceSet(Path repositoryRoot, Environment env, ExecutionContext ctx) throws DependencyResolutionRequiredException, MojoExecutionException, MojoFailureException {
230231
List<NamedStyles> styles = loadStyles(project, env);
231232

232233
//Parse and collect source files from each project in the maven session.

src/main/java/org/openrewrite/maven/AbstractRewriteDryRunMojo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.openrewrite.maven;
1717

1818
import org.apache.maven.plugin.MojoExecutionException;
19+
import org.apache.maven.plugin.MojoFailureException;
1920
import org.apache.maven.plugins.annotations.Parameter;
2021
import org.jspecify.annotations.Nullable;
2122
import org.openrewrite.ExecutionContext;
@@ -47,7 +48,7 @@ public class AbstractRewriteDryRunMojo extends AbstractRewriteBaseRunMojo {
4748
private boolean failOnDryRunResults;
4849

4950
@Override
50-
public void execute() throws MojoExecutionException {
51+
public void execute() throws MojoExecutionException, MojoFailureException {
5152
if (rewriteSkip) {
5253
getLog().info("Skipping execution");
5354
putState(State.SKIPPED);

src/main/java/org/openrewrite/maven/AbstractRewriteRunMojo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.openrewrite.maven;
1717

1818
import org.apache.maven.plugin.MojoExecutionException;
19+
import org.apache.maven.plugin.MojoFailureException;
1920
import org.jspecify.annotations.Nullable;
2021
import org.openrewrite.ExecutionContext;
2122
import org.openrewrite.FileAttributes;
@@ -41,7 +42,7 @@
4142
public class AbstractRewriteRunMojo extends AbstractRewriteBaseRunMojo {
4243

4344
@Override
44-
public void execute() throws MojoExecutionException {
45+
public void execute() throws MojoExecutionException, MojoFailureException {
4546
if (rewriteSkip) {
4647
getLog().info("Skipping execution");
4748
putState(State.SKIPPED);

src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public MavenMojoProjectParser(Log logger, Path baseDir, boolean pomCacheEnabled,
133133
}
134134

135135
public Stream<SourceFile> listSourceFiles(MavenProject mavenProject, List<NamedStyles> styles,
136-
ExecutionContext ctx) throws DependencyResolutionRequiredException, AbstractMojoExecutionException {
136+
ExecutionContext ctx) throws DependencyResolutionRequiredException, MojoExecutionException, MojoFailureException {
137137
if (runPerSubmodule) {
138138
//If running per submodule, parse the source files for only the current project.
139139
List<Marker> projectProvenance = generateProvenance(mavenProject);

0 commit comments

Comments
 (0)