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