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.eclipse.aether.impl;
20  
21  import java.util.List;
22  
23  import org.eclipse.aether.RepositorySystemSession;
24  import org.eclipse.aether.repository.RemoteRepository;
25  import org.eclipse.aether.repository.RepositoryPolicy;
26  
27  /**
28   * Helps dealing with remote repository definitions.
29   *
30   * @noimplement This interface is not intended to be implemented by clients.
31   * @noextend This interface is not intended to be extended by clients.
32   * @provisional This type is provisional and can be changed, moved or removed without prior notice.
33   */
34  public interface RemoteRepositoryManager {
35  
36      /**
37       * Aggregates repository definitions by merging duplicate repositories and optionally applies mirror, proxy and
38       * authentication settings from the supplied session.
39       *
40       * @param session The repository session during which the repositories will be accessed, must not be {@code null}.
41       * @param dominantRepositories The current list of remote repositories to merge the new definitions into, must not
42       *            be {@code null}.
43       * @param recessiveRepositories The remote repositories to merge into the existing list, must not be {@code null}.
44       * @param recessiveIsRaw {@code true} if the recessive repository definitions have not yet been subjected to mirror,
45       *            proxy and authentication settings, {@code false} otherwise.
46       *            Repositories that already list mirrored repositories are not subjected to mirror selection again,
47       *            while proxy and authentication selection still apply.
48       * @return The aggregated list of remote repositories, never {@code null}.
49       * @see RepositorySystemSession#getMirrorSelector()
50       * @see RepositorySystemSession#getProxySelector()
51       * @see RepositorySystemSession#getAuthenticationSelector()
52       */
53      List<RemoteRepository> aggregateRepositories(
54              RepositorySystemSession session,
55              List<RemoteRepository> dominantRepositories,
56              List<RemoteRepository> recessiveRepositories,
57              boolean recessiveIsRaw);
58  
59      /**
60       * Aggregates repository definitions by merging duplicate repositories and optionally applies mirror, proxy and
61       * authentication settings from the supplied session, additionally distinguishing the provenance of the recessive
62       * repository definitions. Repository definitions that originate from a remote artifact descriptor (i.e. a POM
63       * downloaded during dependency collection) are remotely supplied input: implementations may withhold session
64       * authentication from them unless an operator-defined mirror has been selected for them, so that session
65       * authentication is applied only to repositories the operator configured. Repository definitions supplied
66       * by the build itself (e.g. via
67       * {@code RepositorySystem#newResolutionRepositories}) must keep receiving mirror, proxy and authentication
68       * settings as documented for
69       * {@link #aggregateRepositories(RepositorySystemSession, List, List, boolean)}.
70       * <p>
71       * The default implementation ignores the provenance hint and delegates to
72       * {@link #aggregateRepositories(RepositorySystemSession, List, List, boolean)}.
73       *
74       * @param session The repository session during which the repositories will be accessed, must not be {@code null}.
75       * @param dominantRepositories The current list of remote repositories to merge the new definitions into, must not
76       *            be {@code null}.
77       * @param recessiveRepositories The remote repositories to merge into the existing list, must not be {@code null}.
78       * @param recessiveIsRaw {@code true} if the recessive repository definitions have not yet been subjected to mirror,
79       *            proxy and authentication settings, {@code false} otherwise.
80       *            Repositories that already list mirrored repositories are not subjected to mirror selection again
81       *            unless they are declared by a remote artifact descriptor; proxy and authentication selection still apply.
82       * @param recessiveIsFromDescriptor {@code true} if the recessive repository definitions were declared by a remote
83       *            artifact descriptor (POM) rather than by the build itself, {@code false} otherwise.
84       * @return The aggregated list of remote repositories, never {@code null}.
85       * @since 2.0.23
86       * @see RepositorySystemSession#getMirrorSelector()
87       * @see RepositorySystemSession#getProxySelector()
88       * @see RepositorySystemSession#getAuthenticationSelector()
89       */
90      default List<RemoteRepository> aggregateRepositories(
91              RepositorySystemSession session,
92              List<RemoteRepository> dominantRepositories,
93              List<RemoteRepository> recessiveRepositories,
94              boolean recessiveIsRaw,
95              boolean recessiveIsFromDescriptor) {
96          return aggregateRepositories(session, dominantRepositories, recessiveRepositories, recessiveIsRaw);
97      }
98  
99      /**
100      * Gets the effective repository policy for the specified remote repository by merging the applicable
101      * snapshot/release policy of the repository with global settings from the supplied session.
102      *
103      * @param session The repository session during which the repository will be accessed, must not be {@code null}.
104      * @param repository The remote repository to determine the effective policy for, must not be {@code null}.
105      * @param releases {@code true} if the policy for release artifacts needs to be considered, {@code false} if not.
106      * @param snapshots {@code true} if the policy for snapshot artifacts needs to be considered, {@code false} if not.
107      * @return The effective repository policy, never {@code null}.
108      * @see RepositorySystemSession#getChecksumPolicy()
109      * @see RepositorySystemSession#getUpdatePolicy()
110      */
111     RepositoryPolicy getPolicy(
112             RepositorySystemSession session, RemoteRepository repository, boolean releases, boolean snapshots);
113 }