private File downloadReference()

in src/main/java/org/apache/maven/plugins/artifact/buildinfo/ReferenceBuildinfoUtil.java [272:299]


    private File downloadReference(RemoteRepository repo, Artifact artifact)
            throws MojoExecutionException, ArtifactResolutionException {
        try {
            ArtifactRequest request = new ArtifactRequest();
            request.setArtifact(artifact);
            request.setRepositories(Collections.singletonList(repo));

            ArtifactResult result =
                    repoSystem.resolveArtifact(new NoWorkspaceRepositorySystemSession(repoSession), request);
            File resultFile = result.getArtifact().getFile();
            File destFile = getReference(artifact.getGroupId(), resultFile);

            Files.copy(
                    resultFile.toPath(),
                    destFile.toPath(),
                    LinkOption.NOFOLLOW_LINKS,
                    StandardCopyOption.REPLACE_EXISTING);

            return destFile;
        } catch (ArtifactResolutionException are) {
            if (are.getResult().isMissing()) {
                throw are;
            }
            throw new MojoExecutionException("Error resolving reference artifact " + artifact, are);
        } catch (IOException ioe) {
            throw new MojoExecutionException("Error copying reference artifact " + artifact, ioe);
        }
    }