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;
20  
21  import org.apache.maven.api.annotations.Experimental;
22  import org.apache.maven.api.annotations.Immutable;
23  import org.apache.maven.api.annotations.Nonnull;
24  
25  /**
26   * <p>In Maven, repositories are locations where project artifacts (such as JAR files, POM files, and other
27   * resources) are stored and retrieved. There are two primary types of repositories:
28   * {@linkplain LocalRepository local repositories} and
29   * {@linkplain RemoteRepository remote repositories}.</p>
30   *
31   * <h2>Repository Resolution Process</h2>
32   *
33   * <p>When resolving dependencies, Maven follows this order:</p><ol>
34   * <li>Check Local Repository: Maven first checks if the artifact is available in the local repository.</li>
35   * <li>Check Remote Repositories: If the artifact is not found locally, Maven queries the configured remote repositories in the order they are listed.</li>
36   * <li>Download and Cache: If Maven finds the artifact in a remote repository, it downloads it and stores it in the local repository for future use.</li>
37   * </ol>
38   * <p>By caching artifacts in the local repository, Maven minimizes the need to repeatedly download the same artifacts, thus optimizing the build process.</p>
39   *
40   * <h2>Repository Configuration</h2>
41   *
42   * <p>Repositories can be configured at various levels:<ol>
43   * <li>POM: Repositories can be specified in the {@code pom.xml} file under the {@code <repositories>} and {@code <pluginRepositories>} sections.</li>
44   * <li>Settings: the {@code settings.xml} can be used to provide additional repositories in the three level of settings (user, project, installation).</li>
45   * </ol>
46   * By understanding and properly configuring repositories, developers can control where Maven looks for dependencies, manage access to proprietary artifacts, and optimize the build process to ensure consistency and reliability across projects.
47   *
48   * @since 4.0.0
49   * @see RemoteRepository
50   * @see LocalRepository
51   */
52  @Experimental
53  @Immutable
54  public interface Repository {
55  
56      /**
57       * The reserved id for Maven Central
58       */
59      String CENTRAL_ID = "central";
60  
61      /**
62       * Gets the identifier of this repository.
63       *
64       * @return the (case-sensitive) identifier, never {@code null}
65       */
66      @Nonnull
67      String getId();
68  
69      /**
70       * Gets the type of the repository, for example "default".
71       *
72       * @return the (case-sensitive) type of the repository, never {@code null}
73       */
74      @Nonnull
75      String getType();
76  }