View Javadoc
1   package org.apache.maven.model.resolution;
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.model.Parent;
23  import org.apache.maven.model.Repository;
24  import org.apache.maven.model.building.ModelSource;
25  
26  /**
27   * Resolves a POM from its coordinates. During the build process, the
28   * {@link org.apache.maven.model.building.ModelBuilder} will add any relevant repositories to the model resolver. In
29   * other words, the model resolver is stateful and should not be reused across multiple model building requests.
30   *
31   * @author Benjamin Bentmann
32   */
33  public interface ModelResolver
34  {
35  
36      /**
37       * Tries to resolve the POM for the specified coordinates.
38       *
39       * @param groupId The group identifier of the POM, must not be {@code null}.
40       * @param artifactId The artifact identifier of the POM, must not be {@code null}.
41       * @param version The version of the POM, must not be {@code null}.
42       * @return The source of the requested POM, never {@code null}.
43       * @throws UnresolvableModelException If the POM could not be resolved from any configured repository.
44       */
45      ModelSource resolveModel( String groupId, String artifactId, String version )
46          throws UnresolvableModelException;
47  
48      /**
49       * Tries to resolve the POM for the specified parent coordinates possibly updating {@code parent}.
50       *
51       * @param parent The parent coordinates to resolve, must not be {@code null}.
52       * @return The source of the requested POM, never {@code null}.
53       * @throws UnresolvableModelException If the POM could not be resolved from any configured repository.
54       * @since 3.2.2
55       */
56      ModelSource resolveModel( Parent parent )
57          throws UnresolvableModelException;
58  
59      /**
60       * Adds a repository to use for subsequent resolution requests. The order in which repositories are added matters,
61       * repositories that were added first should also be searched first. When multiple repositories with the same
62       * identifier are added, only the first repository being added will be used.
63       *
64       * @param repository The repository to add to the internal search chain, must not be {@code null}.
65       * @throws InvalidRepositoryException If the repository could not be added (e.g. due to invalid URL or layout).
66       */
67      void addRepository( Repository repository )
68          throws InvalidRepositoryException;
69  
70      /**
71       * Resets repositories, has the effect of clearing any repositories previously added by the
72       * {link #addRepository(Repository) method
73       */
74      void resetRepositories();
75  
76      /**
77       * Clones this resolver for usage in a forked resolution process. In general, implementors need not provide a deep
78       * clone. The only requirement is that invocations of {@link #addRepository(Repository)} on the clone do not affect
79       * the state of the original resolver and vice versa.
80       *
81       * @return The cloned resolver, never {@code null}.
82       */
83      ModelResolver newCopy();
84  
85  }