use of org.apache.ivy.core.report.ArtifactDownloadReport in project ant-ivy by apache.
the class IvyCacheFileset method doExecute.
public void doExecute() throws BuildException {
prepareAndCheck();
if (setid == null) {
throw new BuildException("setid is required in ivy cachefileset");
}
try {
final List<ArtifactDownloadReport> artifactDownloadReports = getArtifactReports();
if (artifactDownloadReports.isEmpty()) {
// generate an empty fileset
final FileSet emptyFileSet = new EmptyFileSet();
emptyFileSet.setProject(getProject());
getProject().addReference(setid, emptyFileSet);
return;
}
// find a common base dir of the resolved artifacts
final File baseDir = this.requireCommonBaseDir(artifactDownloadReports);
final FileSet fileset = new FileSet();
fileset.setDir(baseDir);
fileset.setProject(getProject());
// enroll each of the artifact files into the fileset
for (final ArtifactDownloadReport artifactDownloadReport : artifactDownloadReports) {
if (artifactDownloadReport.getLocalFile() == null) {
continue;
}
final NameEntry ne = fileset.createInclude();
ne.setName(getPath(baseDir, artifactDownloadReport.getLocalFile()));
}
getProject().addReference(setid, fileset);
} catch (Exception ex) {
throw new BuildException("impossible to build ivy cache fileset: " + ex, ex);
}
}
use of org.apache.ivy.core.report.ArtifactDownloadReport in project ant-ivy by apache.
the class IvyCachePath method doExecute.
public void doExecute() throws BuildException {
prepareAndCheck();
if (pathid == null) {
if (id == null) {
throw new BuildException("pathid is required in ivy classpath");
}
pathid = id;
log("ID IS DEPRECATED, PLEASE USE PATHID INSTEAD", Project.MSG_WARN);
}
try {
Path path = new Path(getProject());
getProject().addReference(pathid, path);
for (ArtifactDownloadReport adr : getArtifactReports()) {
File f = adr.getLocalFile();
if (adr.getUnpackedLocalFile() != null) {
f = adr.getUnpackedLocalFile();
}
addToPath(path, f);
}
} catch (Exception ex) {
throw new BuildException("impossible to build ivy path: " + ex, ex);
}
}
use of org.apache.ivy.core.report.ArtifactDownloadReport in project ant-ivy by apache.
the class UpdateSiteLoader method loadFromSite.
private UpdateSiteDescriptor loadFromSite(UpdateSite site) throws IOException, SAXException {
UpdateSiteDescriptor repoDescriptor = new UpdateSiteDescriptor(site.getUri(), ExecutionEnvironmentProfileProvider.getInstance());
for (EclipseFeature feature : site.getFeatures()) {
URL url = site.getUri().resolve(feature.getUrl()).toURL();
final URLResource res = new URLResource(url, this.timeoutConstraint);
ArtifactDownloadReport report = repositoryCacheManager.downloadRepositoryResource(res, feature.getId(), "feature", "jar", options, urlRepository);
if (report.getDownloadStatus() == DownloadStatus.FAILED) {
return null;
}
try (InputStream in = new FileInputStream(report.getLocalFile())) {
ZipInputStream zipped = findEntry(in, "feature.xml");
if (zipped == null) {
return null;
}
EclipseFeature f = FeatureParser.parse(zipped);
f.setURL(feature.getUrl());
repoDescriptor.addFeature(f);
}
}
return repoDescriptor;
}
use of org.apache.ivy.core.report.ArtifactDownloadReport in project ant-ivy by apache.
the class FileSystemResolverTest method testSHA256Checksum.
/**
* Tests that <code>SHA-256</code> algorithm can be used for checksums on resolvers
*
* @throws Exception if something goes wrong
*/
@Test
public void testSHA256Checksum() throws Exception {
final FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("sha256-checksum-resolver");
resolver.setSettings(settings);
resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/checksums/[module]/[revision]/[artifact]-[revision].[ext]");
resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/checksums/[module]/[revision]/[artifact]-[revision].[ext]");
resolver.setChecksums("SHA-256");
final ModuleRevisionId mrid = ModuleRevisionId.newInstance("test", "allright", "2.0");
final ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull("Resolved module revision was null for " + mrid, rmr);
final DownloadReport dr = resolver.download(rmr.getDescriptor().getAllArtifacts(), getDownloadOptions());
final ArtifactDownloadReport[] successfulDownloadReports = dr.getArtifactsReports(DownloadStatus.SUCCESSFUL);
assertNotNull("No artifacts were downloaded successfully", successfulDownloadReports);
assertEquals("Unexpected number of successfully downloaded artifacts", 1, successfulDownloadReports.length);
final ArtifactDownloadReport successfulDownloadReport = successfulDownloadReports[0];
final Artifact downloadedArtifact = successfulDownloadReport.getArtifact();
assertEquals("Unexpected organization of downloaded artifact", "test", downloadedArtifact.getModuleRevisionId().getOrganisation());
assertEquals("Unexpected module of downloaded artifact", "allright", downloadedArtifact.getModuleRevisionId().getModuleId().getName());
assertEquals("Unexpected revision of downloaded artifact", "2.0", downloadedArtifact.getModuleRevisionId().getRevision());
}
use of org.apache.ivy.core.report.ArtifactDownloadReport in project ant-ivy by apache.
the class FileSystemResolverTest method testSHA512Checksum.
/**
* Tests that <code>SHA-512</code> algorithm can be used for checksums on resolvers
*
* @throws Exception if something goes wrong
*/
@Test
public void testSHA512Checksum() throws Exception {
final FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("sha256-checksum-resolver");
resolver.setSettings(settings);
resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/checksums/[module]/[revision]/[artifact]-[revision].[ext]");
resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/checksums/[module]/[revision]/[artifact]-[revision].[ext]");
resolver.setChecksums("SHA-512");
final ModuleRevisionId mrid = ModuleRevisionId.newInstance("test", "allright", "3.0");
final ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull("Resolved module revision was null for " + mrid, rmr);
final DownloadReport dr = resolver.download(rmr.getDescriptor().getAllArtifacts(), getDownloadOptions());
final ArtifactDownloadReport[] successfulDownloadReports = dr.getArtifactsReports(DownloadStatus.SUCCESSFUL);
assertNotNull("No artifacts were downloaded successfully", successfulDownloadReports);
assertEquals("Unexpected number of successfully downloaded artifacts", 1, successfulDownloadReports.length);
final ArtifactDownloadReport successfulDownloadReport = successfulDownloadReports[0];
final Artifact downloadedArtifact = successfulDownloadReport.getArtifact();
assertEquals("Unexpected organization of downloaded artifact", "test", downloadedArtifact.getModuleRevisionId().getOrganisation());
assertEquals("Unexpected module of downloaded artifact", "allright", downloadedArtifact.getModuleRevisionId().getModuleId().getName());
assertEquals("Unexpected revision of downloaded artifact", "3.0", downloadedArtifact.getModuleRevisionId().getRevision());
}
Aggregations