001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.eclipse.aether;
020
021import java.io.Closeable;
022import java.nio.file.Path;
023import java.util.Collection;
024import java.util.Map;
025import java.util.function.Supplier;
026
027import org.eclipse.aether.artifact.ArtifactTypeRegistry;
028import org.eclipse.aether.collection.DependencyGraphTransformer;
029import org.eclipse.aether.collection.DependencyManager;
030import org.eclipse.aether.collection.DependencySelector;
031import org.eclipse.aether.collection.DependencyTraverser;
032import org.eclipse.aether.collection.VersionFilter;
033import org.eclipse.aether.repository.AuthenticationSelector;
034import org.eclipse.aether.repository.LocalRepository;
035import org.eclipse.aether.repository.LocalRepositoryManager;
036import org.eclipse.aether.repository.MirrorSelector;
037import org.eclipse.aether.repository.ProxySelector;
038import org.eclipse.aether.repository.RemoteRepository;
039import org.eclipse.aether.repository.RepositoryPolicy;
040import org.eclipse.aether.repository.WorkspaceReader;
041import org.eclipse.aether.resolution.ArtifactDescriptorPolicy;
042import org.eclipse.aether.resolution.ResolutionErrorPolicy;
043import org.eclipse.aether.scope.ScopeManager;
044import org.eclipse.aether.scope.SystemDependencyScope;
045import org.eclipse.aether.transfer.TransferListener;
046
047/**
048 * Defines settings and components that control the repository system. Once initialized, the session object itself is
049 * supposed to be immutable and hence can safely be shared across an entire application and any concurrent threads
050 * reading it. Components that wish to tweak some aspects of an existing session should use the copy constructor of
051 * {@link DefaultRepositorySystemSession} and its mutators to derive a custom session.
052 *
053 * @noimplement This interface is not intended to be implemented by clients.
054 * @noextend This interface is not intended to be extended by clients.
055 */
056public interface RepositorySystemSession {
057
058    /**
059     * Immutable session that is closeable, should be handled as a resource. These session instances can be
060     * created with {@link SessionBuilder}.
061     *
062     * @noimplement This interface is not intended to be implemented by clients.
063     * @noextend This interface is not intended to be extended by clients.
064     *
065     * @since 2.0.0
066     */
067    interface CloseableSession extends RepositorySystemSession, Closeable {
068        /**
069         * Returns the ID of this closeable session instance. Each closeable session has different ID, unique within
070         * repository system they were created with.
071         *
072         * @return The session ID that is never {@code null}.
073         */
074        String sessionId();
075
076        /**
077         * Closes the session. The session should be closed by its creator. A closed session should not be used anymore.
078         * This method may be invoked multiple times, but close will act only once (first time).
079         */
080        @Override
081        void close();
082    }
083
084    /**
085     * Builder for building {@link CloseableSession} instances. Builder instances can be created with
086     * {@link RepositorySystem#createSessionBuilder()} method. Instances are not thread-safe nor immutable.
087     * <p>
088     * Important: if you set a stateful member on builder (for example {@link SessionData} or {@link RepositoryCache}),
089     * the builder will create session instances using same provided stateful members, that may lead to unexpected side
090     * effects. Solution for these cases is to not reuse builder instances, or, keep reconfiguring it, or ultimately
091     * provide suppliers that create new instance per each call.
092     *
093     * @noimplement This interface is not intended to be implemented by clients.
094     * @noextend This interface is not intended to be extended by clients.
095     *
096     * @since 2.0.0
097     */
098    interface SessionBuilder {
099        /**
100         * Controls whether the repository system operates in offline mode and avoids/refuses any access to remote
101         * repositories.
102         *
103         * @param offline {@code true} if the repository system is in offline mode, {@code false} otherwise.
104         * @return This session for chaining, never {@code null}.
105         */
106        SessionBuilder setOffline(boolean offline);
107
108        /**
109         * Controls whether repositories declared in artifact descriptors should be ignored during transitive dependency
110         * collection. If enabled, only the repositories originally provided with the collect request will be considered.
111         *
112         * @param ignoreArtifactDescriptorRepositories {@code true} to ignore additional repositories from artifact
113         *                                             descriptors, {@code false} to merge those with the originally
114         *                                             specified repositories.
115         * @return This session for chaining, never {@code null}.
116         */
117        SessionBuilder setIgnoreArtifactDescriptorRepositories(boolean ignoreArtifactDescriptorRepositories);
118
119        /**
120         * Sets the policy which controls whether resolutions errors from remote repositories should be cached.
121         *
122         * @param resolutionErrorPolicy The resolution error policy for this session, may be {@code null} if resolution
123         *                              errors should generally not be cached.
124         * @return This session for chaining, never {@code null}.
125         */
126        SessionBuilder setResolutionErrorPolicy(ResolutionErrorPolicy resolutionErrorPolicy);
127
128        /**
129         * Sets the policy which controls how errors related to reading artifact descriptors should be handled.
130         *
131         * @param artifactDescriptorPolicy The descriptor error policy for this session, may be {@code null} if descriptor
132         *                                 errors should generally not be tolerated.
133         * @return This session for chaining, never {@code null}.
134         */
135        SessionBuilder setArtifactDescriptorPolicy(ArtifactDescriptorPolicy artifactDescriptorPolicy);
136
137        /**
138         * Sets the global checksum policy. If set, the global checksum policy overrides the checksum policies of the remote
139         * repositories being used for resolution.
140         *
141         * @param checksumPolicy The global checksum policy, may be {@code null}/empty to apply the per-repository policies.
142         * @return This session for chaining, never {@code null}.
143         * @see RepositoryPolicy#CHECKSUM_POLICY_FAIL
144         * @see RepositoryPolicy#CHECKSUM_POLICY_IGNORE
145         * @see RepositoryPolicy#CHECKSUM_POLICY_WARN
146         */
147        SessionBuilder setChecksumPolicy(String checksumPolicy);
148
149        /**
150         * Sets the global update policy. If set, the global update policy overrides the update policies of the remote
151         * repositories being used for resolution.
152         * <p>
153         * This method is meant for code that does not want to distinguish between artifact and metadata policies.
154         * Note: applications should either use get/set updatePolicy (this method and
155         * {@link RepositorySystemSession#getUpdatePolicy()}) or also distinguish between artifact and
156         * metadata update policies (and use other methods), but <em>should not mix the two!</em>
157         *
158         * @param updatePolicy The global update policy, may be {@code null}/empty to apply the per-repository policies.
159         * @return This session for chaining, never {@code null}.
160         * @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
161         * @see RepositoryPolicy#UPDATE_POLICY_DAILY
162         * @see RepositoryPolicy#UPDATE_POLICY_NEVER
163         * @see #setArtifactUpdatePolicy(String)
164         * @see #setMetadataUpdatePolicy(String)
165         */
166        SessionBuilder setUpdatePolicy(String updatePolicy);
167
168        /**
169         * Sets the global artifact update policy. If set, the global update policy overrides the artifact update policies
170         * of the remote repositories being used for resolution.
171         *
172         * @param artifactUpdatePolicy The global update policy, may be {@code null}/empty to apply the per-repository policies.
173         * @return This session for chaining, never {@code null}.
174         * @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
175         * @see RepositoryPolicy#UPDATE_POLICY_DAILY
176         * @see RepositoryPolicy#UPDATE_POLICY_NEVER
177         * @since 2.0.0
178         */
179        SessionBuilder setArtifactUpdatePolicy(String artifactUpdatePolicy);
180
181        /**
182         * Sets the global metadata update policy. If set, the global update policy overrides the metadata update policies
183         * of the remote repositories being used for resolution.
184         *
185         * @param metadataUpdatePolicy The global update policy, may be {@code null}/empty to apply the per-repository policies.
186         * @return This session for chaining, never {@code null}.
187         * @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
188         * @see RepositoryPolicy#UPDATE_POLICY_DAILY
189         * @see RepositoryPolicy#UPDATE_POLICY_NEVER
190         * @since 2.0.0
191         */
192        SessionBuilder setMetadataUpdatePolicy(String metadataUpdatePolicy);
193
194        /**
195         * Sets the local repository manager used during this session. <em>Note:</em> Eventually, a valid session must have
196         * a local repository manager set.
197         *
198         * @param localRepositoryManager The local repository manager used during this session, may be {@code null}.
199         * @return This session for chaining, never {@code null}.
200         */
201        SessionBuilder setLocalRepositoryManager(LocalRepositoryManager localRepositoryManager);
202
203        /**
204         * Sets the workspace reader used during this session. If set, the workspace reader will usually be consulted first
205         * to resolve artifacts.
206         *
207         * @param workspaceReader The workspace reader for this session, may be {@code null} if none.
208         * @return This session for chaining, never {@code null}.
209         */
210        SessionBuilder setWorkspaceReader(WorkspaceReader workspaceReader);
211
212        /**
213         * Sets the listener being notified of actions in the repository system.
214         *
215         * @param repositoryListener The repository listener, may be {@code null} if none.
216         * @return This session for chaining, never {@code null}.
217         */
218        SessionBuilder setRepositoryListener(RepositoryListener repositoryListener);
219
220        /**
221         * Sets the listener being notified of uploads/downloads by the repository system.
222         *
223         * @param transferListener The transfer listener, may be {@code null} if none.
224         * @return This session for chaining, never {@code null}.
225         */
226        SessionBuilder setTransferListener(TransferListener transferListener);
227
228        /**
229         * Sets the system properties to use, e.g. for processing of artifact descriptors. System properties are usually
230         * collected from the runtime environment like {@link System#getProperties()} and environment variables.
231         * <p>
232         * <em>Note:</em> System properties are of type {@code Map<String, String>} and any key-value pair in the input map
233         * that doesn't match this type will be silently ignored.
234         *
235         * @param systemProperties The system properties, may be {@code null} or empty if none.
236         * @return This session for chaining, never {@code null}.
237         */
238        SessionBuilder setSystemProperties(Map<?, ?> systemProperties);
239
240        /**
241         * Sets the specified system property.
242         *
243         * @param key   The property key, must not be {@code null}.
244         * @param value The property value, may be {@code null} to remove/unset the property.
245         * @return This session for chaining, never {@code null}.
246         */
247        SessionBuilder setSystemProperty(String key, String value);
248
249        /**
250         * Sets the user properties to use, e.g. for processing of artifact descriptors. User properties are similar to
251         * system properties but are set on the discretion of the user and hence are considered of higher priority than
252         * system properties in case of conflicts.
253         * <p>
254         * <em>Note:</em> User properties are of type {@code Map<String, String>} and any key-value pair in the input map
255         * that doesn't match this type will be silently ignored.
256         *
257         * @param userProperties The user properties, may be {@code null} or empty if none.
258         * @return This session for chaining, never {@code null}.
259         */
260        SessionBuilder setUserProperties(Map<?, ?> userProperties);
261
262        /**
263         * Sets the specified user property.
264         *
265         * @param key   The property key, must not be {@code null}.
266         * @param value The property value, may be {@code null} to remove/unset the property.
267         * @return This session for chaining, never {@code null}.
268         */
269        SessionBuilder setUserProperty(String key, String value);
270
271        /**
272         * Sets the configuration properties used to tweak internal aspects of the repository system (e.g. thread pooling,
273         * connector-specific behavior, etc.).
274         * <p>
275         * <em>Note:</em> Configuration properties are of type {@code Map<String, Object>} and any key-value pair in the
276         * input map that doesn't match this type will be silently ignored.
277         *
278         * @param configProperties The configuration properties, may be {@code null} or empty if none.
279         * @return This session for chaining, never {@code null}.
280         */
281        SessionBuilder setConfigProperties(Map<?, ?> configProperties);
282
283        /**
284         * Sets the specified configuration property.
285         *
286         * @param key   The property key, must not be {@code null}.
287         * @param value The property value, may be {@code null} to remove/unset the property.
288         * @return This session for chaining, never {@code null}.
289         */
290        SessionBuilder setConfigProperty(String key, Object value);
291
292        /**
293         * Sets the mirror selector to use for repositories discovered in artifact descriptors. Note that this selector is
294         * not used for remote repositories which are passed as request parameters to the repository system, those
295         * repositories are supposed to denote the effective repositories.
296         *
297         * @param mirrorSelector The mirror selector to use, may be {@code null}.
298         * @return This session for chaining, never {@code null}.
299         */
300        SessionBuilder setMirrorSelector(MirrorSelector mirrorSelector);
301
302        /**
303         * Sets the proxy selector to use for repositories discovered in artifact descriptors. Note that this selector is
304         * not used for remote repositories which are passed as request parameters to the repository system, those
305         * repositories are supposed to have their proxy (if any) already set.
306         *
307         * @param proxySelector The proxy selector to use, may be {@code null}.
308         * @return This session for chaining, never {@code null}.
309         * @see RemoteRepository#getProxy()
310         */
311        SessionBuilder setProxySelector(ProxySelector proxySelector);
312
313        /**
314         * Sets the authentication selector to use for repositories discovered in artifact descriptors. Note that this
315         * selector is not used for remote repositories which are passed as request parameters to the repository system,
316         * those repositories are supposed to have their authentication (if any) already set.
317         *
318         * @param authenticationSelector The authentication selector to use, may be {@code null}.
319         * @return This session for chaining, never {@code null}.
320         * @see RemoteRepository#getAuthentication()
321         */
322        SessionBuilder setAuthenticationSelector(AuthenticationSelector authenticationSelector);
323
324        /**
325         * Sets the registry of artifact types recognized by this session.
326         *
327         * @param artifactTypeRegistry The artifact type registry, may be {@code null}.
328         * @return This session for chaining, never {@code null}.
329         */
330        SessionBuilder setArtifactTypeRegistry(ArtifactTypeRegistry artifactTypeRegistry);
331
332        /**
333         * Sets the dependency traverser to use for building dependency graphs.
334         *
335         * @param dependencyTraverser The dependency traverser to use for building dependency graphs, may be {@code null}.
336         * @return This session for chaining, never {@code null}.
337         */
338        SessionBuilder setDependencyTraverser(DependencyTraverser dependencyTraverser);
339
340        /**
341         * Sets the dependency manager to use for building dependency graphs.
342         *
343         * @param dependencyManager The dependency manager to use for building dependency graphs, may be {@code null}.
344         * @return This session for chaining, never {@code null}.
345         */
346        SessionBuilder setDependencyManager(DependencyManager dependencyManager);
347
348        /**
349         * Sets the dependency selector to use for building dependency graphs.
350         *
351         * @param dependencySelector The dependency selector to use for building dependency graphs, may be {@code null}.
352         * @return This session for chaining, never {@code null}.
353         */
354        SessionBuilder setDependencySelector(DependencySelector dependencySelector);
355
356        /**
357         * Sets the version filter to use for building dependency graphs.
358         *
359         * @param versionFilter The version filter to use for building dependency graphs, may be {@code null} to not filter
360         *                      versions.
361         * @return This session for chaining, never {@code null}.
362         */
363        SessionBuilder setVersionFilter(VersionFilter versionFilter);
364
365        /**
366         * Sets the dependency graph transformer to use for building dependency graphs.
367         *
368         * @param dependencyGraphTransformer The dependency graph transformer to use for building dependency graphs, may be
369         *                                   {@code null}.
370         * @return This session for chaining, never {@code null}.
371         */
372        SessionBuilder setDependencyGraphTransformer(DependencyGraphTransformer dependencyGraphTransformer);
373
374        /**
375         * Sets the custom data associated with this session.
376         * Note: When this method used to set instance, same passed instance will be used for every built session out
377         * of this builder instance, hence the built sessions will share these instances as well!
378         *
379         * @param data The session data, may be {@code null}.
380         * @return This session for chaining, never {@code null}.
381         */
382        SessionBuilder setData(SessionData data);
383
384        /**
385         * Sets the cache the repository system may use to save data for future reuse during the session.
386         * Note: When this method used to set instance, same passed instance will be used for every built session out
387         * of this builder instance, hence the built sessions will share these instances as well!
388         *
389         * @param cache The repository cache, may be {@code null} if none.
390         * @return This session for chaining, never {@code null}.
391         */
392        SessionBuilder setCache(RepositoryCache cache);
393
394        /**
395         * Sets the scope manager for session, may be {@code null}.
396         *
397         * @param scopeManager The scope manager, may be {@code null}.
398         * @return The session for chaining, never {@code null}.
399         */
400        SessionBuilder setScopeManager(ScopeManager scopeManager);
401
402        /**
403         * Adds on session ended handler to be immediately registered when this builder creates session.
404         *
405         * @param handler The on session ended handler, may not be {@code null}.
406         * @return The session for chaining, never {@code null}.
407         */
408        SessionBuilder addOnSessionEndedHandler(Runnable handler);
409
410        /**
411         * Sets the custom session data supplier associated with this session.
412         * Note: The supplier will be used for every built session out of this builder instance, so if supplier supplies
413         * <em>same instance</em> the built sessions will share these instances as well!
414         *
415         * @param dataSupplier The session data supplier, may not be {@code null}.
416         * @return This session for chaining, never {@code null}.
417         */
418        SessionBuilder setSessionDataSupplier(Supplier<SessionData> dataSupplier);
419
420        /**
421         * Sets the cache supplier for the repository system may use to save data for future reuse during the session.
422         * Note: The supplier will be used for every built session out of this builder instance, so if supplier supplies
423         * <em>same instance</em> the built sessions will share these instances as well!
424         *
425         * @param cacheSupplier The repository cache supplier, may not be {@code null}.
426         * @return This session for chaining, never {@code null}.
427         */
428        SessionBuilder setRepositoryCacheSupplier(Supplier<RepositoryCache> cacheSupplier);
429
430        /**
431         * Shortcut method to set up local repository manager directly onto builder. There must be at least one non-null
432         * {@link Path} passed in this method. In case multiple files, session builder will use chained local repository
433         * manager.
434         *
435         * @param baseDirectories The local repository base directories.
436         * @return This session for chaining, never {@code null}.
437         * @see #withLocalRepositories(LocalRepository...)
438         */
439        SessionBuilder withLocalRepositoryBaseDirectories(Path... baseDirectories);
440
441        /**
442         * Shortcut method to set up local repository manager directly onto builder. There must be at least one non-null
443         * {@link Path} present in passed in list. In case multiple files, session builder will use chained local
444         * repository manager.
445         *
446         * @param baseDirectories The local repository base directories.
447         * @return This session for chaining, never {@code null}.
448         * @see #withLocalRepositories(Collection)
449         */
450        SessionBuilder withLocalRepositoryBaseDirectories(Collection<Path> baseDirectories);
451
452        /**
453         * Shortcut method to set up local repository manager directly onto builder. There must be at least one non-null
454         * {@link LocalRepository} passed in this method. In case multiple local repositories, session builder will
455         * use chained local repository manager.
456         *
457         * @param localRepositories The local repositories.
458         * @return This session for chaining, never {@code null}.
459         */
460        SessionBuilder withLocalRepositories(LocalRepository... localRepositories);
461
462        /**
463         * Shortcut method to set up local repository manager directly onto builder. There must be at least one non-null
464         * {@link LocalRepository} present in passed in list. In case multiple local repositories, session builder will
465         * use chained local repository manager.
466         *
467         * @param localRepositories The local repositories.
468         * @return This session for chaining, never {@code null}.
469         */
470        SessionBuilder withLocalRepositories(Collection<LocalRepository> localRepositories);
471
472        /**
473         * Adds the listeners to be notified of actions in the repository system.
474         *
475         * @param repositoryListeners The repository listeners, never {@code null}.
476         * @return This session for chaining, never {@code null}.
477         */
478        SessionBuilder withRepositoryListener(RepositoryListener... repositoryListeners);
479
480        /**
481         * Adds the listeners to be notified of actions in the repository system.
482         *
483         * @param repositoryListeners The repository listeners, never {@code null}.
484         * @return This session for chaining, never {@code null}.
485         */
486        SessionBuilder withRepositoryListener(Collection<RepositoryListener> repositoryListeners);
487
488        /**
489         * Adds the listener to be notified of uploads/downloads by the repository system.
490         *
491         * @param transferListeners The transfer listeners, never {@code null}.
492         * @return This session for chaining, never {@code null}.
493         */
494        SessionBuilder withTransferListener(TransferListener... transferListeners);
495
496        /**
497         * Adds the listener to be notified of uploads/downloads by the repository system.
498         *
499         * @param transferListeners The transfer listeners, never {@code null}.
500         * @return This session for chaining, never {@code null}.
501         */
502        SessionBuilder withTransferListener(Collection<TransferListener> transferListeners);
503
504        /**
505         * Shortcut method to shallow-copy passed in session into current builder.
506         *
507         * @param session The session to shallow-copy from.
508         * @return This session for chaining, never {@code null}.
509         */
510        SessionBuilder withRepositorySystemSession(RepositorySystemSession session);
511
512        /**
513         * Creates immutable closeable session out this builder instance.
514         *
515         * @return Immutable closeable session, never {@code null}.
516         */
517        CloseableSession build();
518    }
519
520    /**
521     * Indicates whether the repository system operates in offline mode and avoids/refuses any access to remote
522     * repositories.
523     *
524     * @return {@code true} if the repository system is in offline mode, {@code false} otherwise.
525     */
526    boolean isOffline();
527
528    /**
529     * Indicates whether repositories declared in artifact descriptors should be ignored during transitive dependency
530     * collection. If enabled, only the repositories originally provided with the collect request will be considered.
531     *
532     * @return {@code true} if additional repositories from artifact descriptors are ignored, {@code false} to merge
533     *         those with the originally specified repositories.
534     */
535    boolean isIgnoreArtifactDescriptorRepositories();
536
537    /**
538     * Gets the policy which controls whether resolutions errors from remote repositories should be cached.
539     *
540     * @return The resolution error policy for this session or {@code null} if resolution errors should generally not be
541     *         cached.
542     */
543    ResolutionErrorPolicy getResolutionErrorPolicy();
544
545    /**
546     * Gets the policy which controls how errors related to reading artifact descriptors should be handled.
547     *
548     * @return The descriptor error policy for this session or {@code null} if descriptor errors should generally not be
549     *         tolerated.
550     */
551    ArtifactDescriptorPolicy getArtifactDescriptorPolicy();
552
553    /**
554     * Gets the global checksum policy. If set, the global checksum policy overrides the checksum policies of the remote
555     * repositories being used for resolution.
556     *
557     * @return The global checksum policy or {@code null}/empty if not set and the per-repository policies apply.
558     * @see RepositoryPolicy#CHECKSUM_POLICY_FAIL
559     * @see RepositoryPolicy#CHECKSUM_POLICY_IGNORE
560     * @see RepositoryPolicy#CHECKSUM_POLICY_WARN
561     */
562    String getChecksumPolicy();
563
564    /**
565     * Gets the global update policy, or {@code null} if not set.
566     * <p>
567     * This method is meant for code that does not want to distinguish between artifact and metadata policies.
568     * Note: applications should either use get/set updatePolicy (this method and
569     * {@link DefaultRepositorySystemSession#setUpdatePolicy(String)}) or also distinguish between artifact and
570     * metadata update policies (and use other methods), but <em>should not mix the two!</em>
571     *
572     * @see #getArtifactUpdatePolicy()
573     * @see #getMetadataUpdatePolicy()
574     */
575    String getUpdatePolicy();
576
577    /**
578     * Gets the global artifact update policy. If set, the global update policy overrides the update policies of the
579     * remote repositories being used for resolution.
580     *
581     * @return The global update policy or {@code null}/empty if not set and the per-repository policies apply.
582     * @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
583     * @see RepositoryPolicy#UPDATE_POLICY_DAILY
584     * @see RepositoryPolicy#UPDATE_POLICY_NEVER
585     * @since 2.0.0
586     */
587    String getArtifactUpdatePolicy();
588
589    /**
590     * Gets the global metadata update policy. If set, the global update policy overrides the update policies of the remote
591     * repositories being used for resolution.
592     *
593     * @return The global update policy or {@code null}/empty if not set and the per-repository policies apply.
594     * @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
595     * @see RepositoryPolicy#UPDATE_POLICY_DAILY
596     * @see RepositoryPolicy#UPDATE_POLICY_NEVER
597     * @since 2.0.0
598     */
599    String getMetadataUpdatePolicy();
600
601    /**
602     * Gets the local repository used during this session. This is a convenience method for
603     * {@link LocalRepositoryManager#getRepository()}.
604     *
605     * @return The local repository being during this session, never {@code null}.
606     */
607    LocalRepository getLocalRepository();
608
609    /**
610     * Gets the local repository manager used during this session.
611     *
612     * @return The local repository manager used during this session, never {@code null}.
613     */
614    LocalRepositoryManager getLocalRepositoryManager();
615
616    /**
617     * Gets the workspace reader used during this session. If set, the workspace reader will usually be consulted first
618     * to resolve artifacts.
619     *
620     * @return The workspace reader for this session or {@code null} if none.
621     */
622    WorkspaceReader getWorkspaceReader();
623
624    /**
625     * Gets the listener being notified of actions in the repository system.
626     *
627     * @return The repository listener or {@code null} if none.
628     */
629    RepositoryListener getRepositoryListener();
630
631    /**
632     * Gets the listener being notified of uploads/downloads by the repository system.
633     *
634     * @return The transfer listener or {@code null} if none.
635     */
636    TransferListener getTransferListener();
637
638    /**
639     * Gets the system properties to use, e.g. for processing of artifact descriptors. System properties are usually
640     * collected from the runtime environment like {@link System#getProperties()} and environment variables.
641     *
642     * @return The (read-only) system properties, never {@code null}.
643     */
644    Map<String, String> getSystemProperties();
645
646    /**
647     * Gets the user properties to use, e.g. for processing of artifact descriptors. User properties are similar to
648     * system properties but are set on the discretion of the user and hence are considered of higher priority than
649     * system properties.
650     *
651     * @return The (read-only) user properties, never {@code null}.
652     */
653    Map<String, String> getUserProperties();
654
655    /**
656     * Gets the configuration properties used to tweak internal aspects of the repository system (e.g. thread pooling,
657     * connector-specific behavior, etc.)
658     *
659     * @return The (read-only) configuration properties, never {@code null}.
660     * @see ConfigurationProperties
661     */
662    Map<String, Object> getConfigProperties();
663
664    /**
665     * Gets the mirror selector to use for repositories discovered in artifact descriptors. Note that this selector is
666     * not used for remote repositories which are passed as request parameters to the repository system, those
667     * repositories are supposed to denote the effective repositories.
668     *
669     * @return The mirror selector to use, never {@code null}.
670     * @see RepositorySystem#newResolutionRepositories(RepositorySystemSession, java.util.List)
671     */
672    MirrorSelector getMirrorSelector();
673
674    /**
675     * Gets the proxy selector to use for repositories discovered in artifact descriptors. Note that this selector is
676     * not used for remote repositories which are passed as request parameters to the repository system, those
677     * repositories are supposed to have their proxy (if any) already set.
678     *
679     * @return The proxy selector to use, never {@code null}.
680     * @see org.eclipse.aether.repository.RemoteRepository#getProxy()
681     * @see RepositorySystem#newResolutionRepositories(RepositorySystemSession, java.util.List)
682     */
683    ProxySelector getProxySelector();
684
685    /**
686     * Gets the authentication selector to use for repositories discovered in artifact descriptors. Note that this
687     * selector is not used for remote repositories which are passed as request parameters to the repository system,
688     * those repositories are supposed to have their authentication (if any) already set.
689     *
690     * @return The authentication selector to use, never {@code null}.
691     * @see org.eclipse.aether.repository.RemoteRepository#getAuthentication()
692     * @see RepositorySystem#newResolutionRepositories(RepositorySystemSession, java.util.List)
693     */
694    AuthenticationSelector getAuthenticationSelector();
695
696    /**
697     * Gets the registry of artifact types recognized by this session, for instance when processing artifact
698     * descriptors.
699     *
700     * @return The artifact type registry, never {@code null}.
701     */
702    ArtifactTypeRegistry getArtifactTypeRegistry();
703
704    /**
705     * Gets the dependency traverser to use for building dependency graphs.
706     *
707     * @return The dependency traverser to use for building dependency graphs or {@code null} if dependencies are
708     *         unconditionally traversed.
709     */
710    DependencyTraverser getDependencyTraverser();
711
712    /**
713     * Gets the dependency manager to use for building dependency graphs.
714     *
715     * @return The dependency manager to use for building dependency graphs or {@code null} if dependency management is
716     *         not performed.
717     */
718    DependencyManager getDependencyManager();
719
720    /**
721     * Gets the dependency selector to use for building dependency graphs.
722     *
723     * @return The dependency selector to use for building dependency graphs or {@code null} if dependencies are
724     *         unconditionally included.
725     */
726    DependencySelector getDependencySelector();
727
728    /**
729     * Gets the version filter to use for building dependency graphs.
730     *
731     * @return The version filter to use for building dependency graphs or {@code null} if versions aren't filtered.
732     */
733    VersionFilter getVersionFilter();
734
735    /**
736     * Gets the dependency graph transformer to use for building dependency graphs.
737     *
738     * @return The dependency graph transformer to use for building dependency graphs or {@code null} if none.
739     */
740    DependencyGraphTransformer getDependencyGraphTransformer();
741
742    /**
743     * Gets the custom data associated with this session.
744     *
745     * @return The session data, never {@code null}.
746     */
747    SessionData getData();
748
749    /**
750     * Gets the cache the repository system may use to save data for future reuse during the session.
751     *
752     * @return The repository cache or {@code null} if none.
753     */
754    RepositoryCache getCache();
755
756    /**
757     * Returns the scope manager to be used in this session, may be {@code null} if not set.
758     *
759     * @return The scope manager or {@code null} if not set.
760     * @since 2.0.0
761     */
762    ScopeManager getScopeManager();
763
764    /**
765     * Returns the system dependency scope.
766     * <p>
767     * Shorthand method for {@link ScopeManager#getSystemDependencyScope()}.
768     * <p>
769     * If {@link ScopeManager} is set, {@link #getScopeManager()} returns non-null value, the result of
770     * {@link ScopeManager#getSystemDependencyScope()} is returned (that may be {@code null}). If no {@link ScopeManager}
771     * if set, then {@link SystemDependencyScope#LEGACY} instance is returned, as lack of scope manager means that
772     * resolver operates in "legacy" mode (Maven3 compatible mode).
773     *
774     * @return The system dependency scope or {@code null} if no such scope.
775     * @since 2.0.0
776     */
777    SystemDependencyScope getSystemDependencyScope();
778
779    /**
780     * Registers a handler to execute when this session closed.
781     * <p>
782     * Note: Resolver 1.x sessions will not be able to register handlers. Migrate to Resolver 2.x way of handling
783     * sessions to make full use of new features. New features (like HTTP/2 transport) depend on this functionality.
784     * While they will function with Resolver 1.x sessions, they may produce resource leaks.
785     *
786     * @param handler the handler, never {@code null}.
787     * @return {@code true} if handler successfully registered, {@code false} otherwise.
788     * @since 2.0.0
789     */
790    boolean addOnSessionEndedHandler(Runnable handler);
791}