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.api.services;
20  
21  import java.nio.file.Path;
22  
23  import org.apache.maven.api.Artifact;
24  import org.apache.maven.api.LocalRepository;
25  import org.apache.maven.api.RemoteRepository;
26  import org.apache.maven.api.Service;
27  import org.apache.maven.api.Session;
28  import org.apache.maven.api.annotations.Experimental;
29  import org.apache.maven.api.annotations.Nonnull;
30  
31  /**
32   * Manages the organization and access of artifacts within the local Maven repository.
33   * The local repository serves as a cache for downloaded remote artifacts and storage
34   * for locally installed artifacts. This manager provides services to determine the
35   * appropriate paths for artifacts within the local repository structure.
36   *
37   * <p>The LocalRepositoryManager is responsible for:
38   * <ul>
39   *   <li>Determining the storage path for locally installed artifacts</li>
40   *   <li>Managing the layout and organization of cached remote artifacts</li>
41   *   <li>Maintaining consistency in artifact storage patterns</li>
42   * </ul>
43   *
44   * <p>This interface is part of Maven's repository management system and works in
45   * conjunction with {@link RemoteRepository} and {@link LocalRepository} to provide
46   * a complete artifact resolution and storage solution.
47   *
48   * @since 4.0.0
49   * @see LocalRepository
50   * @see RemoteRepository
51   * @see Artifact
52   */
53  @Experimental
54  public interface LocalRepositoryManager extends Service {
55  
56      /**
57       * Gets the relative path for a locally installed artifact.
58       * Note that the artifact need not actually exist yet at
59       * the returned location, the path merely indicates where
60       * the artifact would eventually be stored.
61       *
62       * @param session The session to use, must not be {@code null}.
63       * @param artifact The artifact for which to determine the path, must not be {@code null}.
64       * @return The path, resolved against the local repository's base directory.
65       */
66      @Nonnull
67      Path getPathForLocalArtifact(@Nonnull Session session, @Nonnull LocalRepository local, @Nonnull Artifact artifact);
68  
69      /**
70       * Gets the relative path for an artifact cached from a remote repository.
71       * Note that the artifact need not actually exist yet at the returned location,
72       * the path merely indicates where the artifact would eventually be stored.
73       *
74       * @param session The session to use, must not be {@code null}.
75       * @param local The local repository, must not be {@code null}.
76       * @param artifact The artifact for which to determine the path, must not be {@code null}.
77       * @param remote – The source repository of the artifact, must not be {@code null}.
78       * @return The path, relative to the local repository's base directory.
79       */
80      @Nonnull
81      Path getPathForRemoteArtifact(
82              @Nonnull Session session,
83              @Nonnull LocalRepository local,
84              @Nonnull RemoteRepository remote,
85              @Nonnull Artifact artifact);
86  }