final ArtifactDownloadReport adr = new ArtifactDownloadReport(artifacts[i]);
dr.addArtifactReport(adr);
if (eventManager != null) {
eventManager.fireIvyEvent(new NeedArtifactEvent(this, artifacts[i]));
}
ArtifactOrigin origin = cacheManager.getSavedArtifactOrigin(artifacts[i]);
// if we can use origin file, we just ask ivy for the file in cache, and it will
// return
// the original one if possible. If we are not in useOrigin mode, we use the
// getArchivePath
// method which always return a path in the actual cache
File archiveFile = cacheManager.getArchiveFileInCache(artifacts[i], origin, options
.isUseOrigin());
if (archiveFile.exists()) {
Message.verbose("\t[NOT REQUIRED] " + artifacts[i]);
adr.setDownloadStatus(DownloadStatus.NO);
adr.setSize(archiveFile.length());
adr.setArtifactOrigin(origin);
} else {
Artifact artifact = fromSystem(artifacts[i]);
if (!artifact.equals(artifacts[i])) {
Message.verbose("\t" + getName() + "looking for artifact " + artifact
+ " (is " + artifacts[i] + " in system namespace)");
}
long start = System.currentTimeMillis();
try {
ResolvedResource artifactRef = getArtifactRef(artifact, null);
if (artifactRef != null) {
origin = new ArtifactOrigin(artifactRef.getResource().isLocal(),
artifactRef.getResource().getName());
if (useOrigin && artifactRef.getResource().isLocal()) {
Message.verbose("\t[NOT REQUIRED] " + artifacts[i]);
cacheManager.saveArtifactOrigin(artifacts[i], origin);
archiveFile = cacheManager.getArchiveFileInCache(artifacts[i],