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.scope;
20  
21  import java.util.Collection;
22  import java.util.Optional;
23  
24  import org.eclipse.aether.RepositorySystemSession;
25  import org.eclipse.aether.collection.DependencySelector;
26  import org.eclipse.aether.graph.DependencyFilter;
27  
28  /**
29   * Scope manager.
30   *
31   * @since 2.0.0
32   *
33   * @noimplement This interface is not intended to be implemented by clients.
34   * @noextend This interface is not intended to be extended by clients.
35   */
36  public interface ScopeManager {
37      /**
38       * The label.
39       *
40       * @return The identifier of this scope manager, never {@code null}.
41       */
42      String getId();
43  
44      /**
45       * Returns the "system" scope, if exists.
46       * <p>
47       * This is a special scope. In this scope case, Resolver should handle it specially, as it has no POM (so is
48       * always a leaf on graph), is not in any repository, but is actually hosted on host OS file system. On resolution
49       * resolver merely checks is file present or not.
50       *
51       * @return The system dependency scope, or an empty optional if this manager has no such scope.
52       */
53      Optional<SystemDependencyScope> getSystemDependencyScope();
54  
55      /**
56       * Returns a specific dependency scope by label.
57       * <p>
58       * Note: despite returns optional, this method may throw as well, if manager set in "strict" mode.
59       *
60       * @param id The label of the dependency scope, must not be {@code null}.
61       * @return The dependency scope with the given label, or an empty optional if no such scope exists.
62       */
63      Optional<DependencyScope> getDependencyScope(String id);
64  
65      /**
66       * Returns the "universe" (all) of dependency scopes as immutable collection.
67       *
68       * @return The immutable collection of all known dependency scopes, never {@code null}.
69       */
70      Collection<DependencyScope> getDependencyScopeUniverse();
71  
72      /**
73       * Returns a specific resolution scope by label.
74       * <p>
75       * Note: despite returns optional, this method may throw as well, if manager set in "strict" mode.
76       *
77       * @param id The label of the resolution scope, must not be {@code null}.
78       * @return The resolution scope with the given label, or an empty optional if no such scope exists.
79       */
80      Optional<ResolutionScope> getResolutionScope(String id);
81  
82      /**
83       * Returns the "universe" (all) of resolution scopes as immutable collection.
84       *
85       * @return The immutable collection of all known resolution scopes, never {@code null}.
86       */
87      Collection<ResolutionScope> getResolutionScopeUniverse();
88  
89      /**
90       * Resolver scope configuration specific: dependency selector to be used to support this scope (with its dependency
91       * and resolution scopes).
92       * <p>
93       * Important: Resolver 2.x when used with {@link ScopeManager}, the scope semantics is defined by client code.
94       * Hence, the scopes cannot be interpreted with fixed logic as it was the case in Maven 3.9 and before, instead
95       * the {@link ScopeManager} has to be asked to create selector based on scope configuration.
96       *
97       * @param session The repository system session, must not be {@code null}.
98       * @param resolutionScope The resolution scope to create the selector for, must not be {@code null}.
99       * @return The dependency selector supporting the given resolution scope, never {@code null}.
100      */
101     DependencySelector getDependencySelector(RepositorySystemSession session, ResolutionScope resolutionScope);
102 
103     /**
104      * Resolver scope configuration specific: dependency filter to be used to support this scope (with its dependency
105      * and resolution scopes).
106      * <p>
107      * Important: Resolver 2.x when used with {@link ScopeManager}, the scope semantics is defined by client code.
108      * Hence, the scopes cannot be interpreted with fixed logic as it was the case in Maven 3.9 and before, instead
109      * the {@link ScopeManager} has to be asked to create filter based on scope configuration.
110      *
111      * @param session The repository system session, must not be {@code null}.
112      * @param resolutionScope The resolution scope to create the filter for, must not be {@code null}.
113      * @return The dependency filter supporting the given resolution scope, never {@code null}.
114      */
115     DependencyFilter getDependencyFilter(RepositorySystemSession session, ResolutionScope resolutionScope);
116 }