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   */
41  public interface LifecycleExecutor {
42  
43      // USED BY MAVEN HELP PLUGIN
44      @Deprecated
45      String ROLE = LifecycleExecutor.class.getName();
46  
47      // For a given project packaging find all the plugins that are bound to any registered
48      // lifecycles. The project builder needs to now what default plugin information needs to be
49      // merged into POM being built. Once the POM builder has this plugin information, versions can be assigned
50      // by the POM builder because they will have to be defined in plugin management. Once this is setComplete then it
51      // can be passed back so that the default configuration information can be populated.
52      //
53      // We need to know the specific version so that we can look up the right version of the plugin descriptor
54      // which tells us what the default configuration is.
55      //
56  
57      /**
58       * @return The plugins bound to the lifecycles of the specified packaging or {@code null} if the packaging is
59       *         unknown.
60       */
61      Set<Plugin> getPluginsBoundByDefaultToAllLifecycles(String packaging);
62  
63      MavenExecutionPlan calculateExecutionPlan(MavenSession session, String... tasks)
64              throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
65                      MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
66                      PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException,
67                      PluginVersionResolutionException;
68  
69      MavenExecutionPlan calculateExecutionPlan(MavenSession session, boolean setup, String... tasks)
70              throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
71                      MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
72                      PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException,
73                      PluginVersionResolutionException;
74  
75      void execute(MavenSession session);
76  
77      // used by the site plugin 3.x
78      void calculateForkedExecutions(MojoExecution mojoExecution, MavenSession session)
79              throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException,
80                      PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
81                      LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException;
82  
83      // used by the site plugin 3.x
84      List<MavenProject> executeForkedExecutions(MojoExecution mojoExecution, MavenSession session)
85              throws LifecycleExecutionException;
86  }