View Javadoc
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  
21  import java.util.Arrays;
22  import java.util.HashMap;
23  import java.util.Iterator;
24  import java.util.List;
25  import java.util.Map;
26  
27  import static org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub.*;
28  
29  /**
30   * @author Kristian Rosenvold
31   */
32  
33  public class DefaultLifecyclesStub
34  {
35      public static DefaultLifecycles createDefaultLifecycles()
36      {
37  
38          List<String> stubDefaultCycle =
39              Arrays.asList( VALIDATE.getPhase(), INITIALIZE.getPhase(), PROCESS_RESOURCES.getPhase(), COMPILE.getPhase(),
40                             TEST.getPhase(), PROCESS_TEST_RESOURCES.getPhase(), PACKAGE.getPhase(), "BEER",
41                             INSTALL.getPhase() );
42  
43          // The two phases below are really for future expansion, some would say they lack a drink
44          // The point being that they do not really have to match the "real" stuff,
45          List<String> stubCleanCycle = Arrays.asList( PRE_CLEAN.getPhase(), CLEAN.getPhase(), POST_CLEAN.getPhase() );
46  
47          List<String> stubSiteCycle =
48              Arrays.asList( PRE_SITE.getPhase(), SITE.getPhase(), POST_SITE.getPhase(), SITE_DEPLOY.getPhase() );
49  
50          @SuppressWarnings( "unchecked" )
51          Iterator<List<String>> lcs = Arrays.asList( stubDefaultCycle, stubCleanCycle, stubSiteCycle ).iterator();
52  
53          Map<String, Lifecycle> lifeCycles = new HashMap<>();
54          for ( String s : DefaultLifecycles.STANDARD_LIFECYCLES )
55          {
56              final Lifecycle lifecycle = new Lifecycle( s, lcs.next(), null );
57              lifeCycles.put( s, lifecycle );
58  
59          }
60          return new DefaultLifecycles( lifeCycles, new LoggerStub() );
61      }
62  
63  }