View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.lifecycle;
20  
21  import java.util.List;
22  import java.util.Set;
23  
24  import org.apache.maven.execution.MavenSession;
25  import org.apache.maven.model.Plugin;
26  import org.apache.maven.plugin.InvalidPluginDescriptorException;
27  import org.apache.maven.plugin.MojoExecution;
28  import org.apache.maven.plugin.MojoNotFoundException;
29  import org.apache.maven.plugin.PluginDescriptorParsingException;
30  import org.apache.maven.plugin.PluginManagerException;
31  import org.apache.maven.plugin.PluginNotFoundException;
32  import org.apache.maven.plugin.PluginResolutionException;
33  import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException;
34  import org.apache.maven.plugin.version.PluginVersionResolutionException;
35  import org.apache.maven.project.MavenProject;
36  
37  /**
38   * A facade that provides lifecycle services to components outside Maven core.
39   *
40   * @author Jason van  Zyl
41   */
42  public interface LifecycleExecutor {
43  
44      // USED BY MAVEN HELP PLUGIN
45      @Deprecated
46      String ROLE = LifecycleExecutor.class.getName();
47  
48      // For a given project packaging find all the plugins that are bound to any registered
49      // lifecycles. The project builder needs to now what default plugin information needs to be
50      // merged into POM being built. Once the POM builder has this plugin information, versions can be assigned
51      // by the POM builder because they will have to be defined in plugin management. Once this is setComplete then it
52      // can be passed back so that the default configuration information can be populated.
53      //
54      // We need to know the specific version so that we can lookup the right version of the plugin descriptor
55      // which tells us what the default configuration is.
56      //
57  
58      /**
59       * @return The plugins bound to the lifecycles of the specified packaging or {@code null} if the packaging is
60       *         unknown.
61       */
62      Set<Plugin> getPluginsBoundByDefaultToAllLifecycles(String packaging);
63  
64      MavenExecutionPlan calculateExecutionPlan(MavenSession session, String... tasks)
65              throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
66                      MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
67                      PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException,
68                      PluginVersionResolutionException;
69  
70      MavenExecutionPlan calculateExecutionPlan(MavenSession session, boolean setup, String... tasks)
71              throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
72                      MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
73                      PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException,
74                      PluginVersionResolutionException;
75  
76      void execute(MavenSession session);
77  
78      // used by the site plugin 3.x
79      void calculateForkedExecutions(MojoExecution mojoExecution, MavenSession session)
80              throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException,
81                      PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
82                      LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException;
83  
84      // used by the site plugin 3.x
85      List<MavenProject> executeForkedExecutions(MojoExecution mojoExecution, MavenSession session)
86              throws LifecycleExecutionException;
87  }