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.scope; 020 021import java.util.Collection; 022import java.util.Optional; 023 024import org.eclipse.aether.RepositorySystemSession; 025import org.eclipse.aether.collection.DependencySelector; 026import org.eclipse.aether.graph.DependencyFilter; 027 028/** 029 * Scope manager. 030 * 031 * @since 2.0.0 032 * 033 * @noimplement This interface is not intended to be implemented by clients. 034 * @noextend This interface is not intended to be extended by clients. 035 */ 036public interface ScopeManager { 037 /** 038 * The label. 039 * 040 * @return The identifier of this scope manager, never {@code null}. 041 */ 042 String getId(); 043 044 /** 045 * Returns the "system" scope, if exists. 046 * <p> 047 * This is a special scope. In this scope case, Resolver should handle it specially, as it has no POM (so is 048 * always a leaf on graph), is not in any repository, but is actually hosted on host OS file system. On resolution 049 * resolver merely checks is file present or not. 050 * 051 * @return The system dependency scope, or an empty optional if this manager has no such scope. 052 */ 053 Optional<SystemDependencyScope> getSystemDependencyScope(); 054 055 /** 056 * Returns a specific dependency scope by label. 057 * <p> 058 * Note: despite returns optional, this method may throw as well, if manager set in "strict" mode. 059 * 060 * @param id The label of the dependency scope, must not be {@code null}. 061 * @return The dependency scope with the given label, or an empty optional if no such scope exists. 062 */ 063 Optional<DependencyScope> getDependencyScope(String id); 064 065 /** 066 * Returns the "universe" (all) of dependency scopes as immutable collection. 067 * 068 * @return The immutable collection of all known dependency scopes, never {@code null}. 069 */ 070 Collection<DependencyScope> getDependencyScopeUniverse(); 071 072 /** 073 * Returns a specific resolution scope by label. 074 * <p> 075 * Note: despite returns optional, this method may throw as well, if manager set in "strict" mode. 076 * 077 * @param id The label of the resolution scope, must not be {@code null}. 078 * @return The resolution scope with the given label, or an empty optional if no such scope exists. 079 */ 080 Optional<ResolutionScope> getResolutionScope(String id); 081 082 /** 083 * Returns the "universe" (all) of resolution scopes as immutable collection. 084 * 085 * @return The immutable collection of all known resolution scopes, never {@code null}. 086 */ 087 Collection<ResolutionScope> getResolutionScopeUniverse(); 088 089 /** 090 * Resolver scope configuration specific: dependency selector to be used to support this scope (with its dependency 091 * and resolution scopes). 092 * <p> 093 * Important: Resolver 2.x when used with {@link ScopeManager}, the scope semantics is defined by client code. 094 * Hence, the scopes cannot be interpreted with fixed logic as it was the case in Maven 3.9 and before, instead 095 * the {@link ScopeManager} has to be asked to create selector based on scope configuration. 096 * 097 * @param session The repository system session, must not be {@code null}. 098 * @param resolutionScope The resolution scope to create the selector for, must not be {@code null}. 099 * @return The dependency selector supporting the given resolution scope, never {@code null}. 100 */ 101 DependencySelector getDependencySelector(RepositorySystemSession session, ResolutionScope resolutionScope); 102 103 /** 104 * Resolver scope configuration specific: dependency filter to be used to support this scope (with its dependency 105 * and resolution scopes). 106 * <p> 107 * Important: Resolver 2.x when used with {@link ScopeManager}, the scope semantics is defined by client code. 108 * Hence, the scopes cannot be interpreted with fixed logic as it was the case in Maven 3.9 and before, instead 109 * the {@link ScopeManager} has to be asked to create filter based on scope configuration. 110 * 111 * @param session The repository system session, must not be {@code null}. 112 * @param resolutionScope The resolution scope to create the filter for, must not be {@code null}. 113 * @return The dependency filter supporting the given resolution scope, never {@code null}. 114 */ 115 DependencyFilter getDependencyFilter(RepositorySystemSession session, ResolutionScope resolutionScope); 116}