|
54 | 54 | import org.apache.maven.execution.MavenExecutionResult; |
55 | 55 | import org.apache.maven.execution.MavenSession; |
56 | 56 | import org.apache.maven.lifecycle.internal.DependencyContext; |
| 57 | +import org.apache.maven.lifecycle.internal.LifecycleExecutionPlanCalculator; |
57 | 58 | import org.apache.maven.lifecycle.internal.MojoExecutor; |
58 | 59 | import org.apache.maven.plugin.BuildPluginManager; |
59 | 60 | import org.apache.maven.plugin.LegacySupport; |
@@ -325,14 +326,18 @@ private static void executeMojo(MavenSession session, MojoExecution execution, I |
325 | 326 | artifacts.put(project, new LinkedHashSet<>(project.getArtifacts())); |
326 | 327 | snapshots.put(project, MavenProjectMutableState.takeSnapshot(project)); |
327 | 328 | } |
| 329 | + MojoExecution clone = new MojoExecution(execution.getPlugin(), execution.getGoal(), execution.getExecutionId()); |
328 | 330 | try { |
| 331 | + MavenProject currentProject = session.getCurrentProject(); |
| 332 | + LifecycleExecutionPlanCalculator executionPlanCalculator = lookup.lookup(LifecycleExecutionPlanCalculator.class); |
| 333 | + executionPlanCalculator.setupMojoExecution(session, currentProject, clone); |
329 | 334 | MojoExecutor mojoExecutor = lookup.lookup(MojoExecutor.class); |
330 | | - DependencyContext dependencyContext = mojoExecutor.newDependencyContext(session, List.of(execution)); |
331 | | - mojoExecutor.ensureDependenciesAreResolved(execution.getMojoDescriptor(), session, dependencyContext); |
332 | | - lookup.lookup(BuildPluginManager.class).executeMojo(session, execution); |
| 335 | + DependencyContext dependencyContext = mojoExecutor.newDependencyContext(session, List.of(clone)); |
| 336 | + mojoExecutor.ensureDependenciesAreResolved(clone.getMojoDescriptor(), session, dependencyContext); |
| 337 | + BuildPluginManager buildPluginManager = lookup.lookup(BuildPluginManager.class); |
| 338 | + buildPluginManager.executeMojo(session, clone); |
333 | 339 | } catch(Exception ex) { |
334 | | - session.getResult().addException(ex); |
335 | | - throw new CoreException(Status.error("Failed to execute mojo", ex)); |
| 340 | + throw new CoreException(Status.error("Failed to execute mojo " + clone, ex)); |
336 | 341 | } finally { |
337 | 342 | for(MavenProject project : session.getProjects()) { |
338 | 343 | project.setArtifactFilter(null); |
|
0 commit comments