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.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       * @param session The repository system session, must not be {@code null}.
45       * @param request The collect request about to be processed, must not be {@code null}.
46       * @return The session to use for the collection, possibly adapted by this checker.
47       */
48      default RepositorySystemSession prepare(RepositorySystemSession session, CollectRequest request) {
49          return session;
50      }
51  
52      /**
53       * Performs checks on finished dependency collection. It should return {@code true} if the collection was deemed
54       * "satisfactory". If should return {@code false} <em>only, if collection was not satisfactory, and checker
55       * was able to modify resolution parameters (to not repeat same work)</em>. In other cases (not satisfactory
56       * but no param change would help) it should throw {@link DependencyCollectionException}.
57       *
58       * @param session The repository system session, must not be {@code null}.
59       * @param request The collect request that was processed, must not be {@code null}.
60       * @param result The result of the dependency collection, must not be {@code null}.
61       * @return {@code true} if the collection result is satisfactory, {@code false} if the checker adjusted
62       *         resolution parameters and collection should be repeated.
63       * @throws DependencyCollectionException If the collection is not satisfactory and cannot be remedied.
64       */
65      default boolean isSatisfactory(RepositorySystemSession session, CollectRequest request, CollectResult result)
66              throws DependencyCollectionException {
67          return true;
68      }
69  }