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.apache.maven.repository.internal;
20  
21  import org.eclipse.aether.DefaultRepositorySystemSession;
22  import org.eclipse.aether.util.graph.manager.ClassicDependencyManager;
23  
24  /**
25   * A utility class to assist in setting up a Maven-like repository system. <em>Note:</em> This component is meant to
26   * assist those clients that employ the repository system outside of an IoC container, Maven plugins should instead
27   * always use regular dependency injection to acquire the repository system.
28   *
29   * @deprecated See {@link MavenSessionBuilderSupplier}
30   */
31  @Deprecated
32  public final class MavenRepositorySystemUtils {
33  
34      private MavenRepositorySystemUtils() {
35          // hide constructor
36      }
37  
38      /**
39       * This method is deprecated, nobody should use it.
40       *
41       * @deprecated This method is here only for legacy uses (like UTs), nothing else should use it.
42       */
43      @Deprecated
44      public static DefaultRepositorySystemSession newSession() {
45          DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(h -> false); // no close handle
46          MavenSessionBuilderSupplier builder = new MavenSessionBuilderSupplier();
47          session.setDependencyTraverser(builder.getDependencyTraverser());
48          session.setDependencyManager(new ClassicDependencyManager()); // Maven 3 behavior
49          session.setDependencySelector(builder.getDependencySelector());
50          session.setDependencyGraphTransformer(builder.getDependencyGraphTransformer());
51          session.setArtifactTypeRegistry(builder.getArtifactTypeRegistry());
52          session.setArtifactDescriptorPolicy(builder.getArtifactDescriptorPolicy());
53          return session;
54      }
55  }