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.api.services; 20 21 import java.nio.file.Path; 22 23 import org.apache.maven.api.Artifact; 24 import org.apache.maven.api.ArtifactCoordinate; 25 import org.apache.maven.api.Service; 26 import org.apache.maven.api.Session; 27 import org.apache.maven.api.annotations.Experimental; 28 import org.apache.maven.api.annotations.Nonnull; 29 30 /** 31 * @since 4.0 32 */ 33 @Experimental 34 public interface ProjectBuilder extends Service { 35 36 /** 37 * Creates a {@link org.apache.maven.api.Project} from a POM file. 38 * 39 * @param request {@link ProjectBuilderRequest} 40 * @return the {@link ProjectBuilderResult} containing the built project and possible errors 41 * @throws ProjectBuilderException if the project cannot be created 42 * @throws IllegalArgumentException if an argument is {@code null} or invalid 43 */ 44 @Nonnull 45 ProjectBuilderResult build(ProjectBuilderRequest request); 46 47 /** 48 * Creates a {@link org.apache.maven.api.Project} from a POM file. 49 * 50 * @param session the {@link Session}, must not be {@code null} 51 * @param source The {@link Source}, must not be {@code null} 52 * @throws ProjectBuilderException if the project cannot be created 53 * @throws IllegalArgumentException if an argument is {@code null} or invalid 54 * @see #build(ProjectBuilderRequest) 55 */ 56 @Nonnull 57 default ProjectBuilderResult build(@Nonnull Session session, @Nonnull Source source) { 58 return build(ProjectBuilderRequest.build(session, source)); 59 } 60 61 /** 62 * Creates a {@link org.apache.maven.api.Project} from a POM file. 63 * 64 * @param session the {@link Session}, must not be {@code null} 65 * @param path the {@link Path}, must not be {@code null} 66 * @throws ProjectBuilderException if the project cannot be created 67 * @throws IllegalArgumentException if an argument is {@code null} or invalid 68 * @see #build(ProjectBuilderRequest) 69 */ 70 @Nonnull 71 default ProjectBuilderResult build(@Nonnull Session session, @Nonnull Path path) { 72 return build(ProjectBuilderRequest.build(session, path)); 73 } 74 75 /** 76 * Creates a {@link org.apache.maven.api.Project} from an artifact. 77 * 78 * @param session the {@link Session}, must not be {@code null} 79 * @param artifact the {@link Artifact}, must not be {@code null} 80 * @throws ProjectBuilderException if the project cannot be created 81 * @throws IllegalArgumentException if an argument is {@code null} or invalid 82 * @see #build(ProjectBuilderRequest) 83 */ 84 @Nonnull 85 default ProjectBuilderResult build(@Nonnull Session session, @Nonnull Artifact artifact) { 86 return build(ProjectBuilderRequest.build(session, artifact)); 87 } 88 89 /** 90 * Creates a {@link org.apache.maven.api.Project} from a coordinate. 91 * 92 * @param session the {@link Session}, must not be {@code null} 93 * @param coordinate the {@link ArtifactCoordinate}, must not be {@code null} 94 * @throws ProjectBuilderException if the project cannot be created 95 * @throws IllegalArgumentException if an argument is {@code null} or invalid 96 * @see #build(ProjectBuilderRequest) 97 */ 98 @Nonnull 99 default ProjectBuilderResult build(@Nonnull Session session, @Nonnull ArtifactCoordinate coordinate) { 100 return build(ProjectBuilderRequest.build(session, coordinate)); 101 } 102 }