Skip to content

Commit

Permalink
Declare to throw MojoExecutionException & MojoFailureException
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Sep 12, 2024
1 parent fa57b83 commit 59404e5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.micrometer.core.instrument.Metrics;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.jspecify.annotations.Nullable;
Expand Down Expand Up @@ -102,7 +103,7 @@ protected Path repositoryRoot() {
return maybeBaseDir;
}

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

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

//Parse and collect source files from each project in the maven session.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.openrewrite.maven;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Parameter;
import org.jspecify.annotations.Nullable;
import org.openrewrite.ExecutionContext;
Expand Down Expand Up @@ -47,7 +48,7 @@ public class AbstractRewriteDryRunMojo extends AbstractRewriteBaseRunMojo {
private boolean failOnDryRunResults;

@Override
public void execute() throws MojoExecutionException {
public void execute() throws MojoExecutionException, MojoFailureException {
if (rewriteSkip) {
getLog().info("Skipping execution");
putState(State.SKIPPED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.openrewrite.maven;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.jspecify.annotations.Nullable;
import org.openrewrite.ExecutionContext;
import org.openrewrite.FileAttributes;
Expand All @@ -41,7 +42,7 @@
public class AbstractRewriteRunMojo extends AbstractRewriteBaseRunMojo {

@Override
public void execute() throws MojoExecutionException {
public void execute() throws MojoExecutionException, MojoFailureException {
if (rewriteSkip) {
getLog().info("Skipping execution");
putState(State.SKIPPED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public MavenMojoProjectParser(Log logger, Path baseDir, boolean pomCacheEnabled,
}

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

0 comments on commit 59404e5

Please sign in to comment.