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.util.graph.manager;
20  
21  import java.util.ArrayList;
22  import java.util.Collection;
23  
24  import org.eclipse.aether.collection.DependencyManager;
25  import org.eclipse.aether.graph.Exclusion;
26  import org.eclipse.aether.scope.ScopeManager;
27  import org.eclipse.aether.scope.SystemDependencyScope;
28  
29  /**
30   * A dependency manager managing dependencies on all levels supporting transitive dependency management.
31   * <p>
32   * <b>Note:</b>Unlike the {@code ClassicDependencyManager} and the {@code TransitiveDependencyManager} this
33   * implementation applies management also on the first level. This is considered the resolver's default behaviour.
34   * It ignores all management overrides supported by the {@code MavenModelBuilder}.
35   * <p>
36   * This manager has {@code deriveUntil=Integer.MAX_VALUE} and {@code applyFrom=0}.
37   *
38   * @author Christian Schulte
39   * @since 1.4.0
40   */
41  public final class DefaultDependencyManager extends AbstractDependencyManager {
42      /**
43       * Creates a new dependency manager without any management information.
44       *
45       * @deprecated Use constructor that provides consumer application specific predicate.
46       */
47      @Deprecated
48      public DefaultDependencyManager() {
49          this(null);
50      }
51  
52      public DefaultDependencyManager(ScopeManager scopeManager) {
53          super(Integer.MAX_VALUE, 0, scopeManager);
54      }
55  
56      @SuppressWarnings("checkstyle:ParameterNumber")
57      private DefaultDependencyManager(
58              ArrayList<AbstractDependencyManager> path,
59              int depth,
60              int deriveUntil,
61              int applyFrom,
62              MMap<Key, String> managedVersions,
63              MMap<Key, String> managedScopes,
64              MMap<Key, Boolean> managedOptionals,
65              MMap<Key, String> managedLocalPaths,
66              MMap<Key, Holder<Collection<Exclusion>>> managedExclusions,
67              SystemDependencyScope systemDependencyScope) {
68          super(
69                  path,
70                  depth,
71                  deriveUntil,
72                  applyFrom,
73                  managedVersions,
74                  managedScopes,
75                  managedOptionals,
76                  managedLocalPaths,
77                  managedExclusions,
78                  systemDependencyScope);
79      }
80  
81      @Override
82      protected DependencyManager newInstance(
83              MMap<Key, String> managedVersions,
84              MMap<Key, String> managedScopes,
85              MMap<Key, Boolean> managedOptionals,
86              MMap<Key, String> managedLocalPaths,
87              MMap<Key, Holder<Collection<Exclusion>>> managedExclusions) {
88          ArrayList<AbstractDependencyManager> path = new ArrayList<>(this.path);
89          path.add(this);
90          return new DefaultDependencyManager(
91                  path,
92                  depth + 1,
93                  deriveUntil,
94                  applyFrom,
95                  managedVersions,
96                  managedScopes,
97                  managedOptionals,
98                  managedLocalPaths,
99                  managedExclusions,
100                 systemDependencyScope);
101     }
102 }