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.Dependency; 23 import org.apache.maven.model.Parent; 24 import org.apache.maven.model.Repository; 25 import org.apache.maven.model.building.ModelSource; 26 27 /** 28 * Resolves a POM from its coordinates. During the build process, the 29 * {@link org.apache.maven.model.building.ModelBuilder} will add any relevant repositories to the model resolver. In 30 * other words, the model resolver is stateful and should not be reused across multiple model building requests. 31 * 32 * @author Benjamin Bentmann 33 */ 34 public interface ModelResolver 35 { 36 37 /** 38 * Tries to resolve the POM for the specified coordinates. 39 * 40 * @param groupId The group identifier of the POM, must not be {@code null}. 41 * @param artifactId The artifact identifier of the POM, must not be {@code null}. 42 * @param version The version of the POM, must not be {@code null}. 43 * @return The source of the requested POM, never {@code null}. 44 * @throws UnresolvableModelException If the POM could not be resolved from any configured repository. 45 */ 46 ModelSource resolveModel( String groupId, String artifactId, String version ) 47 throws UnresolvableModelException; 48 49 /** 50 * Tries to resolve the POM for the specified parent coordinates possibly updating {@code parent}. 51 * <p> 52 * Unlike the {@link #resolveModel(java.lang.String, java.lang.String, java.lang.String)} method, this method 53 * supports version ranges and updates the given {@code parent} instance to match the returned {@code ModelSource}. 54 * If {@code parent} declares a version range, the version corresponding to the returned {@code ModelSource} will 55 * be set on the given {@code parent}. 56 * </p> 57 * 58 * @param parent The parent coordinates to resolve, must not be {@code null}. 59 * 60 * @return The source of the requested POM, never {@code null}. 61 * 62 * @throws UnresolvableModelException If the POM could not be resolved from any configured repository. 63 * @since 3.2.2 64 * 65 * @see Parent#clone() 66 */ 67 ModelSource resolveModel( Parent parent ) 68 throws UnresolvableModelException; 69 70 /** 71 * Tries to resolve the POM for the specified dependency coordinates possibly updating {@code dependency}. 72 * <p> 73 * Unlike the {@link #resolveModel(java.lang.String, java.lang.String, java.lang.String)} method, this method 74 * supports version ranges and updates the given {@code dependency} instance to match the returned 75 * {@code ModelSource}. If {@code dependency} declares a version range, the version corresponding to the returned 76 * {@code ModelSource} will be set on the given {@code dependency}. 77 * </p> 78 * 79 * @param dependency The dependency coordinates to resolve, must not be {@code null}. 80 * 81 * @return The source of the requested POM, never {@code null}. 82 * 83 * @throws UnresolvableModelException If the POM could not be resolved from any configured repository. 84 * @since 3.5.0 85 * 86 * @see Dependency#clone() 87 */ 88 ModelSource resolveModel( Dependency dependency ) 89 throws UnresolvableModelException; 90 91 /** 92 * Adds a repository to use for subsequent resolution requests. The order in which repositories are added matters, 93 * repositories that were added first should also be searched first. When multiple repositories with the same 94 * identifier are added, only the first repository being added will be used. 95 * 96 * @param repository The repository to add to the internal search chain, must not be {@code null}. 97 * @throws InvalidRepositoryException If the repository could not be added (e.g. due to invalid URL or layout). 98 */ 99 void addRepository( Repository repository ) 100 throws InvalidRepositoryException; 101 102 /** 103 * Adds a repository to use for subsequent resolution requests. The order in which repositories are added matters, 104 * repositories that were added first should also be searched first. When multiple repositories with the same 105 * identifier are added, then the value of the replace argument is determines the behaviour. 106 * 107 * If replace is false than any existing repository with the same Id will remain in use. If replace 108 * is true the new repository replaces the original. 109 * 110 * @param repository The repository to add to the internal search chain, must not be {@code null}. 111 * @throws InvalidRepositoryException If the repository could not be added (e.g. due to invalid URL or layout). 112 */ 113 void addRepository( Repository repository, boolean replace ) 114 throws InvalidRepositoryException; 115 116 /** 117 * Clones this resolver for usage in a forked resolution process. In general, implementors need not provide a deep 118 * clone. The only requirement is that invocations of {@link #addRepository(Repository)} on the clone do not affect 119 * the state of the original resolver and vice versa. 120 * 121 * @return The cloned resolver, never {@code null}. 122 */ 123 ModelResolver newCopy(); 124 125 }