Class ChannelSession

  • All Implemented Interfaces:
    AutoCloseable

    public class ChannelSession
    extends Object
    implements AutoCloseable
    A ChannelSession is used to install and resolve Maven Artifacts inside a single scope.
    • Constructor Detail

      • ChannelSession

        public ChannelSession​(List<Channel> channels,
                              MavenVersionsResolver.Factory factory)
        Create a ChannelSession.
        Parameters:
        channels - the list of channels to resolve Maven artifact
        factory - Factory to create MavenVersionsResolver that are performing the actual Maven resolution.
    • Method Detail

      • resolveMavenArtifact

        public MavenArtifact resolveMavenArtifact​(String groupId,
                                                  String artifactId,
                                                  String extension,
                                                  String classifier)
                                           throws UnresolvedMavenArtifactException
        Resolve the Maven artifact according to the session's channels.
        Parameters:
        groupId - - required
        artifactId - - required
        extension - - can be null
        classifier - - can be null
        Returns:
        the Maven Artifact (with a file corresponding to the artifact).
        Throws:
        UnresolvedMavenArtifactException - if the latest version can not be resolved or the artifact itself can not be resolved
      • resolveDirectMavenArtifact

        public MavenArtifact resolveDirectMavenArtifact​(String groupId,
                                                        String artifactId,
                                                        String extension,
                                                        String classifier,
                                                        String version)
                                                 throws UnresolvedMavenArtifactException
        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 - - required
        artifactId - - required
        extension - - can be null
        classifier - - can be null
        version - - required
        Returns:
        the Maven Artifact (with a file corresponding to the artifact).
        Throws:
        UnresolvedMavenArtifactException - if the artifact can not be resolved
      • findLatestMavenArtifactVersion

        public String findLatestMavenArtifactVersion​(String groupId,
                                                     String artifactId,
                                                     String extension,
                                                     String classifier)
                                              throws UnresolvedMavenArtifactException
        Find the latest version of the Maven artifact in the session's channel. The artifact file will not be resolved.
        Parameters:
        groupId - - required
        artifactId - - required
        extension - - can be null
        classifier - - can be null
        Returns:
        the latest version if a Maven artifact
        Throws:
        UnresolvedMavenArtifactException - if the latest version cannot be established
      • getRecordedChannel

        public Channel getRecordedChannel()
        Returns a synthetic Channel where each resolved artifacts (either with exact or latest version) is defined in a Stream with a version field. This channel can be used to reproduce the same resolution in another ChannelSession.
        Returns:
        a synthetic Channel.