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