Search in sources :

Example 1 with URLRepository

use of org.apache.ivy.plugins.repository.url.URLRepository 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());
}
Also used : URLResource(org.apache.ivy.plugins.repository.url.URLResource) EventManager(org.apache.ivy.core.event.EventManager) Resource(org.apache.ivy.plugins.repository.Resource) URLResource(org.apache.ivy.plugins.repository.url.URLResource) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) CacheResourceOptions(org.apache.ivy.core.cache.CacheResourceOptions) URLRepository(org.apache.ivy.plugins.repository.url.URLRepository)

Example 2 with URLRepository

use of org.apache.ivy.plugins.repository.url.URLRepository 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();
}
Also used : URLResource(org.apache.ivy.plugins.repository.url.URLResource) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) CacheResourceOptions(org.apache.ivy.core.cache.CacheResourceOptions) URLRepository(org.apache.ivy.plugins.repository.url.URLRepository) RelativeURLRepository(org.apache.ivy.osgi.repo.RelativeURLRepository)

Aggregations

CacheResourceOptions (org.apache.ivy.core.cache.CacheResourceOptions)2 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)2 URLRepository (org.apache.ivy.plugins.repository.url.URLRepository)2 URLResource (org.apache.ivy.plugins.repository.url.URLResource)2 EventManager (org.apache.ivy.core.event.EventManager)1 RelativeURLRepository (org.apache.ivy.osgi.repo.RelativeURLRepository)1 Resource (org.apache.ivy.plugins.repository.Resource)1