use of org.apache.ivy.plugins.repository.url.URLResource in project ant-ivy by apache.
the class BasicResolver method getArtifactRef.
protected ResolvedResource getArtifactRef(Artifact artifact, Date date) {
IvyContext.getContext().set(getName() + ".artifact", artifact);
try {
ResolvedResource ret = findArtifactRef(artifact, date);
if (ret == null && artifact.getUrl() != null) {
URL url = artifact.getUrl();
Message.verbose("\tusing url for " + artifact + ": " + url);
logArtifactAttempt(artifact, url.toExternalForm());
Resource resource;
if ("file".equals(url.getProtocol())) {
File f;
try {
f = new File(new URI(url.toExternalForm()));
} catch (URISyntaxException e) {
// unexpected, try to get the best of it
f = new File(url.getPath());
}
resource = new FileResource(new FileRepository(), f);
} else {
resource = new URLResource(url, this.getTimeoutConstraint());
}
ret = new ResolvedResource(resource, artifact.getModuleRevisionId().getRevision());
}
return ret;
} finally {
IvyContext.getContext().set(getName() + ".artifact", null);
}
}
use of org.apache.ivy.plugins.repository.url.URLResource in project ant-ivy by apache.
the class JarResolver method setSettings.
@Override
public void setSettings(ResolverSettings settings) {
super.setSettings(settings);
if (url == null) {
return;
}
// let's resolve the url
ArtifactDownloadReport report;
EventManager eventManager = getEventManager();
try {
if (eventManager != null) {
getRepository().addTransferListener(eventManager);
}
Resource jarResource = new URLResource(url, this.getTimeoutConstraint());
CacheResourceOptions options = new CacheResourceOptions();
report = getRepositoryCacheManager().downloadRepositoryResource(jarResource, "jarrepository", "jar", "jar", options, new URLRepository());
} finally {
if (eventManager != null) {
getRepository().removeTransferListener(eventManager);
}
}
if (report.getDownloadStatus() == DownloadStatus.FAILED) {
throw new RuntimeException("The jar file " + url.toExternalForm() + " could not be downloaded (" + report.getDownloadDetails() + ")");
}
setJarFile(report.getLocalFile());
}
use of org.apache.ivy.plugins.repository.url.URLResource in project ant-ivy by apache.
the class MirroredURLResolver method downloadMirrorList.
private File downloadMirrorList() {
final URLRepository urlRepository = new URLRepository(this.getTimeoutConstraint());
if (getEventManager() != null) {
urlRepository.addTransferListener(getEventManager());
}
final URLResource mirrorResource = new URLResource(mirrorListUrl, this.getTimeoutConstraint());
CacheResourceOptions options = new CacheResourceOptions();
ArtifactDownloadReport report = getRepositoryCacheManager().downloadRepositoryResource(mirrorResource, "mirrorlist", "text", "txt", options, urlRepository);
return report.getLocalFile();
}
use of org.apache.ivy.plugins.repository.url.URLResource 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.plugins.repository.url.URLResource in project ant-ivy by apache.
the class ResolveEngine method resolve.
/**
* Resolve dependencies of a module described by an ivy file.
*
* @param ivySource URL
* @param options ResolveOptions
* @return ResolveReport
* @throws ParseException if something goes wrong
* @throws IOException if something goes wrong
*/
public ResolveReport resolve(URL ivySource, ResolveOptions options) throws ParseException, IOException {
URLResource res = new URLResource(ivySource);
ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(res);
Message.verbose("using " + parser + " to parse " + ivySource);
ModuleDescriptor md = parser.parseDescriptor(settings, ivySource, options.isValidate());
String revision = options.getRevision();
if (revision == null && md.getResolvedModuleRevisionId().getRevision() == null) {
revision = Ivy.getWorkingRevision();
}
if (revision != null) {
md.setResolvedModuleRevisionId(ModuleRevisionId.newInstance(md.getModuleRevisionId(), revision));
}
return resolve(md, options);
}
Aggregations