Class ChannelSession
- All Implemented Interfaces:
AutoCloseable
-
Constructor Summary
ConstructorsConstructorDescriptionChannelSession(List<Channel> channelDefinitions, MavenVersionsResolver.Factory factory) Create a ChannelSession.ChannelSession(List<Channel> channelDefinitions, MavenVersionsResolver.Factory factory, int versionResolutionParallelism) Create a ChannelSession. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()findLatestMavenArtifactVersion(String groupId, String artifactId, String extension, String classifier, String baseVersion) Find the latest version of the Maven artifact in the session's channel.Return the list of manifests configured in this channel session.Returns a synthetic Channel where each resolved artifacts (either with exact or latest version) is defined in aStreamwith aversionfield.Get the definitions of channels used by this session.resolveDirectMavenArtifact(String groupId, String artifactId, String extension, String classifier, String version) Resolve the Maven artifact with a specific version without checking the channels.resolveDirectMavenArtifacts(List<ArtifactCoordinate> coordinates) Resolve a list of Maven artifacts with a specific version without checking the channels.resolveMavenArtifact(String groupId, String artifactId, String extension, String classifier, String baseVersion) Resolve the Maven artifact according to the session's channels.resolveMavenArtifacts(List<ArtifactCoordinate> coordinates) Resolve a list of Maven artifacts according to the session's channels.
-
Constructor Details
-
ChannelSession
Create a ChannelSession.- Parameters:
channelDefinitions- the list of channels to resolve Maven artifactfactory- Factory to createMavenVersionsResolverthat are performing the actual Maven resolution.- Throws:
UnresolvedRequiredManifestException- - if a required manifest cannot be resolved either via maven coordinates or in the list of channelsCyclicDependencyException- - if the required manifests form a cyclic dependency
-
ChannelSession
public ChannelSession(List<Channel> channelDefinitions, MavenVersionsResolver.Factory factory, int versionResolutionParallelism) Create a ChannelSession.- Parameters:
channels- the list of channels to resolve Maven artifactfactory- Factory to createMavenVersionsResolverthat are performing the actual Maven resolution.versionResolutionParallelism- Number of threads to use when resolving available artifact versions.- Throws:
UnresolvedRequiredManifestException- - if a required manifest cannot be resolved either via maven coordinates or in the list of channelsCyclicDependencyException- - if the required manifests form a cyclic dependency
-
-
Method Details
-
getRuntimeChannels
Get the definitions of channels used by this session. Returned version contains resolved versions of channel metadata (if applicable).- Returns:
- List of
RuntimeChannels used to resolve artifacts by this session
-
resolveMavenArtifact
public MavenArtifact resolveMavenArtifact(String groupId, String artifactId, String extension, String classifier, String baseVersion) throws NoStreamFoundException, ArtifactTransferException Resolve the Maven artifact according to the session's channels.In order to find the stream corresponding to the Maven artifact, the channels are searched depth-first, starting with the first channel in the list and into their respective required channels. Once the first stream that matches the
groupIdand parameters is found, the Maven artifact will be resolved with the version determined by this stream.- Parameters:
groupId- - requiredartifactId- - requiredextension- - can be nullclassifier- - can be nullbaseVersion- - can be null. The base version is required when the stream for the component specifies multiple versions and needs the base version to determine the appropriate version to resolve.- Returns:
- the Maven Artifact (with a file corresponding to the artifact).
- Throws:
NoStreamFoundException- if none of the channels in theChannelSessionprovides the artifactArtifactTransferException- if the artifact is provided by theChannelSession, but the resolution failed
-
getManifests
Return the list of manifests configured in this channel session.- Returns:
- The list of manifests.
-
resolveMavenArtifacts
public List<MavenArtifact> resolveMavenArtifacts(List<ArtifactCoordinate> coordinates) throws UnresolvedMavenArtifactException Resolve a list of Maven artifacts according to the session's channels.In order to find the stream corresponding to the Maven artifact, the channels are searched depth-first, starting with the first channel in the list and into their respective required channels. Once the first stream that matches the
groupIdand parameters is found, the Maven artifact will be resolved with the version determined by this stream.The returned list of resolved artifacts does not maintain ordering of requested coordinates
- Parameters:
coordinates- list of ArtifactCoordinates to resolve- Returns:
- a list of resolved MavenArtifacts with resolved versions asnd files
- Throws:
NoStreamFoundException- if one or more of the artifact is not provided by any of the channels in theChannelSessionArtifactTransferException- if one or more of the artifacts is provided by theChannelSession, but the resolution failedUnresolvedMavenArtifactException
-
resolveDirectMavenArtifact
public MavenArtifact resolveDirectMavenArtifact(String groupId, String artifactId, String extension, String classifier, String version) throws ArtifactTransferException Resolve the Maven artifact with a specific version without checking the channels.If the artifact is resolved, a stream for it is added to the
getRecordedChannel.- Parameters:
groupId- - requiredartifactId- - requiredextension- - can be nullclassifier- - can be nullversion- - required- Returns:
- the Maven Artifact (with a file corresponding to the artifact).
- Throws:
ArtifactTransferException- if the artifact can not be resolved
-
resolveDirectMavenArtifacts
public List<MavenArtifact> resolveDirectMavenArtifacts(List<ArtifactCoordinate> coordinates) throws ArtifactTransferException Resolve a list of Maven artifacts with a specific version without checking the channels.If the artifact is resolved, a stream for it is added to the
getRecordedChannel.- Parameters:
coordinates- - list of ArtifactCoordinates to check- Returns:
- the Maven Artifact (with a file corresponding to the artifact).
- Throws:
ArtifactTransferException- if the artifact can not be resolved
-
findLatestMavenArtifactVersion
public VersionResult findLatestMavenArtifactVersion(String groupId, String artifactId, String extension, String classifier, String baseVersion) throws NoStreamFoundException Find the latest version of the Maven artifact in the session's channel. The artifact file will not be resolved.- Parameters:
groupId- - requiredartifactId- - requiredextension- - can be nullclassifier- - can be nullbaseVersion- - can be null. The base version is required when the stream for the component specifies multiple versions and needs the base version to determine the appropriate version to resolve.- Returns:
- the latest version if a Maven artifact
- Throws:
NoStreamFoundException- if the latest version cannot be established
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
getRecordedChannel
Returns a synthetic Channel where each resolved artifacts (either with exact or latest version) is defined in aStreamwith aversionfield.This channel can be used to reproduce the same resolution in another ChannelSession.
- Returns:
- a synthetic Channel.
-