001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
003 * agreements. See the NOTICE file distributed with this work for additional information regarding
004 * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
005 * "License"); you may not use this file except in compliance with the License. You may obtain a
006 * copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software distributed under the License
011 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
012 * or implied. See the License for the specific language governing permissions and limitations under
013 * the License.
014 */
015
016package org.apache.maven.lifecycle.internal.stub;
017
018import org.apache.maven.lifecycle.DefaultLifecycles;
019import org.apache.maven.lifecycle.Lifecycle;
020
021import java.util.Arrays;
022import java.util.HashMap;
023import java.util.Iterator;
024import java.util.List;
025import java.util.Map;
026
027import static org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub.*;
028
029/**
030 * @author Kristian Rosenvold
031 */
032
033public class DefaultLifecyclesStub
034{
035    public static DefaultLifecycles createDefaultLifecycles()
036    {
037
038        List<String> stubDefaultCycle =
039            Arrays.asList( VALIDATE.getPhase(), INITIALIZE.getPhase(), PROCESS_RESOURCES.getPhase(), COMPILE.getPhase(),
040                           TEST.getPhase(), PROCESS_TEST_RESOURCES.getPhase(), PACKAGE.getPhase(), "BEER",
041                           INSTALL.getPhase() );
042
043        // The two phases below are really for future expansion, some would say they lack a drink
044        // The point being that they do not really have to match the "real" stuff,
045        List<String> stubCleanCycle = Arrays.asList( PRE_CLEAN.getPhase(), CLEAN.getPhase(), POST_CLEAN.getPhase() );
046
047        List<String> stubSiteCycle =
048            Arrays.asList( PRE_SITE.getPhase(), SITE.getPhase(), POST_SITE.getPhase(), SITE_DEPLOY.getPhase() );
049
050        @SuppressWarnings( "unchecked" )
051        Iterator<List<String>> lcs = Arrays.asList( stubDefaultCycle, stubCleanCycle, stubSiteCycle ).iterator();
052
053        Map<String, Lifecycle> lifeCycles = new HashMap<String, Lifecycle>();
054        for ( String s : DefaultLifecycles.STANDARD_LIFECYCLES )
055        {
056            final Lifecycle lifecycle = new Lifecycle( s, lcs.next(), null );
057            lifeCycles.put( s, lifecycle );
058
059        }
060        return new DefaultLifecycles( lifeCycles, new LoggerStub() );
061    }
062
063}