1 package org.apache.maven.lifecycle.mapping;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import java.util.Collections;
23 import java.util.LinkedHashMap;
24 import java.util.List;
25 import java.util.Map;
26
27
28 /**
29 * Class Lifecycle.
30 */
31 public class Lifecycle
32 {
33 /**
34 * Field id
35 */
36 private String id;
37
38 /**
39 * Field phases
40 */
41 private Map<String, LifecyclePhase> lifecyclePhases;
42
43 /*
44 * NOTE: This exists merely for backward-compat with legacy-style lifecycle definitions and allows configuration
45 * injection to work instead of failing.
46 */
47 @SuppressWarnings( "unused" )
48 private List<String> optionalMojos;
49
50 /**
51 * Method getId
52 */
53 public String getId()
54 {
55 return this.id;
56 }
57
58 /**
59 * Method getLifecyclePhases
60 */
61 public Map<String, LifecyclePhase> getLifecyclePhases()
62 {
63 return this.lifecyclePhases;
64 }
65
66 /**
67 * Method setId
68 *
69 * @param id
70 */
71 public void setId( String id )
72 {
73 this.id = id;
74 }
75
76 /**
77 * Method setLifecyclePhases
78 *
79 * @param lifecyclePhases
80 */
81 public void setLifecyclePhases( Map<String, LifecyclePhase> lifecyclePhases )
82 {
83 this.lifecyclePhases = lifecyclePhases;
84 }
85
86 @Deprecated
87 public Map<String, String> getPhases()
88 {
89 Map<String, LifecyclePhase> lphases = getLifecyclePhases();
90 if ( lphases == null )
91 {
92 return null;
93 }
94
95 if ( lphases.isEmpty() )
96 {
97 return Collections.emptyMap();
98 }
99
100 Map<String, String> phases = new LinkedHashMap<>();
101 for ( Map.Entry<String, LifecyclePhase> e: lphases.entrySet() )
102 {
103 phases.put( e.getKey(), e.getValue().toString() );
104 }
105 return phases;
106 }
107
108 @Deprecated
109 public void setPhases( Map<String, String> phases )
110 {
111 Map<String, LifecyclePhase> lphases = new LinkedHashMap<>();
112 for ( Map.Entry<String, String> e: phases.entrySet() )
113 {
114 lphases.put( e.getKey(), new LifecyclePhase( e.getValue() ) );
115 }
116 setLifecyclePhases( lphases );
117 }
118 }