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; 027import org.apache.maven.model.building.ModelSource2; 028 029/** 030 * Builds in-memory descriptions of projects. 031 */ 032public interface ProjectBuilder 033{ 034 035 /** 036 * Builds a project descriptor from the specified POM file. 037 * 038 * @param projectFile The POM file to build the project from, must not be {@code null}. 039 * @param request The project building request that holds further parameters, must not be {@code null}. 040 * @return The result of the project building, never {@code null}. 041 * @throws ProjectBuildingException If the project descriptor could not be successfully built. 042 */ 043 ProjectBuildingResult build( File projectFile, ProjectBuildingRequest request ) 044 throws ProjectBuildingException; 045 046 /** 047 * Builds a project descriptor for the specified artifact. 048 * 049 * @param projectArtifact The POM artifact to build the project from, must not be {@code null}. 050 * @param request The project building request that holds further parameters, must not be {@code null}. 051 * @return The result of the project building, never {@code null}. 052 * @throws ProjectBuildingException If the project descriptor could not be successfully built. 053 */ 054 ProjectBuildingResult build( Artifact projectArtifact, ProjectBuildingRequest request ) 055 throws ProjectBuildingException; 056 057 /** 058 * Builds a project descriptor for the specified artifact. 059 * 060 * @param projectArtifact The POM artifact to build the project from, must not be {@code null}. 061 * @param allowStubModel A flag controlling the case of a missing POM artifact. If {@code true} and the specified 062 * POM artifact does not exist, a simple stub model will be returned. If {@code false}, an exception will 063 * be thrown. 064 * @param request The project building request that holds further parameters, must not be {@code null}. 065 * @return The result of the project building, never {@code null}. 066 * @throws ProjectBuildingException If the project descriptor could not be successfully built. 067 */ 068 ProjectBuildingResult build( Artifact projectArtifact, boolean allowStubModel, ProjectBuildingRequest request ) 069 throws ProjectBuildingException; 070 071 /** 072 * Builds a project descriptor for the specified model source. 073 * 074 * @param modelSource The source of the model to built the project descriptor from, must not be {@code null}. 075 * @param request The project building request that holds further parameters, must not be {@code null}. 076 * @return The result of the project building, never {@code null}. 077 * @throws ProjectBuildingException If the project descriptor could not be successfully built. 078 * 079 * @see ModelSource2 080 */ 081 ProjectBuildingResult build( ModelSource modelSource, ProjectBuildingRequest request ) 082 throws ProjectBuildingException; 083 084 /** 085 * Builds the projects for the specified POM files and optionally their children. 086 * 087 * @param pomFiles The POM files to build, must not be {@code null}. 088 * @param recursive {@code true} to recursively build sub modules referenced by the POM files, {@code false} to 089 * build only the specified POM files. 090 * @param request The project builder configuration that provides further parameters, must not be {@code null}. 091 * @return The results of the project builder where each result corresponds to one project that was built, never 092 * {@code null}. 093 * @throws ProjectBuildingException If an error was encountered during building of any project. 094 * {@link ProjectBuildingException#getResults()} provides access to the details of the problems. 095 */ 096 List<ProjectBuildingResult> build( List<File> pomFiles, boolean recursive, ProjectBuildingRequest request ) 097 throws ProjectBuildingException; 098 099}