001package org.apache.maven.lifecycle;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import org.apache.maven.execution.MavenSession;
023import org.apache.maven.model.Plugin;
024import org.apache.maven.plugin.InvalidPluginDescriptorException;
025import org.apache.maven.plugin.MojoExecution;
026import org.apache.maven.plugin.MojoNotFoundException;
027import org.apache.maven.plugin.PluginDescriptorParsingException;
028import org.apache.maven.plugin.PluginManagerException;
029import org.apache.maven.plugin.PluginNotFoundException;
030import org.apache.maven.plugin.PluginResolutionException;
031import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException;
032import org.apache.maven.plugin.version.PluginVersionResolutionException;
033import org.apache.maven.project.MavenProject;
034
035import java.util.List;
036import java.util.Set;
037
038/**
039 * A facade that provides lifecycle services to components outside Maven core.
040 *
041 * @author Jason van  Zyl
042 */
043public interface LifecycleExecutor
044{
045
046    // USED BY MAVEN HELP PLUGIN
047    @Deprecated
048    String ROLE = LifecycleExecutor.class.getName();
049
050    // For a given project packaging find all the plugins that are bound to any registered
051    // lifecycles. The project builder needs to now what default plugin information needs to be
052    // merged into POM being built. Once the POM builder has this plugin information, versions can be assigned
053    // by the POM builder because they will have to be defined in plugin management. Once this is setComplete then it
054    // can be passed back so that the default configuration information can be populated.
055    //
056    // We need to know the specific version so that we can lookup the right version of the plugin descriptor
057    // which tells us what the default configuration is.
058    //
059
060    /**
061     * @return The plugins bound to the lifecycles of the specified packaging or {@code null} if the packaging is
062     *         unknown.
063     */
064    Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging );
065
066    MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks )
067        throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
068        MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
069        PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException,
070        PluginVersionResolutionException;
071
072    MavenExecutionPlan calculateExecutionPlan( MavenSession session, boolean setup, String... tasks )
073        throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
074        MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
075        PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException,
076        PluginVersionResolutionException;
077
078    void execute( MavenSession session );
079
080    // used by the site plugin 3.x
081    void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session )
082        throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException,
083        PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
084        LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException;
085
086    // used by the site plugin 3.x
087    List<MavenProject> executeForkedExecutions( MojoExecution mojoExecution, MavenSession session )
088        throws LifecycleExecutionException;
089}