in src/main/java/org/apache/maven/plugins/artifact/buildinfo/ReferenceBuildinfoUtil.java [283:313]
private File downloadReference(RemoteRepository repo, Artifact artifact)
throws MojoExecutionException, ArtifactNotFoundException {
try {
ArtifactRequest request = new ArtifactRequest();
request.setArtifact(new DefaultArtifact(
artifact.getGroupId(),
artifact.getArtifactId(),
artifact.getClassifier(),
(artifact.getArtifactHandler() != null)
? artifact.getArtifactHandler().getExtension()
: artifact.getType(),
artifact.getVersion()));
request.setRepositories(Collections.singletonList(repo));
ArtifactResult result =
repoSystem.resolveArtifact(new NoWorkspaceRepositorySystemSession(repoSession), request);
File resultFile = result.getArtifact().getFile();
File destFile = getReference(artifact.getGroupId(), resultFile);
FileUtils.copyFile(resultFile, destFile);
return destFile;
} catch (org.eclipse.aether.resolution.ArtifactResolutionException are) {
if (are.getResult().isMissing()) {
throw new ArtifactNotFoundException("Artifact not found " + artifact, artifact);
}
throw new MojoExecutionException("Error resolving reference artifact " + artifact, are);
} catch (IOException ioe) {
throw new MojoExecutionException("Error copying reference artifact " + artifact, ioe);
}
}