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