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.collection;
20
21 import org.eclipse.aether.RepositorySystemSession;
22
23 /**
24 * Dependency collector checker. It is able to check dependency collection result, deem it "satisfiable" or
25 * augment collection and re-execute it.
26 *
27 * @since 2.0.19
28 */
29 public interface DependencyCollectionChecker {
30 /**
31 * A default "no op" implementation.
32 */
33 DependencyCollectionChecker NOOP = new DependencyCollectionChecker() {};
34
35 /**
36 * Config property for collector checker suppression. Presence of this key will suppress collection checking.
37 * This key is not meant for users, but to programmatically signal collection suppression.
38 */
39 String COLLECTOR_CHECKER_SUPPRESSED = "aether.dependencyCollector.checker.suppressed";
40
41 /**
42 * Prepares for dependency collection.
43 */
44 default RepositorySystemSession prepare(RepositorySystemSession session, CollectRequest request) {
45 return session;
46 }
47
48 /**
49 * Performs checks on finished dependency collection. It should return {@code true} if the collection was deemed
50 * "satisfactory". If should return {@code false} <em>only, if collection was not satisfactory, and checker
51 * was able to modify resolution parameters (to not repeat same work)</em>. In other cases (not satisfactory
52 * but no param change would help) it should throw {@link DependencyCollectionException}.
53 */
54 default boolean isSatisfactory(RepositorySystemSession session, CollectRequest request, CollectResult result)
55 throws DependencyCollectionException {
56 return true;
57 }
58 }