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