001package org.apache.maven.project;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.io.File;
023import java.util.List;
024
025import org.apache.maven.artifact.Artifact;
026import org.apache.maven.model.building.ModelSource;
027
028/**
029 * Builds in-memory descriptions of projects.
030 */
031public interface ProjectBuilder
032{
033
034    /**
035     * Builds a project descriptor from the specified POM file.
036     *
037     * @param projectFile The POM file to build the project from, must not be {@code null}.
038     * @param request The project building request that holds further parameters, must not be {@code null}.
039     * @return The result of the project building, never {@code null}.
040     * @throws ProjectBuildingException If the project descriptor could not be successfully built.
041     */
042    ProjectBuildingResult build( File projectFile, ProjectBuildingRequest request )
043        throws ProjectBuildingException;
044
045    /**
046     * Builds a project descriptor for the specified artifact.
047     *
048     * @param projectArtifact The POM artifact to build the project from, must not be {@code null}.
049     * @param request The project building request that holds further parameters, must not be {@code null}.
050     * @return The result of the project building, never {@code null}.
051     * @throws ProjectBuildingException If the project descriptor could not be successfully built.
052     */
053    ProjectBuildingResult build( Artifact projectArtifact, ProjectBuildingRequest request )
054        throws ProjectBuildingException;
055
056    /**
057     * Builds a project descriptor for the specified artifact.
058     *
059     * @param projectArtifact The POM artifact to build the project from, must not be {@code null}.
060     * @param allowStubModel A flag controlling the case of a missing POM artifact. If {@code true} and the specified
061     *            POM artifact does not exist, a simple stub model will be returned. If {@code false}, an exception will
062     *            be thrown.
063     * @param request The project building request that holds further parameters, must not be {@code null}.
064     * @return The result of the project building, never {@code null}.
065     * @throws ProjectBuildingException If the project descriptor could not be successfully built.
066     */
067    ProjectBuildingResult build( Artifact projectArtifact, boolean allowStubModel, ProjectBuildingRequest request )
068        throws ProjectBuildingException;
069
070    /**
071     * Builds a project descriptor for the specified model source.
072     *
073     * @param modelSource The source of the model to built the project descriptor from, must not be {@code null}.
074     * @param request The project building request that holds further parameters, must not be {@code null}.
075     * @return The result of the project building, never {@code null}.
076     * @throws ProjectBuildingException If the project descriptor could not be successfully built.
077     *
078     * @see org.apache.maven.model.building.ModelSource2
079     */
080    ProjectBuildingResult build( ModelSource modelSource, ProjectBuildingRequest request )
081        throws ProjectBuildingException;
082
083    /**
084     * Builds the projects for the specified POM files and optionally their children.
085     *
086     * @param pomFiles The POM files to build, must not be {@code null}.
087     * @param recursive {@code true} to recursively build sub modules referenced by the POM files, {@code false} to
088     *            build only the specified POM files.
089     * @param request The project builder configuration that provides further parameters, must not be {@code null}.
090     * @return The results of the project builder where each result corresponds to one project that was built, never
091     *         {@code null}.
092     * @throws ProjectBuildingException If an error was encountered during building of any project.
093     *             {@link ProjectBuildingException#getResults()} provides access to the details of the problems.
094     */
095    List<ProjectBuildingResult> build( List<File> pomFiles, boolean recursive, ProjectBuildingRequest request )
096        throws ProjectBuildingException;
097
098}