1 package org.apache.maven.lifecycle.mapping; 2 3 18 19 import java.util.HashMap ; 20 import java.util.Iterator ; 21 import java.util.List ; 22 import java.util.Map ; 23 24 30 public class DefaultLifecycleMapping 31 implements LifecycleMapping 32 { 33 private List lifecycles; 34 35 private Map lifecycleMap; 36 37 38 private Map phases; 39 40 public List getOptionalMojos( String lifecycle ) 41 { 42 if ( lifecycleMap == null ) 43 { 44 lifecycleMap = new HashMap (); 45 46 if ( lifecycles != null ) 47 { 48 for ( Iterator 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 getPhases( String lifecycle ) 68 { 69 if ( lifecycleMap == null ) 70 { 71 lifecycleMap = new HashMap (); 72 73 if ( lifecycles != null ) 74 { 75 for ( Iterator 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 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 |