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 transitive dependencies supporting transitive dependency management.
31   * <p>
32   * This manager is similar to "classic", it has {@code deriveUntil=Integer.MAX_VALUE} (unlike 2 as in "classic") and
33   * {@code applyFrom=2}.
34   *
35   * @author Christian Schulte
36   * @since 1.4.0
37   */
38  public final class TransitiveDependencyManager extends AbstractDependencyManager {
39      /**
40       * Creates a new dependency manager without any management information.
41       *
42       * @deprecated Use constructor that provides consumer application specific predicate.
43       */
44      @Deprecated
45      public TransitiveDependencyManager() {
46          this(null);
47      }
48  
49      public TransitiveDependencyManager(ScopeManager scopeManager) {
50          super(Integer.MAX_VALUE, 2, scopeManager);
51      }
52  
53      @SuppressWarnings("checkstyle:ParameterNumber")
54      private TransitiveDependencyManager(
55              ArrayList<AbstractDependencyManager> path,
56              int depth,
57              int deriveUntil,
58              int applyFrom,
59              MMap<Key, String> managedVersions,
60              MMap<Key, String> managedScopes,
61              MMap<Key, Boolean> managedOptionals,
62              MMap<Key, String> managedLocalPaths,
63              MMap<Key, Holder<Collection<Exclusion>>> managedExclusions,
64              SystemDependencyScope systemDependencyScope) {
65          super(
66                  path,
67                  depth,
68                  deriveUntil,
69                  applyFrom,
70                  managedVersions,
71                  managedScopes,
72                  managedOptionals,
73                  managedLocalPaths,
74                  managedExclusions,
75                  systemDependencyScope);
76      }
77  
78      @Override
79      protected DependencyManager newInstance(
80              MMap<Key, String> managedVersions,
81              MMap<Key, String> managedScopes,
82              MMap<Key, Boolean> managedOptionals,
83              MMap<Key, String> managedLocalPaths,
84              MMap<Key, Holder<Collection<Exclusion>>> managedExclusions) {
85          ArrayList<AbstractDependencyManager> path = new ArrayList<>(this.path);
86          path.add(this);
87          return new TransitiveDependencyManager(
88                  path,
89                  depth + 1,
90                  deriveUntil,
91                  applyFrom,
92                  managedVersions,
93                  managedScopes,
94                  managedOptionals,
95                  managedLocalPaths,
96                  managedExclusions,
97                  systemDependencyScope);
98      }
99  }