use of org.apache.ivy.plugins.repository.url.URLResource in project ant-ivy by apache.
the class PomModuleDescriptorParserTest method createIvySettingsForParentLicenseTesting.
private IvySettings createIvySettingsForParentLicenseTesting(final String parentPomFileName, final String parentOrgName, final String parentModuleName) throws Exception {
final URL parentPomURL = this.getClass().getResource(parentPomFileName);
assertNotNull("Could not find " + parentPomFileName, parentPomURL);
final PomReader parentPomReader = new PomReader(parentPomURL, new URLResource(parentPomURL));
final License[] parentLicenses = parentPomReader.getLicenses();
assertNotNull("Missing licenses in parent pom " + parentPomFileName, parentLicenses);
assertEquals("Unexpected number of licenses in parent pom " + parentPomFileName, 1, parentLicenses.length);
final DependencyResolver dependencyResolver = new MockedDependencyResolver() {
@Override
protected ModuleDescriptor getModuleDescriptor(DependencyDescriptor dependencyDescriptor) {
final String depOrg = dependencyDescriptor.getDependencyId().getOrganisation();
final String depModuleName = dependencyDescriptor.getDependencyId().getName();
if (depOrg.equals(parentOrgName) && depModuleName.equals(parentModuleName)) {
final DefaultModuleDescriptor moduleDescriptor = DefaultModuleDescriptor.newDefaultInstance(dependencyDescriptor.getDependencyRevisionId());
for (final License license : parentLicenses) {
moduleDescriptor.addLicense(license);
}
return moduleDescriptor;
} else {
return super.getModuleDescriptor(dependencyDescriptor);
}
}
};
final IvySettings ivySettings = new IvySettings();
ivySettings.setDictatorResolver(dependencyResolver);
return ivySettings;
}
use of org.apache.ivy.plugins.repository.url.URLResource in project ant-ivy by apache.
the class AbstractOSGiResolver method findArtifactRef.
@Override
public ResolvedResource findArtifactRef(Artifact artifact, Date date) {
URL url = artifact.getUrl();
if (url == null) {
// not an artifact resolved by this resolver
return null;
}
Message.verbose("\tusing url for " + artifact + ": " + url);
logArtifactAttempt(artifact, url.toExternalForm());
final Resource resource = new URLResource(url, this.getTimeoutConstraint());
return new ResolvedResource(resource, artifact.getModuleRevisionId().getRevision());
}
use of org.apache.ivy.plugins.repository.url.URLResource in project ant-ivy by apache.
the class OBRResolver method init.
@Override
protected void init() {
if (repoXmlFile != null && repoXmlURL != null) {
throw new RuntimeException("The OBR repository resolver " + getName() + " couldn't be configured: repoXmlFile and repoXmlUrl cannot be set both");
}
if (repoXmlFile != null) {
File f = new File(repoXmlFile);
loadRepoFromFile(f.getParentFile().toURI(), f, repoXmlFile);
} else if (repoXmlURL != null) {
final URL url;
try {
url = new URL(repoXmlURL);
} catch (MalformedURLException e) {
throw new RuntimeException("The OBR repository resolver " + getName() + " couldn't be configured: repoXmlURL '" + repoXmlURL + "' is not an URL");
}
ArtifactDownloadReport report;
EventManager eventManager = getEventManager();
try {
if (eventManager != null) {
getRepository().addTransferListener(eventManager);
}
final Resource obrResource = new URLResource(url, this.getTimeoutConstraint());
CacheResourceOptions options = new CacheResourceOptions();
if (metadataTtl != null) {
options.setTtl(metadataTtl);
}
if (forceMetadataUpdate != null) {
options.setForce(forceMetadataUpdate);
}
report = getRepositoryCacheManager().downloadRepositoryResource(obrResource, "obr", "obr", "xml", options, getRepository());
} finally {
if (eventManager != null) {
getRepository().removeTransferListener(eventManager);
}
}
URI baseURI;
try {
baseURI = new URI(repoXmlURL);
} catch (URISyntaxException e) {
throw new RuntimeException("illegal uri");
}
loadRepoFromFile(baseURI, report.getLocalFile(), repoXmlURL);
} else {
throw new RuntimeException("The OBR repository resolver " + getName() + " couldn't be configured: repoXmlFile or repoXmlUrl is missing");
}
}
use of org.apache.ivy.plugins.repository.url.URLResource in project ant-ivy by apache.
the class UpdateSiteLoader method loadSite.
private UpdateSite loadSite(URI repoUri) throws IOException, SAXException {
URI siteUri = normalizeSiteUri(repoUri, null);
URL u = siteUri.resolve("site.xml").toURL();
final URLResource res = new URLResource(u, this.timeoutConstraint);
ArtifactDownloadReport report = repositoryCacheManager.downloadRepositoryResource(res, "site", "updatesite", "xml", options, urlRepository);
if (report.getDownloadStatus() == DownloadStatus.FAILED) {
return null;
}
try (InputStream in = new FileInputStream(report.getLocalFile())) {
UpdateSite site = EclipseUpdateSiteParser.parse(in);
site.setUri(normalizeSiteUri(site.getUri(), siteUri));
return site;
}
}
use of org.apache.ivy.plugins.repository.url.URLResource in project ant-ivy by apache.
the class UpdateSiteLoader method loadFromDigest.
private UpdateSiteDescriptor loadFromDigest(UpdateSite site) throws IOException, SAXException {
URI digestBaseUri = site.getDigestUri();
if (digestBaseUri == null) {
digestBaseUri = site.getUri();
} else if (!digestBaseUri.isAbsolute()) {
digestBaseUri = site.getUri().resolve(digestBaseUri);
}
URL digest = digestBaseUri.resolve("digest.zip").toURL();
Message.verbose("\tReading " + digest);
final URLResource res = new URLResource(digest, this.timeoutConstraint);
ArtifactDownloadReport report = repositoryCacheManager.downloadRepositoryResource(res, "digest", "digest", "zip", options, urlRepository);
if (report.getDownloadStatus() == DownloadStatus.FAILED) {
return null;
}
try (InputStream in = new FileInputStream(report.getLocalFile())) {
ZipInputStream zipped = findEntry(in, "digest.xml");
if (zipped == null) {
return null;
}
return UpdateSiteDigestParser.parse(zipped, site);
}
}
Aggregations