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.internal.impl;
20  
21  import java.util.Collection;
22  import java.util.List;
23  
24  import org.apache.maven.api.Artifact;
25  import org.apache.maven.api.ArtifactCoordinates;
26  import org.apache.maven.api.Dependency;
27  import org.apache.maven.api.DependencyCoordinates;
28  import org.apache.maven.api.LocalRepository;
29  import org.apache.maven.api.Node;
30  import org.apache.maven.api.RemoteRepository;
31  import org.apache.maven.api.Session;
32  import org.apache.maven.api.annotations.Nonnull;
33  import org.eclipse.aether.RepositorySystem;
34  import org.eclipse.aether.RepositorySystemSession;
35  
36  import static org.apache.maven.internal.impl.Utils.cast;
37  
38  public interface InternalSession extends Session {
39  
40      static InternalSession from(Session session) {
41          return cast(InternalSession.class, session, "session should be an " + InternalSession.class);
42      }
43  
44      static InternalSession from(org.eclipse.aether.RepositorySystemSession session) {
45          return cast(InternalSession.class, session.getData().get(InternalSession.class), "session");
46      }
47  
48      static void associate(org.eclipse.aether.RepositorySystemSession rsession, Session session) {
49          if (!rsession.getData().set(InternalSession.class, null, from(session))) {
50              throw new IllegalStateException("A maven session is already associated with the repository session");
51          }
52      }
53  
54      RemoteRepository getRemoteRepository(org.eclipse.aether.repository.RemoteRepository repository);
55  
56      Node getNode(org.eclipse.aether.graph.DependencyNode node);
57  
58      Node getNode(org.eclipse.aether.graph.DependencyNode node, boolean verbose);
59  
60      @Nonnull
61      Artifact getArtifact(@Nonnull org.eclipse.aether.artifact.Artifact artifact);
62  
63      @Nonnull
64      <T extends Artifact> T getArtifact(@Nonnull Class<T> clazz, @Nonnull org.eclipse.aether.artifact.Artifact artifact);
65  
66      @Nonnull
67      Dependency getDependency(@Nonnull org.eclipse.aether.graph.Dependency dependency);
68  
69      List<org.eclipse.aether.repository.RemoteRepository> toRepositories(List<RemoteRepository> repositories);
70  
71      org.eclipse.aether.repository.RemoteRepository toRepository(RemoteRepository repository);
72  
73      org.eclipse.aether.repository.LocalRepository toRepository(LocalRepository repository);
74  
75      List<org.eclipse.aether.graph.Dependency> toDependencies(
76              Collection<DependencyCoordinates> dependencies, boolean managed);
77  
78      org.eclipse.aether.graph.Dependency toDependency(DependencyCoordinates dependency, boolean managed);
79  
80      List<org.eclipse.aether.artifact.Artifact> toArtifacts(Collection<Artifact> artifacts);
81  
82      org.eclipse.aether.artifact.Artifact toArtifact(Artifact artifact);
83  
84      org.eclipse.aether.artifact.Artifact toArtifact(ArtifactCoordinates coords);
85  
86      RepositorySystemSession getSession();
87  
88      RepositorySystem getRepositorySystem();
89  }