1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional information regarding
4    * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with the License. You may obtain a
6    * copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software distributed under the License
11   * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing permissions and limitations under
13   * the License.
14   */
15  
16  package org.apache.maven.lifecycle.internal.stub;
17  
18  import org.apache.maven.lifecycle.DefaultLifecycles;
19  import org.apache.maven.lifecycle.Lifecycle;
20  import org.apache.maven.lifecycle.Schedule;
21  import org.apache.maven.lifecycle.Scheduling;
22  
23  import java.util.Arrays;
24  import java.util.HashMap;
25  import java.util.Iterator;
26  import java.util.List;
27  import java.util.Map;
28  
29  import static org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub.*;
30  
31  /**
32   * @author Kristian Rosenvold
33   */
34  
35  public class DefaultLifecyclesStub
36  {
37      public static DefaultLifecycles createDefaultLifecycles()
38      {
39  
40          List<String> stubDefaultCycle =
41              Arrays.asList( VALIDATE.getPhase(), INITIALIZE.getPhase(), PROCESS_RESOURCES.getPhase(), COMPILE.getPhase(),
42                             TEST.getPhase(), PROCESS_TEST_RESOURCES.getPhase(), PACKAGE.getPhase(), "BEER",
43                             INSTALL.getPhase() );
44  
45          // The two phases below are really for future expansion, some would say they lack a drink
46          // The point being that they do not really have to match the "real" stuff,
47          List<String> stubCleanCycle = Arrays.asList( PRE_CLEAN.getPhase(), CLEAN.getPhase(), POST_CLEAN.getPhase() );
48  
49          List<String> stubSiteCycle =
50              Arrays.asList( PRE_SITE.getPhase(), SITE.getPhase(), POST_SITE.getPhase(), SITE_DEPLOY.getPhase() );
51  
52          Iterator<List<String>> lcs = Arrays.asList( stubDefaultCycle, stubCleanCycle, stubSiteCycle ).iterator();
53  
54          Map<String, Lifecycle> lifeCycles = new HashMap<String, Lifecycle>();
55          for ( String s : DefaultLifecycles.STANDARD_LIFECYCLES )
56          {
57              final Lifecycle lifecycle = new Lifecycle( s, lcs.next(), null );
58              lifeCycles.put( s, lifecycle );
59  
60          }
61          return new DefaultLifecycles( lifeCycles, new LoggerStub() );
62      }
63  
64      public static List<Scheduling> getSchedulingList()
65      {
66          return Arrays.asList( new Scheduling( "default", Arrays.asList( new Schedule( "compile", false, false ),
67                                                                          new Schedule( "test", false, true ) ) ) );
68      }
69  }