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.util.graph.manager;
020
021import java.util.Collection;
022import java.util.Map;
023
024import org.eclipse.aether.collection.DependencyManager;
025import org.eclipse.aether.graph.Exclusion;
026import org.eclipse.aether.scope.ScopeManager;
027import org.eclipse.aether.scope.SystemDependencyScope;
028
029/**
030 * A dependency manager managing dependencies on all levels supporting transitive dependency management.
031 * <p>
032 * <b>Note:</b>Unlike the {@code ClassicDependencyManager} and the {@code TransitiveDependencyManager} this
033 * implementation applies management also on the first level. This is considered the resolver's default behaviour.
034 * It ignores all management overrides supported by the {@code MavenModelBuilder}.
035 * <p>
036 * This manager has {@code deriveUntil=Integer.MAX_VALUE} and {@code applyFrom=0}.
037 *
038 * @author Christian Schulte
039 * @since 1.4.0
040 */
041public final class DefaultDependencyManager extends AbstractDependencyManager {
042    /**
043     * Creates a new dependency manager without any management information.
044     *
045     * @deprecated Use constructor that provides consumer application specific predicate.
046     */
047    @Deprecated
048    public DefaultDependencyManager() {
049        this(null);
050    }
051
052    public DefaultDependencyManager(ScopeManager scopeManager) {
053        super(Integer.MAX_VALUE, 0, scopeManager);
054    }
055
056    @SuppressWarnings("checkstyle:ParameterNumber")
057    private DefaultDependencyManager(
058            int depth,
059            int deriveUntil,
060            int applyFrom,
061            Map<Object, Holder<String>> managedVersions,
062            Map<Object, Holder<String>> managedScopes,
063            Map<Object, Holder<Boolean>> managedOptionals,
064            Map<Object, Holder<String>> managedLocalPaths,
065            Map<Object, Collection<Holder<Collection<Exclusion>>>> managedExclusions,
066            SystemDependencyScope systemDependencyScope) {
067        super(
068                depth,
069                deriveUntil,
070                applyFrom,
071                managedVersions,
072                managedScopes,
073                managedOptionals,
074                managedLocalPaths,
075                managedExclusions,
076                systemDependencyScope);
077    }
078
079    @Override
080    protected DependencyManager newInstance(
081            Map<Object, Holder<String>> managedVersions,
082            Map<Object, Holder<String>> managedScopes,
083            Map<Object, Holder<Boolean>> managedOptionals,
084            Map<Object, Holder<String>> managedLocalPaths,
085            Map<Object, Collection<Holder<Collection<Exclusion>>>> managedExclusions) {
086        return new DefaultDependencyManager(
087                depth + 1,
088                deriveUntil,
089                applyFrom,
090                managedVersions,
091                managedScopes,
092                managedOptionals,
093                managedLocalPaths,
094                managedExclusions,
095                systemDependencyScope);
096    }
097}