001 package org.apache.maven.model.resolution; 002 003 /* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022 import org.apache.maven.model.Repository; 023 import org.apache.maven.model.building.ModelSource; 024 025 /** 026 * Resolves a POM from its coordinates. During the build process, the 027 * {@link org.apache.maven.model.building.ModelBuilder} will add any relevant repositories to the model resolver. In 028 * other words, the model resolver is stateful and should not be reused across multiple model building requests. 029 * 030 * @author Benjamin Bentmann 031 */ 032 public interface ModelResolver 033 { 034 035 /** 036 * Tries to resolve the POM for the specified coordinates. 037 * 038 * @param groupId The group identifier of the POM, must not be {@code null}. 039 * @param artifactId The artifact identifier of the POM, must not be {@code null}. 040 * @param version The version of the POM, must not be {@code null}. 041 * @return The source of the requested POM, never {@code null}. 042 * @throws UnresolvableModelException If the POM could not be resolved from any configured repository. 043 */ 044 ModelSource resolveModel( String groupId, String artifactId, String version ) 045 throws UnresolvableModelException; 046 047 /** 048 * Adds a repository to use for subsequent resolution requests. The order in which repositories are added matters, 049 * repositories that were added first should also be searched first. When multiple repositories with the same 050 * identifier are added, only the first repository being added will be used. 051 * 052 * @param repository The repository to add to the internal search chain, must not be {@code null}. 053 * @throws InvalidRepositoryException If the repository could not be added (e.g. due to invalid URL or layout). 054 */ 055 void addRepository( Repository repository ) 056 throws InvalidRepositoryException; 057 058 /** 059 * Clones this resolver for usage in a forked resolution process. In general, implementors need not provide a deep 060 * clone. The only requirement is that invocations of {@link #addRepository(Repository)} on the clone do not affect 061 * the state of the original resolver and vice versa. 062 * 063 * @return The cloned resolver, never {@code null}. 064 */ 065 ModelResolver newCopy(); 066 067 }