View Javadoc
1   package org.apache.maven.project;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  import java.util.List;
24  
25  import org.apache.maven.artifact.Artifact;
26  import org.apache.maven.model.building.ModelSource;
27  
28  /**
29   * Builds in-memory descriptions of projects.
30   */
31  public interface ProjectBuilder
32  {
33  
34      /**
35       * Builds a project descriptor from the specified POM file.
36       *
37       * @param projectFile The POM file to build the project from, must not be {@code null}.
38       * @param request The project building request that holds further parameters, must not be {@code null}.
39       * @return The result of the project building, never {@code null}.
40       * @throws ProjectBuildingException If the project descriptor could not be successfully built.
41       */
42      ProjectBuildingResult build( File projectFile, ProjectBuildingRequest request )
43          throws ProjectBuildingException;
44  
45      /**
46       * Builds a project descriptor for the specified artifact.
47       *
48       * @param projectArtifact The POM artifact to build the project from, must not be {@code null}.
49       * @param request The project building request that holds further parameters, must not be {@code null}.
50       * @return The result of the project building, never {@code null}.
51       * @throws ProjectBuildingException If the project descriptor could not be successfully built.
52       */
53      ProjectBuildingResult build( Artifact projectArtifact, ProjectBuildingRequest request )
54          throws ProjectBuildingException;
55  
56      /**
57       * Builds a project descriptor for the specified artifact.
58       *
59       * @param projectArtifact The POM artifact to build the project from, must not be {@code null}.
60       * @param allowStubModel A flag controlling the case of a missing POM artifact. If {@code true} and the specified
61       *            POM artifact does not exist, a simple stub model will be returned. If {@code false}, an exception will
62       *            be thrown.
63       * @param request The project building request that holds further parameters, must not be {@code null}.
64       * @return The result of the project building, never {@code null}.
65       * @throws ProjectBuildingException If the project descriptor could not be successfully built.
66       */
67      ProjectBuildingResult build( Artifact projectArtifact, boolean allowStubModel, ProjectBuildingRequest request )
68          throws ProjectBuildingException;
69  
70      /**
71       * Builds a project descriptor for the specified model source.
72       *
73       * @param modelSource The source of the model to built the project descriptor from, must not be {@code null}.
74       * @param request The project building request that holds further parameters, must not be {@code null}.
75       * @return The result of the project building, never {@code null}.
76       * @throws ProjectBuildingException If the project descriptor could not be successfully built.
77       *
78       * @see org.apache.maven.model.building.ModelSource2
79       */
80      ProjectBuildingResult build( ModelSource modelSource, ProjectBuildingRequest request )
81          throws ProjectBuildingException;
82  
83      /**
84       * Builds the projects for the specified POM files and optionally their children.
85       *
86       * @param pomFiles The POM files to build, must not be {@code null}.
87       * @param recursive {@code true} to recursively build sub modules referenced by the POM files, {@code false} to
88       *            build only the specified POM files.
89       * @param request The project builder configuration that provides further parameters, must not be {@code null}.
90       * @return The results of the project builder where each result corresponds to one project that was built, never
91       *         {@code null}.
92       * @throws ProjectBuildingException If an error was encountered during building of any project.
93       *             {@link ProjectBuildingException#getResults()} provides access to the details of the problems.
94       */
95      List<ProjectBuildingResult> build( List<File> pomFiles, boolean recursive, ProjectBuildingRequest request )
96          throws ProjectBuildingException;
97  
98  }