1 package org.apache.maven.lifecycle.mapping;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25
26 public class DefaultLifecycleMapping
27 implements LifecycleMapping
28 {
29
30 private List<Lifecycle> lifecycles;
31
32 private Map<String, Lifecycle> lifecycleMap;
33
34
35 private Map<String, String> phases;
36
37
38
39
40 private void initLifecycleMap()
41 {
42 if ( lifecycleMap == null )
43 {
44 lifecycleMap = new HashMap<String, Lifecycle>();
45
46 if ( lifecycles != null )
47 {
48 for ( Lifecycle lifecycle : lifecycles )
49 {
50 lifecycleMap.put( lifecycle.getId(), lifecycle );
51 }
52 }
53 else
54 {
55
56
57
58
59
60 String[] lifecycleIds = { "default", "clean", "site" };
61
62 for ( String lifecycleId : lifecycleIds )
63 {
64 Map<String, String> phases = getPhases( lifecycleId );
65 if ( phases != null )
66 {
67 Lifecycle lifecycle = new Lifecycle();
68
69 lifecycle.setId( lifecycleId );
70 lifecycle.setPhases( phases );
71
72 lifecycleMap.put( lifecycleId, lifecycle );
73 }
74 }
75 }
76 }
77 }
78
79 public Map<String, Lifecycle> getLifecycles()
80 {
81 initLifecycleMap();
82
83 return lifecycleMap;
84 }
85
86 public List<String> getOptionalMojos( String lifecycle )
87 {
88 return null;
89 }
90
91 public Map<String, String> getPhases( String lifecycle )
92 {
93 initLifecycleMap();
94
95 Lifecycle lifecycleMapping = lifecycleMap.get( lifecycle );
96
97 if ( lifecycleMapping != null )
98 {
99 return lifecycleMapping.getPhases();
100 }
101 else if ( "default".equals( lifecycle ) )
102 {
103 return phases;
104 }
105 else
106 {
107 return null;
108 }
109 }
110
111 }