use of org.apache.ivy.core.report.ArtifactDownloadReport in project ant-ivy by apache.
the class P2DescriptorTest method testResolvePacked.
@Test
public void testResolvePacked() throws Exception {
settings.setDefaultResolver("p2-with-packed");
ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.junit", "4.10.0.v4_10_0_v20120426-0900");
ResolvedModuleRevision rmr = p2WithPackedResolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
assertEquals(1, rmr.getDescriptor().getAllArtifacts().length);
DownloadOptions options = new DownloadOptions();
DownloadReport report = p2WithPackedResolver.download(rmr.getDescriptor().getAllArtifacts(), options);
assertNotNull(report);
assertEquals(1, report.getArtifactsReports().length);
Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0];
ArtifactDownloadReport ar = report.getArtifactReport(artifact);
assertNotNull(ar);
assertEquals(artifact, ar.getArtifact());
assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
assertNotNull(ar.getUnpackedLocalFile());
}
use of org.apache.ivy.core.report.ArtifactDownloadReport in project ant-ivy by apache.
the class P2DescriptorTest method testResolveNotZipped.
@Test
public void testResolveNotZipped() throws Exception {
settings.setDefaultResolver("p2-zipped");
ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.eclipse.e4.core.services", "1.0.0.v20120521-2346");
ResolvedModuleRevision rmr = p2ZippedResolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
assertEquals(1, rmr.getDescriptor().getAllArtifacts().length);
DownloadOptions options = new DownloadOptions();
DownloadReport report = p2ZippedResolver.download(rmr.getDescriptor().getAllArtifacts(), options);
assertNotNull(report);
assertEquals(1, report.getArtifactsReports().length);
Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0];
ArtifactDownloadReport ar = report.getArtifactReport(artifact);
assertNotNull(ar);
assertEquals(artifact, ar.getArtifact());
assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
assertNull(ar.getUnpackedLocalFile());
}
use of org.apache.ivy.core.report.ArtifactDownloadReport in project Saturn by vipshop.
the class IvyGetArtifact method getCachePath.
private Set<URL> getCachePath(ModuleDescriptor md, String[] confs) throws ParseException, IOException {
Set<URL> fs = new HashSet<URL>();
StringBuffer buf = new StringBuffer();
Collection<ArtifactDownloadReport> all = new LinkedHashSet<ArtifactDownloadReport>();
ResolutionCacheManager cacheMgr = ivy.getResolutionCacheManager();
XmlReportParser parser = new XmlReportParser();
for (int i = 0; i < confs.length; i++) {
String resolveId = ResolveOptions.getDefaultResolveId(md);
File report = cacheMgr.getConfigurationResolveReportInCache(resolveId, confs[i]);
parser.parse(report);
all.addAll(Arrays.asList(parser.getArtifactReports()));
}
for (ArtifactDownloadReport artifact : all) {
if (artifact.getLocalFile() != null) {
buf.append(artifact.getLocalFile().getCanonicalPath());
buf.append(File.pathSeparator);
}
}
String[] fs_str = buf.toString().split(File.pathSeparator);
for (String str : fs_str) {
File file = new File(str);
if (file.exists()) {
fs.add(file.toURI().toURL());
}
}
return fs;
}
use of org.apache.ivy.core.report.ArtifactDownloadReport in project ant-ivy by apache.
the class ResolveEngine method download.
/**
* Download an artifact to the cache. Not used internally, useful especially for IDE plugins
* needing to download artifact one by one (for source or javadoc artifact, for instance).
* <p>
* Downloaded artifact file can be accessed using {@link ArtifactDownloadReport#getLocalFile()}.
* </p>
* <p>
* It is possible to track the progression of the download using classical ivy progress
* monitoring feature (see addTransferListener).
* </p>
*
* @param artifact
* the artifact to download
* @param options DownloadOptions
* @return a report concerning the download
* @see #download(ArtifactOrigin, DownloadOptions)
*/
public ArtifactDownloadReport download(Artifact artifact, DownloadOptions options) {
DependencyResolver resolver = settings.getResolver(artifact.getModuleRevisionId());
DownloadReport r = resolver.download(new Artifact[] { artifact }, options);
return r.getArtifactReport(artifact);
}
use of org.apache.ivy.core.report.ArtifactDownloadReport 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