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;
20  
21  import java.io.File;
22  import java.util.List;
23  
24  import org.apache.maven.artifact.Artifact;
25  import org.apache.maven.artifact.InvalidRepositoryException;
26  import org.apache.maven.artifact.repository.ArtifactRepository;
27  import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
28  import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
29  import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
30  import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
31  import org.apache.maven.model.Dependency;
32  import org.apache.maven.model.Plugin;
33  import org.apache.maven.model.Repository;
34  import org.apache.maven.model.interpolation.ModelInterpolator;
35  import org.apache.maven.settings.Mirror;
36  import org.apache.maven.settings.Server;
37  import org.eclipse.aether.RepositorySystemSession;
38  
39  /**
40   * @author Jason van Zyl
41   * @since 3.0-alpha
42   *
43   * @deprecated Use maven-resolver and new DefaultArtifact(...) directly instead.
44   */
45  @Deprecated
46  public interface RepositorySystem {
47      String DEFAULT_LOCAL_REPO_ID = "local";
48  
49      @SuppressWarnings("checkstyle:constantname")
50      String userHome = System.getProperty("user.home");
51  
52      @SuppressWarnings("checkstyle:constantname")
53      File userMavenConfigurationHome = new File(userHome, ".m2");
54  
55      @SuppressWarnings("checkstyle:constantname")
56      File defaultUserLocalRepository = new File(userMavenConfigurationHome, "repository");
57  
58      String DEFAULT_REMOTE_REPO_ID = "central";
59  
60      String DEFAULT_REMOTE_REPO_URL = ModelInterpolator.DEFAULT_MAVEN_REPO_CENTRAL_URL;
61  
62      Artifact createArtifact(String groupId, String artifactId, String version, String packaging);
63  
64      Artifact createArtifact(String groupId, String artifactId, String version, String scope, String type);
65  
66      Artifact createProjectArtifact(String groupId, String artifactId, String version);
67  
68      Artifact createArtifactWithClassifier(
69              String groupId, String artifactId, String version, String type, String classifier);
70  
71      Artifact createPluginArtifact(Plugin plugin);
72  
73      Artifact createDependencyArtifact(Dependency dependency);
74  
75      ArtifactRepository buildArtifactRepository(Repository repository) throws InvalidRepositoryException;
76  
77      ArtifactRepository createDefaultRemoteRepository() throws InvalidRepositoryException;
78  
79      ArtifactRepository createDefaultLocalRepository() throws InvalidRepositoryException;
80  
81      ArtifactRepository createLocalRepository(File localRepository) throws InvalidRepositoryException;
82  
83      ArtifactRepository createArtifactRepository(
84              String id,
85              String url,
86              ArtifactRepositoryLayout repositoryLayout,
87              ArtifactRepositoryPolicy snapshots,
88              ArtifactRepositoryPolicy releases);
89  
90      /**
91       * Calculates the effective repositories for the given input repositories which are assumed to be already mirrored
92       * (if applicable). This process will essentially remove duplicate repositories by merging them into one equivalent
93       * repository. It is worth to point out that merging does not simply choose one of the input repositories and
94       * discards the others but actually combines their possibly different policies.
95       *
96       * @param repositories The original repositories, may be {@code null}.
97       * @return The effective repositories or {@code null} if the input was {@code null}.
98       */
99      List<ArtifactRepository> getEffectiveRepositories(List<ArtifactRepository> repositories);
100 
101     /**
102      * Determines the mirror for the specified repository.
103      *
104      * @param repository The repository to determine the mirror for, must not be {@code null}.
105      * @param mirrors The available mirrors, may be {@code null}.
106      * @return The mirror specification for the repository or {@code null} if no mirror matched.
107      */
108     Mirror getMirror(ArtifactRepository repository, List<Mirror> mirrors);
109 
110     /**
111      * Injects the mirroring information into the specified repositories. For each repository that is matched by a
112      * mirror, its URL and ID will be updated to match the values from the mirror specification. Repositories without a
113      * matching mirror will pass through unchanged. <em>Note:</em> This method must be called before
114      * {@link #injectAuthentication(List, List)} or the repositories will end up with the wrong credentials.
115      *
116      * @param repositories The repositories into which to inject the mirror information, may be {@code null}.
117      * @param mirrors The available mirrors, may be {@code null}.
118      */
119     void injectMirror(List<ArtifactRepository> repositories, List<Mirror> mirrors);
120 
121     /**
122      * Injects the proxy information into the specified repositories. For each repository that is matched by a proxy,
123      * its proxy data will be set accordingly. Repositories without a matching proxy will have their proxy cleared.
124      * <em>Note:</em> This method must be called after {@link #injectMirror(List, List)} or the repositories will end up
125      * with the wrong proxies.
126      *
127      * @param repositories The repositories into which to inject the proxy information, may be {@code null}.
128      * @param proxies The available proxies, may be {@code null}.
129      */
130     void injectProxy(List<ArtifactRepository> repositories, List<org.apache.maven.settings.Proxy> proxies);
131 
132     /**
133      * Injects the authentication information into the specified repositories. For each repository that is matched by a
134      * server, its credentials will be updated to match the values from the server specification. Repositories without a
135      * matching server will have their credentials cleared. <em>Note:</em> This method must be called after
136      * {@link #injectMirror(List, List)} or the repositories will end up with the wrong credentials.
137      *
138      * @param repositories The repositories into which to inject the authentication information, may be {@code null}.
139      * @param servers The available servers, may be {@code null}.
140      */
141     void injectAuthentication(List<ArtifactRepository> repositories, List<Server> servers);
142 
143     void injectMirror(RepositorySystemSession session, List<ArtifactRepository> repositories);
144 
145     void injectProxy(RepositorySystemSession session, List<ArtifactRepository> repositories);
146 
147     void injectAuthentication(RepositorySystemSession session, List<ArtifactRepository> repositories);
148 
149     ArtifactResolutionResult resolve(ArtifactResolutionRequest request);
150 
151     // Install
152 
153     // Deploy
154 
155     // Map types of artifacts
156 
157     //
158     // Raw file transfers
159     //
160     void publish(
161             ArtifactRepository repository, File source, String remotePath, ArtifactTransferListener transferListener)
162             throws ArtifactTransferFailedException;
163 
164     void retrieve(
165             ArtifactRepository repository,
166             File destination,
167             String remotePath,
168             ArtifactTransferListener transferListener)
169             throws ArtifactTransferFailedException, ArtifactDoesNotExistException;
170 }