Search in sources :

Example 1 with RelativeURLRepository

use of org.apache.ivy.osgi.repo.RelativeURLRepository in project ant-ivy by apache.

the class MirroredURLResolver method setupMirrors.

private void setupMirrors() {
    File mirrorListFile = downloadMirrorList();
    List<String> mirrorBaseUrls;
    try {
        mirrorBaseUrls = readMirrorList(mirrorListFile);
    } catch (IOException e) {
        throw new IllegalStateException("The mirror list could not be read from " + mirrorListUrl + " (" + e.getMessage() + ")");
    }
    List<Repository> repositories = new ArrayList<>();
    for (String baseUrl : mirrorBaseUrls) {
        URL url = null;
        try {
            url = new URL(baseUrl);
        } catch (MalformedURLException e) {
            Message.warn("In the mirror list from " + mirrorListUrl + ", an incorrect url has been found and will then not be used: " + baseUrl);
        }
        if (url != null) {
            final RelativeURLRepository repo = new RelativeURLRepository(url, this.getTimeoutConstraint());
            repositories.add(repo);
        }
    }
    ((ChainedRepository) getRepository()).setRepositories(repositories);
}
Also used : ChainedRepository(org.apache.ivy.plugins.repository.url.ChainedRepository) URLRepository(org.apache.ivy.plugins.repository.url.URLRepository) RelativeURLRepository(org.apache.ivy.osgi.repo.RelativeURLRepository) Repository(org.apache.ivy.plugins.repository.Repository) MalformedURLException(java.net.MalformedURLException) ArrayList(java.util.ArrayList) ChainedRepository(org.apache.ivy.plugins.repository.url.ChainedRepository) IOException(java.io.IOException) RelativeURLRepository(org.apache.ivy.osgi.repo.RelativeURLRepository) File(java.io.File) URL(java.net.URL)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 RelativeURLRepository (org.apache.ivy.osgi.repo.RelativeURLRepository)1 Repository (org.apache.ivy.plugins.repository.Repository)1 ChainedRepository (org.apache.ivy.plugins.repository.url.ChainedRepository)1 URLRepository (org.apache.ivy.plugins.repository.url.URLRepository)1