1   package org.apache.maven.lifecycle.internal;
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  import org.apache.maven.lifecycle.internal.builder.BuilderCommon;
23  import org.apache.maven.model.Plugin;
24  import org.apache.maven.plugin.MojoExecution;
25  import org.apache.maven.plugin.descriptor.MojoDescriptor;
26  import org.apache.maven.project.MavenProject;
27  
28  import java.util.ArrayList;
29  import java.util.List;
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  public class ExecutionPlanItem
41  {
42      private final MojoExecution mojoExecution;
43  
44      public ExecutionPlanItem( MojoExecution mojoExecution )
45      {
46          this.mojoExecution = mojoExecution;
47      }
48  
49      public static List<ExecutionPlanItem> createExecutionPlanItems( MavenProject mavenProject,
50                                                                      List<MojoExecution> executions )
51      {
52          BuilderCommon.attachToThread( mavenProject );
53  
54          List<ExecutionPlanItem> result = new ArrayList<>();
55          for ( MojoExecution mojoExecution : executions )
56          {
57              result.add( new ExecutionPlanItem( mojoExecution ) );
58          }
59          return result;
60      }
61  
62      public MojoExecution getMojoExecution()
63      {
64          return mojoExecution;
65      }
66  
67      public String getLifecyclePhase()
68      {
69          return mojoExecution.getLifecyclePhase();
70      }
71  
72      public Plugin getPlugin()
73      {
74          final MojoDescriptor mojoDescriptor = getMojoExecution().getMojoDescriptor();
75          return mojoDescriptor.getPluginDescriptor().getPlugin();
76      }
77  
78      @Override
79      public String toString()
80      {
81          return "ExecutionPlanItem{" + ", mojoExecution=" + mojoExecution + '}'
82              + super.toString();
83      }
84  
85  }