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.ArrayList;
23 import java.util.Collections;
24 import java.util.LinkedHashMap;
25 import java.util.List;
26 import java.util.Map;
27
28 import org.codehaus.plexus.util.StringUtils;
29
30
31
32
33
34
35 public class LifecyclePhase
36 {
37
38 private List<LifecycleMojo> mojos;
39
40 public LifecyclePhase()
41 {
42 }
43
44 public LifecyclePhase( String goals )
45 {
46 set( goals );
47 }
48
49 public List<LifecycleMojo> getMojos()
50 {
51 return mojos;
52 }
53
54 public void setMojos( List<LifecycleMojo> mojos )
55 {
56 this.mojos = mojos;
57 }
58
59 public void set( String goals )
60 {
61 mojos = new ArrayList<>();
62
63 if ( StringUtils.isNotEmpty( goals ) )
64 {
65 String[] mojoGoals = StringUtils.split( goals, "," );
66
67 for ( String mojoGoal: mojoGoals )
68 {
69 LifecycleMojo lifecycleMojo = new LifecycleMojo();
70 lifecycleMojo.setGoal( mojoGoal.trim() );
71 mojos.add( lifecycleMojo );
72 }
73 }
74 }
75
76 @Override
77 public String toString()
78 {
79 StringBuilder sb = new StringBuilder();
80 boolean first = true;
81 List<LifecycleMojo> mojos = getMojos();
82 if ( mojos != null )
83 {
84 for ( LifecycleMojo mojo: mojos )
85 {
86 if ( first )
87 {
88 first = false;
89 }
90 else
91 {
92 sb.append( ',' );
93 }
94 sb.append( mojo.getGoal() );
95 }
96 }
97 return sb.toString();
98 }
99
100 @Deprecated
101 public static Map<String, String> toLegacyMap( Map<String, LifecyclePhase> lifecyclePhases )
102 {
103 if ( lifecyclePhases == null )
104 {
105 return null;
106 }
107
108 if ( lifecyclePhases.isEmpty() )
109 {
110 return Collections.emptyMap();
111 }
112
113 Map<String, String> phases = new LinkedHashMap<>();
114 for ( Map.Entry<String, LifecyclePhase> e: lifecyclePhases.entrySet() )
115 {
116 phases.put( e.getKey(), e.getValue().toString() );
117 }
118 return phases;
119 }
120
121 }