1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.maven.lifecycle.internal.stub;
17
18 import org.apache.maven.execution.MavenSession;
19 import org.apache.maven.lifecycle.LifecycleExecutionException;
20 import org.apache.maven.lifecycle.internal.DependencyContext;
21 import org.apache.maven.lifecycle.internal.MojoExecutor;
22 import org.apache.maven.lifecycle.internal.PhaseRecorder;
23 import org.apache.maven.lifecycle.internal.ProjectIndex;
24 import org.apache.maven.plugin.MojoExecution;
25 import org.apache.maven.plugin.descriptor.MojoDescriptor;
26 import org.apache.maven.plugin.descriptor.PluginDescriptor;
27
28 import java.util.ArrayList;
29 import java.util.Collections;
30 import java.util.List;
31
32
33
34
35 public class MojoExecutorStub
36 extends MojoExecutor
37 {
38
39 public List<MojoExecution> executions = Collections.synchronizedList( new ArrayList<MojoExecution>() );
40
41 @Override
42 public void execute( MavenSession session, MojoExecution mojoExecution, ProjectIndex projectIndex,
43 DependencyContext dependencyContext, PhaseRecorder phaseRecorder )
44 throws LifecycleExecutionException
45 {
46 executions.add( mojoExecution );
47 }
48
49 @Override
50 public void execute( MavenSession session, List<MojoExecution> mojoExecutions, ProjectIndex projectIndex )
51 throws LifecycleExecutionException
52 {
53 for ( MojoExecution mojoExecution : mojoExecutions )
54 {
55 executions.add( mojoExecution );
56 }
57 }
58
59
60 public static MojoDescriptor createMojoDescriptor( String mojoDescription )
61 {
62 final PluginDescriptor descriptor = new PluginDescriptor();
63 descriptor.setArtifactId( mojoDescription );
64 final MojoDescriptor mojoDescriptor = new MojoDescriptor();
65 mojoDescriptor.setDescription( mojoDescription );
66 mojoDescriptor.setPluginDescriptor( descriptor );
67 return mojoDescriptor;
68 }
69
70 }