View Javadoc
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.util.List;
22  
23  import org.apache.maven.api.DependencyCoordinate;
24  import org.apache.maven.api.Node;
25  import org.apache.maven.api.Project;
26  import org.apache.maven.api.ResolutionScope;
27  import org.apache.maven.api.Service;
28  import org.apache.maven.api.Session;
29  import org.apache.maven.api.annotations.Experimental;
30  import org.apache.maven.api.annotations.Nonnull;
31  
32  /**
33   * Collects, flattens and resolves dependencies.
34   */
35  @Experimental
36  public interface DependencyResolver extends Service {
37  
38      List<Node> flatten(Session session, Node node, ResolutionScope scope) throws DependencyResolverException;
39  
40      /**
41       * This method collects, flattens and resolves the dependencies.
42       *
43       * @param request the request to resolve
44       * @return the result of the resolution
45       * @throws DependencyCollectorException
46       * @throws DependencyResolverException
47       * @throws ArtifactResolverException
48       *
49       * @see DependencyCollector#collect(DependencyCollectorRequest)
50       * @see #flatten(Session, Node, ResolutionScope)
51       * @see ArtifactResolver#resolve(ArtifactResolverRequest)
52       */
53      DependencyResolverResult resolve(DependencyResolverRequest request)
54              throws DependencyCollectorException, DependencyResolverException, ArtifactResolverException;
55  
56      @Nonnull
57      default DependencyResolverResult resolve(@Nonnull Session session, @Nonnull Project project) {
58          return resolve(DependencyResolverRequest.build(session, project));
59      }
60  
61      @Nonnull
62      default DependencyResolverResult resolve(
63              @Nonnull Session session, @Nonnull Project project, @Nonnull ResolutionScope scope) {
64          return resolve(DependencyResolverRequest.build(session, project, scope));
65      }
66  
67      @Nonnull
68      default DependencyResolverResult resolve(@Nonnull Session session, @Nonnull DependencyCoordinate dependency) {
69          return resolve(DependencyResolverRequest.build(session, dependency));
70      }
71  
72      @Nonnull
73      default DependencyResolverResult resolve(
74              @Nonnull Session session, @Nonnull DependencyCoordinate dependency, @Nonnull ResolutionScope scope) {
75          return resolve(DependencyResolverRequest.build(session, dependency, scope));
76      }
77  
78      @Nonnull
79      default DependencyResolverResult resolve(
80              @Nonnull Session session, @Nonnull List<DependencyCoordinate> dependencies) {
81          return resolve(DependencyResolverRequest.build(session, dependencies));
82      }
83  
84      @Nonnull
85      default DependencyResolverResult resolve(
86              @Nonnull Session session,
87              @Nonnull List<DependencyCoordinate> dependencies,
88              @Nonnull ResolutionScope scope) {
89          return resolve(DependencyResolverRequest.build(session, dependencies, scope));
90      }
91  }