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       * @return The aggregated list of remote repositories, never {@code null}.
47       * @see RepositorySystemSession#getMirrorSelector()
48       * @see RepositorySystemSession#getProxySelector()
49       * @see RepositorySystemSession#getAuthenticationSelector()
50       */
51      List<RemoteRepository> aggregateRepositories(
52              RepositorySystemSession session,
53              List<RemoteRepository> dominantRepositories,
54              List<RemoteRepository> recessiveRepositories,
55              boolean recessiveIsRaw);
56  
57      /**
58       * Aggregates repository definitions by merging duplicate repositories and optionally applies mirror, proxy and
59       * authentication settings from the supplied session, additionally distinguishing the provenance of the recessive
60       * repository definitions. Repository definitions that originate from a remote artifact descriptor (i.e. a POM
61       * downloaded during dependency collection) are remotely supplied input: implementations may withhold session
62       * authentication from them unless an operator-defined mirror has been selected for them, so that session
63       * authentication is applied only to repositories the operator configured. Repository definitions supplied
64       * by the build itself (e.g. via
65       * {@code RepositorySystem#newResolutionRepositories}) must keep receiving mirror, proxy and authentication
66       * settings as documented for
67       * {@link #aggregateRepositories(RepositorySystemSession, List, List, boolean)}.
68       * <p>
69       * The default implementation ignores the provenance hint and delegates to
70       * {@link #aggregateRepositories(RepositorySystemSession, List, List, boolean)}.
71       *
72       * @param session The repository session during which the repositories will be accessed, must not be {@code null}.
73       * @param dominantRepositories The current list of remote repositories to merge the new definitions into, must not
74       *            be {@code null}.
75       * @param recessiveRepositories The remote repositories to merge into the existing list, must not be {@code null}.
76       * @param recessiveIsRaw {@code true} if the recessive repository definitions have not yet been subjected to mirror,
77       *            proxy and authentication settings, {@code false} otherwise.
78       * @param recessiveIsFromDescriptor {@code true} if the recessive repository definitions were declared by a remote
79       *            artifact descriptor (POM) rather than by the build itself, {@code false} otherwise.
80       * @return The aggregated list of remote repositories, never {@code null}.
81       * @since 2.0.23
82       * @see RepositorySystemSession#getMirrorSelector()
83       * @see RepositorySystemSession#getProxySelector()
84       * @see RepositorySystemSession#getAuthenticationSelector()
85       */
86      default List<RemoteRepository> aggregateRepositories(
87              RepositorySystemSession session,
88              List<RemoteRepository> dominantRepositories,
89              List<RemoteRepository> recessiveRepositories,
90              boolean recessiveIsRaw,
91              boolean recessiveIsFromDescriptor) {
92          return aggregateRepositories(session, dominantRepositories, recessiveRepositories, recessiveIsRaw);
93      }
94  
95      /**
96       * Gets the effective repository policy for the specified remote repository by merging the applicable
97       * snapshot/release policy of the repository with global settings from the supplied session.
98       *
99       * @param session The repository session during which the repository will be accessed, must not be {@code null}.
100      * @param repository The remote repository to determine the effective policy for, must not be {@code null}.
101      * @param releases {@code true} if the policy for release artifacts needs to be considered, {@code false} if not.
102      * @param snapshots {@code true} if the policy for snapshot artifacts needs to be considered, {@code false} if not.
103      * @return The effective repository policy, never {@code null}.
104      * @see RepositorySystemSession#getChecksumPolicy()
105      * @see RepositorySystemSession#getUpdatePolicy()
106      */
107     RepositoryPolicy getPolicy(
108             RepositorySystemSession session, RemoteRepository repository, boolean releases, boolean snapshots);
109 }