Class DependencyDownloader


  • @Component(role=DependencyDownloader.class,
               hint="default")
    public class DependencyDownloader
    extends java.lang.Object
    Downloads artifacts for project dependencies and plugins. This class maintains two separate sessions with separate caches for project and plugin dependencies so all artifacts are resolved for all remote repository contexts.

    The downloader must be initialized by calling init(ProjectBuildingRequest, List, Log) before any of its other methods my be used.

    This class only works for maven versions >=3.1

    Author:
    Andreas Janning andreas.janning@qaware.de
    • Constructor Detail

      • DependencyDownloader

        public DependencyDownloader()
    • Method Detail

      • init

        public void init​(org.apache.maven.project.ProjectBuildingRequest buildingRequest,
                         java.util.List<org.apache.maven.project.MavenProject> reactorProjects,
                         org.apache.maven.plugin.logging.Log logger)
        Initialize the DependencyDownloader
        Parameters:
        buildingRequest - a buildingRequest containing the maven session and Repositories to be used to download artifacts
        reactorProjects - the reactorProjects of the current build used to exclude reactor artifacts from the dependency download.
        logger - used to log infos and warnings.
      • enableDownloadSources

        public void enableDownloadSources()
      • enableDownloadJavadoc

        public void enableDownloadJavadoc()
      • downloadArtifacts

        public void downloadArtifacts​(java.util.Collection<ArtifactWithRepoType> artifacts)
      • resolveDependencies

        public java.util.Set<ArtifactWithRepoType> resolveDependencies​(org.apache.maven.project.MavenProject project)
        Download all dependencies of a maven project including transitive dependencies. Dependencies that refer to an artifact in the current reactor build are ignored. Transitive dependencies that are marked as optional are ignored Transitive dependencies with the scopes "test", "system" and "provided" are ignored.
        Parameters:
        project - the project to download the dependencies for.
      • resolvePlugin

        public java.util.Set<ArtifactWithRepoType> resolvePlugin​(org.apache.maven.model.Plugin plugin)
        Download a plugin, all of its transitive dependencies and dependencies declared on the plugin declaration.

        Dependencies and plugin artifacts that refer to an artifact in the current reactor build are ignored. Transitive dependencies that are marked as optional are ignored Transitive dependencies with the scopes "test", "system" and "provided" are ignored.

        Parameters:
        plugin - the plugin to download
      • resolveDynamicDependency

        public java.util.Set<ArtifactWithRepoType> resolveDynamicDependency​(DynamicDependency dynamicDependency)
        Download a single dependency and all of its transitive dependencies that is needed by the build without appearing in any dependency tree

        Dependencies and plugin artifacts that refer to an artifact in the current reactor build are ignored. Transitive dependencies that are marked as optional are ignored Transitive dependencies with the scopes "test", "system" and "provided" are ignored.

        Parameters:
        dynamicDependency - the dependency to download
      • getErrors

        public java.util.List<java.lang.Exception> getErrors()
        Returns:
        a List of errors encountered during the downloading of artifacts since this class has been initialized.