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