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.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.CollectResult;
26  import org.eclipse.aether.collection.DependencySelector;
27  import org.eclipse.aether.scope.DependencyScope;
28  import org.eclipse.aether.scope.ResolutionScope;
29  import org.eclipse.aether.scope.ScopeManager;
30  import org.eclipse.aether.scope.SystemDependencyScope;
31  
32  /**
33   * Internal scope manager.
34   *
35   * @since 2.0.0
36   */
37  public interface InternalScopeManager extends ScopeManager {
38      /**
39       * The "width" of scope: is basically sum of all distinct {@link ProjectPath} and {@link BuildPath} that are
40       * in build scopes the scope is present in. The more of them, the "wider" is the scope. Transitive scopes are
41       * weighted more as well.
42       * <p>
43       * The {@link ProjectPath#order()} makes given path "weigh" more. So a scope being present only in
44       * "main" project path is wider than scope being present only in "test" project path.
45       * <p>
46       * Interpretation: the bigger the returned integer is, the "wider" the scope is. The numbers should not serve
47       * any other purposes, merely to sort scope instances by "width" (i.e. from "widest" to "narrowest").
48       */
49      int getDependencyScopeWidth(DependencyScope dependencyScope);
50  
51      /**
52       * Returns the {@link BuildScope} that this scope deem as main.
53       */
54      Optional<BuildScope> getDependencyScopeMainProjectBuildScope(DependencyScope dependencyScope);
55  
56      /**
57       * Resolver specific: dependency selector to be used to support this scope (with its dependency
58       * and resolution scopes).
59       */
60      DependencySelector getDependencySelector(RepositorySystemSession session, ResolutionScope resolutionScope);
61  
62      /**
63       * Resolver specific: post-processing to be used to support this scope (with its dependency
64       * and resolution scopes).
65       */
66      CollectResult postProcess(
67              RepositorySystemSession session, ResolutionScope resolutionScope, CollectResult collectResult);
68  
69      /**
70       * The mode of resolution scope: eliminate (remove all occurrences) or just remove.
71       */
72      enum Mode {
73          /**
74           * Mode where artifacts in non-wanted scopes are completely eliminated. In other words, this mode ensures
75           * that if a dependency was removed due unwanted scope, it is guaranteed that no such dependency will appear
76           * anywhere else in the resulting graph either.
77           */
78          ELIMINATE,
79  
80          /**
81           * Mode where artifacts in non-wanted scopes are removed only. In other words, they will NOT prevent (as in
82           * they will not "dominate") other possibly appearing occurrences of same artifact in the graph.
83           */
84          REMOVE
85      }
86  
87      /**
88       * Creates dependency scope instance.
89       * <p>
90       * Should be invoked only via {@link ScopeManagerConfiguration#buildDependencyScopes(InternalScopeManager)}.
91       */
92      DependencyScope createDependencyScope(String id, boolean transitive, Collection<BuildScopeQuery> presence);
93  
94      /**
95       * Creates system dependency scope instance. This method may be invoked only once, as there can be only one
96       * instance of {@link SystemDependencyScope}!
97       * <p>
98       * Should be invoked only via {@link ScopeManagerConfiguration#buildDependencyScopes(InternalScopeManager)}.
99       */
100     SystemDependencyScope createSystemDependencyScope(
101             String id, boolean transitive, Collection<BuildScopeQuery> presence, String systemPathProperty);
102 
103     /**
104      * Creates resolution scope instance.
105      * <p>
106      * Should be invoked only via {@link ScopeManagerConfiguration#buildResolutionScopes(InternalScopeManager)}.
107      */
108     ResolutionScope createResolutionScope(
109             String id,
110             Mode mode,
111             Collection<BuildScopeQuery> wantedPresence,
112             Collection<DependencyScope> explicitlyIncluded,
113             Collection<DependencyScope> transitivelyExcluded);
114 }