use of org.apache.ivy.core.event.download.PrepareDownloadEvent in project ant-ivy by apache.
the class ResolveEngine method downloadArtifacts.
public void downloadArtifacts(ResolveReport report, Filter<Artifact> artifactFilter, DownloadOptions options) {
long start = System.currentTimeMillis();
eventManager.fireIvyEvent(new PrepareDownloadEvent(report.getArtifacts().toArray(new Artifact[report.getArtifacts().size()])));
long totalSize = 0;
for (IvyNode dependency : report.getDependencies()) {
checkInterrupted();
// download artifacts required in all asked configurations
if (!dependency.isCompletelyEvicted() && !dependency.hasProblem() && dependency.getModuleRevision() != null) {
DependencyResolver resolver = dependency.getModuleRevision().getArtifactResolver();
Artifact[] selectedArtifacts = dependency.getSelectedArtifacts(artifactFilter);
DownloadReport dReport = resolver.download(selectedArtifacts, options);
for (ArtifactDownloadReport adr : dReport.getArtifactsReports()) {
if (adr.getDownloadStatus() == DownloadStatus.FAILED) {
if (adr.getArtifact().getExtraAttribute("ivy:merged") != null) {
Message.warn("\tmerged artifact not found: " + adr.getArtifact() + ". It was required in " + adr.getArtifact().getExtraAttribute("ivy:merged"));
} else {
Message.warn("\t" + adr);
resolver.reportFailure(adr.getArtifact());
}
} else if (adr.getDownloadStatus() == DownloadStatus.SUCCESSFUL) {
totalSize += adr.getSize();
}
}
// update concerned reports
for (String dconf : dependency.getRootModuleConfigurations()) {
// (as described by the Dependency object)
if (dependency.isEvicted(dconf) || dependency.isBlacklisted(dconf)) {
report.getConfigurationReport(dconf).addDependency(dependency);
} else {
report.getConfigurationReport(dconf).addDependency(dependency, dReport);
}
}
}
}
report.setDownloadTime(System.currentTimeMillis() - start);
report.setDownloadSize(totalSize);
}
Aggregations