KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > maven > lifecycle > mapping > DefaultLifecycleMapping


1 package org.apache.maven.lifecycle.mapping;
2
3 /*
4  * Copyright 2001-2005 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * 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, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import java.util.HashMap JavaDoc;
20 import java.util.Iterator JavaDoc;
21 import java.util.List JavaDoc;
22 import java.util.Map JavaDoc;
23
24 /**
25  * Lifecycle mapping for a POM.
26  *
27  * @author <a HREF="mailto:brett@apache.org">Brett Porter</a>
28  * @version $Id: DefaultLifecycleMapping.java 367963 2006-01-11 07:59:23Z jdcasey $
29  */

30 public class DefaultLifecycleMapping
31     implements LifecycleMapping
32 {
33     private List JavaDoc lifecycles;
34
35     private Map JavaDoc lifecycleMap;
36
37     /** @deprecated use lifecycles instead */
38     private Map JavaDoc phases;
39     
40     public List JavaDoc getOptionalMojos( String JavaDoc lifecycle )
41     {
42         if ( lifecycleMap == null )
43         {
44             lifecycleMap = new HashMap JavaDoc();
45
46             if ( lifecycles != null )
47             {
48                 for ( Iterator JavaDoc i = lifecycles.iterator(); i.hasNext(); )
49                 {
50                     Lifecycle l = (Lifecycle) i.next();
51                     lifecycleMap.put( l.getId(), l );
52                 }
53             }
54         }
55         Lifecycle l = (Lifecycle) lifecycleMap.get( lifecycle );
56
57         if ( l != null )
58         {
59             return l.getOptionalMojos();
60         }
61         else
62         {
63             return null;
64         }
65     }
66
67     public Map JavaDoc getPhases( String JavaDoc lifecycle )
68     {
69         if ( lifecycleMap == null )
70         {
71             lifecycleMap = new HashMap JavaDoc();
72
73             if ( lifecycles != null )
74             {
75                 for ( Iterator JavaDoc i = lifecycles.iterator(); i.hasNext(); )
76                 {
77                     Lifecycle l = (Lifecycle) i.next();
78                     lifecycleMap.put( l.getId(), l );
79                 }
80             }
81         }
82         Lifecycle l = (Lifecycle) lifecycleMap.get( lifecycle );
83
84         Map JavaDoc mappings = null;
85         if ( l == null )
86         {
87             if ( "default".equals( lifecycle ) )
88             {
89                 mappings = phases;
90             }
91         }
92         else
93         {
94             mappings = l.getPhases();
95         }
96
97         return mappings;
98     }
99
100 }
101
Popular Tags