1 package org.apache.maven.lifecycle;
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.BuilderCommon;
23 import org.apache.maven.lifecycle.internal.ExecutionPlanItem;
24 import org.apache.maven.plugin.MojoExecution;
25 import org.apache.maven.project.MavenProject;
26
27 import java.util.ArrayList;
28 import java.util.List;
29
30
31
32
33
34
35
36 public class DefaultSchedules
37 {
38 List<Scheduling> schedules;
39
40 @SuppressWarnings( { "UnusedDeclaration" } )
41 public DefaultSchedules()
42 {
43 }
44
45 public DefaultSchedules( List<Scheduling> schedules )
46 {
47 this.schedules = schedules;
48 }
49
50 public List<ExecutionPlanItem> createExecutionPlanItem( MavenProject mavenProject, List<MojoExecution> executions )
51 {
52 BuilderCommon.attachToThread( mavenProject );
53
54 List<ExecutionPlanItem> result = new ArrayList<ExecutionPlanItem>();
55 for ( MojoExecution mojoExecution : executions )
56 {
57 String lifeCyclePhase = mojoExecution.getLifecyclePhase();
58 final Scheduling scheduling = getScheduling( "default" );
59 Schedule schedule = null;
60 if ( scheduling != null )
61 {
62 schedule = scheduling.getSchedule( mojoExecution );
63 if ( schedule == null )
64 {
65 schedule = scheduling.getSchedule( lifeCyclePhase );
66 }
67 }
68 result.add( new ExecutionPlanItem( mojoExecution, schedule ) );
69
70 }
71 return result;
72 }
73
74
75
76
77
78
79
80
81
82
83 Scheduling getScheduling( String lifecyclePhaseName )
84 {
85 for ( Scheduling schedule : schedules )
86 {
87 if ( lifecyclePhaseName.equals( schedule.getLifecycle() ) )
88 {
89 return schedule;
90 }
91 }
92 return null;
93 }
94
95 public List<Scheduling> getSchedules()
96 {
97 return schedules;
98 }
99 }