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.project;
20  
21  import java.io.File;
22  import java.util.List;
23  
24  import org.apache.maven.artifact.Artifact;
25  import org.apache.maven.model.building.ModelSource;
26  
27  /**
28   * Builds in-memory descriptions of projects.
29   */
30  public interface ProjectBuilder {
31  
32      /**
33       * Builds a project descriptor from the specified POM file.
34       *
35       * @param projectFile The POM file to build the project from, must not be {@code null}.
36       * @param request The project building request that holds further parameters, must not be {@code null}.
37       * @return The result of the project building, never {@code null}.
38       * @throws ProjectBuildingException If the project descriptor could not be successfully built.
39       */
40      ProjectBuildingResult build(File projectFile, ProjectBuildingRequest request) throws ProjectBuildingException;
41  
42      /**
43       * Builds a project descriptor for the specified artifact.
44       *
45       * @param projectArtifact The POM artifact to build the project from, must not be {@code null}.
46       * @param request The project building request that holds further parameters, must not be {@code null}.
47       * @return The result of the project building, never {@code null}.
48       * @throws ProjectBuildingException If the project descriptor could not be successfully built.
49       */
50      ProjectBuildingResult build(Artifact projectArtifact, ProjectBuildingRequest request)
51              throws ProjectBuildingException;
52  
53      /**
54       * Builds a project descriptor for the specified artifact.
55       *
56       * @param projectArtifact The POM artifact to build the project from, must not be {@code null}.
57       * @param allowStubModel A flag controlling the case of a missing POM artifact. If {@code true} and the specified
58       *            POM artifact does not exist, a simple stub model will be returned. If {@code false}, an exception will
59       *            be thrown.
60       * @param request The project building request that holds further parameters, must not be {@code null}.
61       * @return The result of the project building, never {@code null}.
62       * @throws ProjectBuildingException If the project descriptor could not be successfully built.
63       */
64      ProjectBuildingResult build(Artifact projectArtifact, boolean allowStubModel, ProjectBuildingRequest request)
65              throws ProjectBuildingException;
66  
67      /**
68       * Builds a project descriptor for the specified model source.
69       *
70       * @param modelSource The source of the model to built the project descriptor from, must not be {@code null}.
71       * @param request The project building request that holds further parameters, must not be {@code null}.
72       * @return The result of the project building, never {@code null}.
73       * @throws ProjectBuildingException If the project descriptor could not be successfully built.
74       *
75       * @see org.apache.maven.model.building.ModelSource2
76       */
77      ProjectBuildingResult build(ModelSource modelSource, ProjectBuildingRequest request)
78              throws ProjectBuildingException;
79  
80      /**
81       * Builds the projects for the specified POM files and optionally their children.
82       *
83       * @param pomFiles The POM files to build, must not be {@code null}.
84       * @param recursive {@code true} to recursively build sub modules referenced by the POM files, {@code false} to
85       *            build only the specified POM files.
86       * @param request The project builder configuration that provides further parameters, must not be {@code null}.
87       * @return The results of the project builder where each result corresponds to one project that was built, never
88       *         {@code null}.
89       * @throws ProjectBuildingException If an error was encountered during building of any project.
90       *             {@link ProjectBuildingException#getResults()} provides access to the details of the problems.
91       */
92      List<ProjectBuildingResult> build(List<File> pomFiles, boolean recursive, ProjectBuildingRequest request)
93              throws ProjectBuildingException;
94  }