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