Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
DefaultLifecycleMapping |
|
| 6.0;6 |
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.HashMap; | |
23 | import java.util.Iterator; | |
24 | import java.util.List; | |
25 | import java.util.Map; | |
26 | ||
27 | /** | |
28 | * Lifecycle mapping for a POM. | |
29 | * | |
30 | * @author <a href="mailto:brett@apache.org">Brett Porter</a> | |
31 | * @version $Id: DefaultLifecycleMapping.java 640549 2008-03-24 20:05:11Z bentmann $ | |
32 | */ | |
33 | 0 | public class DefaultLifecycleMapping |
34 | implements LifecycleMapping | |
35 | { | |
36 | private List lifecycles; | |
37 | ||
38 | private Map lifecycleMap; | |
39 | ||
40 | /** @deprecated use lifecycles instead */ | |
41 | private Map phases; | |
42 | ||
43 | public List getOptionalMojos( String lifecycle ) | |
44 | { | |
45 | 0 | if ( lifecycleMap == null ) |
46 | { | |
47 | 0 | lifecycleMap = new HashMap(); |
48 | ||
49 | 0 | if ( lifecycles != null ) |
50 | { | |
51 | 0 | for ( Iterator i = lifecycles.iterator(); i.hasNext(); ) |
52 | { | |
53 | 0 | Lifecycle l = (Lifecycle) i.next(); |
54 | 0 | lifecycleMap.put( l.getId(), l ); |
55 | 0 | } |
56 | } | |
57 | } | |
58 | 0 | Lifecycle l = (Lifecycle) lifecycleMap.get( lifecycle ); |
59 | ||
60 | 0 | if ( l != null ) |
61 | { | |
62 | 0 | return l.getOptionalMojos(); |
63 | } | |
64 | else | |
65 | { | |
66 | 0 | return null; |
67 | } | |
68 | } | |
69 | ||
70 | public Map getPhases( String lifecycle ) | |
71 | { | |
72 | 0 | if ( lifecycleMap == null ) |
73 | { | |
74 | 0 | lifecycleMap = new HashMap(); |
75 | ||
76 | 0 | if ( lifecycles != null ) |
77 | { | |
78 | 0 | for ( Iterator i = lifecycles.iterator(); i.hasNext(); ) |
79 | { | |
80 | 0 | Lifecycle l = (Lifecycle) i.next(); |
81 | 0 | lifecycleMap.put( l.getId(), l ); |
82 | 0 | } |
83 | } | |
84 | } | |
85 | 0 | Lifecycle l = (Lifecycle) lifecycleMap.get( lifecycle ); |
86 | ||
87 | 0 | Map mappings = null; |
88 | 0 | if ( l == null ) |
89 | { | |
90 | 0 | if ( "default".equals( lifecycle ) ) |
91 | { | |
92 | 0 | mappings = phases; |
93 | } | |
94 | } | |
95 | else | |
96 | { | |
97 | 0 | mappings = l.getPhases(); |
98 | } | |
99 | ||
100 | 0 | return mappings; |
101 | } | |
102 | ||
103 | } |