View Javadoc
1   package org.eclipse.aether;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   * 
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   * 
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.Collection;
23  import java.util.List;
24  
25  import org.eclipse.aether.artifact.Artifact;
26  import org.eclipse.aether.collection.CollectRequest;
27  import org.eclipse.aether.collection.CollectResult;
28  import org.eclipse.aether.collection.DependencyCollectionException;
29  import org.eclipse.aether.deployment.DeployRequest;
30  import org.eclipse.aether.deployment.DeployResult;
31  import org.eclipse.aether.deployment.DeploymentException;
32  import org.eclipse.aether.installation.InstallRequest;
33  import org.eclipse.aether.installation.InstallResult;
34  import org.eclipse.aether.installation.InstallationException;
35  import org.eclipse.aether.metadata.Metadata;
36  import org.eclipse.aether.repository.LocalRepository;
37  import org.eclipse.aether.repository.LocalRepositoryManager;
38  import org.eclipse.aether.repository.RemoteRepository;
39  import org.eclipse.aether.resolution.ArtifactDescriptorException;
40  import org.eclipse.aether.resolution.ArtifactDescriptorRequest;
41  import org.eclipse.aether.resolution.ArtifactDescriptorResult;
42  import org.eclipse.aether.resolution.ArtifactRequest;
43  import org.eclipse.aether.resolution.ArtifactResolutionException;
44  import org.eclipse.aether.resolution.ArtifactResult;
45  import org.eclipse.aether.resolution.DependencyRequest;
46  import org.eclipse.aether.resolution.DependencyResolutionException;
47  import org.eclipse.aether.resolution.DependencyResult;
48  import org.eclipse.aether.resolution.MetadataRequest;
49  import org.eclipse.aether.resolution.MetadataResult;
50  import org.eclipse.aether.resolution.VersionRangeRequest;
51  import org.eclipse.aether.resolution.VersionRangeResolutionException;
52  import org.eclipse.aether.resolution.VersionRangeResult;
53  import org.eclipse.aether.resolution.VersionRequest;
54  import org.eclipse.aether.resolution.VersionResolutionException;
55  import org.eclipse.aether.resolution.VersionResult;
56  
57  /**
58   * The main entry point to the repository system and its functionality. Note that obtaining a concrete implementation of
59   * this interface (e.g. via dependency injection, service locator, etc.) is dependent on the application and its
60   * specific needs, please consult the online documentation for examples and directions on booting the system.
61   * 
62   * @noimplement This interface is not intended to be implemented by clients.
63   * @noextend This interface is not intended to be extended by clients.
64   */
65  public interface RepositorySystem
66  {
67  
68      /**
69       * Expands a version range to a list of matching versions, in ascending order. For example, resolves "[3.8,4.0)" to
70       * "3.8", "3.8.1", "3.8.2". Note that the returned list of versions is only dependent on the configured repositories
71       * and their contents, the list is not processed by the {@link RepositorySystemSession#getVersionFilter() session's
72       * version filter}.
73       * <p>
74       * The supplied request may also refer to a single concrete version rather than a version range. In this case
75       * though, the result contains simply the (parsed) input version, regardless of the repositories and their contents.
76       * 
77       * @param session The repository session, must not be {@code null}.
78       * @param request The version range request, must not be {@code null}.
79       * @return The version range result, never {@code null}.
80       * @throws VersionRangeResolutionException If the requested range could not be parsed. Note that an empty range does
81       *             not raise an exception.
82       * @see #newResolutionRepositories(RepositorySystemSession, List)
83       */
84      VersionRangeResult resolveVersionRange( RepositorySystemSession session, VersionRangeRequest request )
85          throws VersionRangeResolutionException;
86  
87      /**
88       * Resolves an artifact's meta version (if any) to a concrete version. For example, resolves "1.0-SNAPSHOT" to
89       * "1.0-20090208.132618-23".
90       * 
91       * @param session The repository session, must not be {@code null}.
92       * @param request The version request, must not be {@code null}.
93       * @return The version result, never {@code null}.
94       * @throws VersionResolutionException If the metaversion could not be resolved.
95       * @see #newResolutionRepositories(RepositorySystemSession, List)
96       */
97      VersionResult resolveVersion( RepositorySystemSession session, VersionRequest request )
98          throws VersionResolutionException;
99  
100     /**
101      * Gets information about an artifact like its direct dependencies and potential relocations.
102      * 
103      * @param session The repository session, must not be {@code null}.
104      * @param request The descriptor request, must not be {@code null}.
105      * @return The descriptor result, never {@code null}.
106      * @throws ArtifactDescriptorException If the artifact descriptor could not be read.
107      * @see RepositorySystemSession#getArtifactDescriptorPolicy()
108      * @see #newResolutionRepositories(RepositorySystemSession, List)
109      */
110     ArtifactDescriptorResult readArtifactDescriptor( RepositorySystemSession session, ArtifactDescriptorRequest request )
111         throws ArtifactDescriptorException;
112 
113     /**
114      * Collects the transitive dependencies of an artifact and builds a dependency graph. Note that this operation is
115      * only concerned about determining the coordinates of the transitive dependencies. To also resolve the actual
116      * artifact files, use {@link #resolveDependencies(RepositorySystemSession, DependencyRequest)}.
117      * 
118      * @param session The repository session, must not be {@code null}.
119      * @param request The collection request, must not be {@code null}.
120      * @return The collection result, never {@code null}.
121      * @throws DependencyCollectionException If the dependency tree could not be built.
122      * @see RepositorySystemSession#getDependencyTraverser()
123      * @see RepositorySystemSession#getDependencyManager()
124      * @see RepositorySystemSession#getDependencySelector()
125      * @see RepositorySystemSession#getVersionFilter()
126      * @see RepositorySystemSession#getDependencyGraphTransformer()
127      * @see #newResolutionRepositories(RepositorySystemSession, List)
128      */
129     CollectResult collectDependencies( RepositorySystemSession session, CollectRequest request )
130         throws DependencyCollectionException;
131 
132     /**
133      * Collects and resolves the transitive dependencies of an artifact. This operation is essentially a combination of
134      * {@link #collectDependencies(RepositorySystemSession, CollectRequest)} and
135      * {@link #resolveArtifacts(RepositorySystemSession, Collection)}.
136      * 
137      * @param session The repository session, must not be {@code null}.
138      * @param request The dependency request, must not be {@code null}.
139      * @return The dependency result, never {@code null}.
140      * @throws DependencyResolutionException If the dependency tree could not be built or any dependency artifact could
141      *             not be resolved.
142      * @see #newResolutionRepositories(RepositorySystemSession, List)
143      */
144     DependencyResult resolveDependencies( RepositorySystemSession session, DependencyRequest request )
145         throws DependencyResolutionException;
146 
147     /**
148      * Resolves the path for an artifact. The artifact will be downloaded to the local repository if necessary. An
149      * artifact that is already resolved will be skipped and is not re-resolved. In general, callers must not assume any
150      * relationship between an artifact's resolved filename and its coordinates. Note that this method assumes that any
151      * relocations have already been processed.
152      * 
153      * @param session The repository session, must not be {@code null}.
154      * @param request The resolution request, must not be {@code null}.
155      * @return The resolution result, never {@code null}.
156      * @throws ArtifactResolutionException If the artifact could not be resolved.
157      * @see Artifact#getFile()
158      * @see #newResolutionRepositories(RepositorySystemSession, List)
159      */
160     ArtifactResult resolveArtifact( RepositorySystemSession session, ArtifactRequest request )
161         throws ArtifactResolutionException;
162 
163     /**
164      * Resolves the paths for a collection of artifacts. Artifacts will be downloaded to the local repository if
165      * necessary. Artifacts that are already resolved will be skipped and are not re-resolved. In general, callers must
166      * not assume any relationship between an artifact's filename and its coordinates. Note that this method assumes
167      * that any relocations have already been processed.
168      * 
169      * @param session The repository session, must not be {@code null}.
170      * @param requests The resolution requests, must not be {@code null}.
171      * @return The resolution results (in request order), never {@code null}.
172      * @throws ArtifactResolutionException If any artifact could not be resolved.
173      * @see Artifact#getFile()
174      * @see #newResolutionRepositories(RepositorySystemSession, List)
175      */
176     List<ArtifactResult> resolveArtifacts( RepositorySystemSession session,
177                                            Collection<? extends ArtifactRequest> requests )
178         throws ArtifactResolutionException;
179 
180     /**
181      * Resolves the paths for a collection of metadata. Metadata will be downloaded to the local repository if
182      * necessary, e.g. because it hasn't been cached yet or the cache is deemed outdated.
183      * 
184      * @param session The repository session, must not be {@code null}.
185      * @param requests The resolution requests, must not be {@code null}.
186      * @return The resolution results (in request order), never {@code null}.
187      * @see Metadata#getFile()
188      * @see #newResolutionRepositories(RepositorySystemSession, List)
189      */
190     List<MetadataResult> resolveMetadata( RepositorySystemSession session,
191                                           Collection<? extends MetadataRequest> requests );
192 
193     /**
194      * Installs a collection of artifacts and their accompanying metadata to the local repository.
195      * 
196      * @param session The repository session, must not be {@code null}.
197      * @param request The installation request, must not be {@code null}.
198      * @return The installation result, never {@code null}.
199      * @throws InstallationException If any artifact/metadata from the request could not be installed.
200      */
201     InstallResult install( RepositorySystemSession session, InstallRequest request )
202         throws InstallationException;
203 
204     /**
205      * Uploads a collection of artifacts and their accompanying metadata to a remote repository.
206      * 
207      * @param session The repository session, must not be {@code null}.
208      * @param request The deployment request, must not be {@code null}.
209      * @return The deployment result, never {@code null}.
210      * @throws DeploymentException If any artifact/metadata from the request could not be deployed.
211      * @see #newDeploymentRepository(RepositorySystemSession, RemoteRepository)
212      */
213     DeployResult deploy( RepositorySystemSession session, DeployRequest request )
214         throws DeploymentException;
215 
216     /**
217      * Creates a new manager for the specified local repository. If the specified local repository has no type, the
218      * default local repository type of the system will be used. <em>Note:</em> It is expected that this method
219      * invocation is one of the last steps of setting up a new session, in particular any configuration properties
220      * should have been set already.
221      * 
222      * @param session The repository system session from which to configure the manager, must not be {@code null}.
223      * @param localRepository The local repository to create a manager for, must not be {@code null}.
224      * @return The local repository manager, never {@code null}.
225      * @throws IllegalArgumentException If the specified repository type is not recognized or no base directory is
226      *             given.
227      */
228     LocalRepositoryManager newLocalRepositoryManager( RepositorySystemSession session, LocalRepository localRepository );
229 
230     /**
231      * Creates a new synchronization context.
232      * 
233      * @param session The repository session during which the context will be used, must not be {@code null}.
234      * @param shared A flag indicating whether access to the artifacts/metadata associated with the new context can be
235      *            shared among concurrent readers or whether access needs to be exclusive to the calling thread.
236      * @return The synchronization context, never {@code null}.
237      */
238     SyncContext newSyncContext( RepositorySystemSession session, boolean shared );
239 
240     /**
241      * Forms remote repositories suitable for artifact resolution by applying the session's authentication selector and
242      * similar network configuration to the given repository prototypes. As noted for
243      * {@link RepositorySystemSession#getAuthenticationSelector()} etc. the remote repositories passed to e.g.
244      * {@link #resolveArtifact(RepositorySystemSession, ArtifactRequest) resolveArtifact()} are used as is and expected
245      * to already carry any required authentication or proxy configuration. This method can be used to apply the
246      * authentication/proxy configuration from a session to a bare repository definition to obtain the complete
247      * repository definition for use in the resolution request.
248      * 
249      * @param session The repository system session from which to configure the repositories, must not be {@code null}.
250      * @param repositories The repository prototypes from which to derive the resolution repositories, must not be
251      *            {@code null} or contain {@code null} elements.
252      * @return The resolution repositories, never {@code null}. Note that there is generally no 1:1 relationship of the
253      *         obtained repositories to the original inputs due to mirror selection potentially aggregating multiple
254      *         repositories.
255      * @see #newDeploymentRepository(RepositorySystemSession, RemoteRepository)
256      */
257     List<RemoteRepository> newResolutionRepositories( RepositorySystemSession session,
258                                                       List<RemoteRepository> repositories );
259 
260     /**
261      * Forms a remote repository suitable for artifact deployment by applying the session's authentication selector and
262      * similar network configuration to the given repository prototype. As noted for
263      * {@link RepositorySystemSession#getAuthenticationSelector()} etc. the remote repository passed to
264      * {@link #deploy(RepositorySystemSession, DeployRequest) deploy()} is used as is and expected to already carry any
265      * required authentication or proxy configuration. This method can be used to apply the authentication/proxy
266      * configuration from a session to a bare repository definition to obtain the complete repository definition for use
267      * in the deploy request.
268      * 
269      * @param session The repository system session from which to configure the repository, must not be {@code null}.
270      * @param repository The repository prototype from which to derive the deployment repository, must not be
271      *            {@code null}.
272      * @return The deployment repository, never {@code null}.
273      * @see #newResolutionRepositories(RepositorySystemSession, List)
274      */
275     RemoteRepository newDeploymentRepository( RepositorySystemSession session, RemoteRepository repository );
276 
277 }