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