001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.eclipse.aether.collection; 020 021import org.eclipse.aether.RepositorySystemSession; 022 023/** 024 * Dependency collector checker. It is able to check dependency collection result, deem it "satisfiable" or 025 * augment collection and re-execute it. 026 * 027 * @since 2.0.19 028 */ 029public interface DependencyCollectionChecker { 030 /** 031 * A default "no op" implementation. 032 */ 033 DependencyCollectionChecker NOOP = new DependencyCollectionChecker() {}; 034 035 /** 036 * Config property for collector checker suppression. Presence of this key will suppress collection checking. 037 * This key is not meant for users, but to programmatically signal collection suppression. 038 */ 039 String COLLECTOR_CHECKER_SUPPRESSED = "aether.dependencyCollector.checker.suppressed"; 040 041 /** 042 * Prepares for dependency collection. 043 * 044 * @param session The repository system session, must not be {@code null}. 045 * @param request The collect request about to be processed, must not be {@code null}. 046 * @return The session to use for the collection, possibly adapted by this checker. 047 */ 048 default RepositorySystemSession prepare(RepositorySystemSession session, CollectRequest request) { 049 return session; 050 } 051 052 /** 053 * Performs checks on finished dependency collection. It should return {@code true} if the collection was deemed 054 * "satisfactory". If should return {@code false} <em>only, if collection was not satisfactory, and checker 055 * was able to modify resolution parameters (to not repeat same work)</em>. In other cases (not satisfactory 056 * but no param change would help) it should throw {@link DependencyCollectionException}. 057 * 058 * @param session The repository system session, must not be {@code null}. 059 * @param request The collect request that was processed, must not be {@code null}. 060 * @param result The result of the dependency collection, must not be {@code null}. 061 * @return {@code true} if the collection result is satisfactory, {@code false} if the checker adjusted 062 * resolution parameters and collection should be repeated. 063 * @throws DependencyCollectionException If the collection is not satisfactory and cannot be remedied. 064 */ 065 default boolean isSatisfactory(RepositorySystemSession session, CollectRequest request, CollectResult result) 066 throws DependencyCollectionException { 067 return true; 068 } 069}