From 1f7f266c24a074de37f0064d6e8a222e2715bbdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Thu, 15 Feb 2024 13:33:16 +0100 Subject: [PATCH] Only warn if a referenced repository can not be loaded Currently Tycho fails completely if one of the referenced repositories can not be loaded, as it is hard to control references and they probably are gone over times this makes the repository that use them unusable. This now only warns if a referenced repository can not be loaded instead of failing completely. --- .../p2resolver/TargetPlatformFactoryImpl.java | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetPlatformFactoryImpl.java b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetPlatformFactoryImpl.java index e31cfbb8e8..0ae6282857 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetPlatformFactoryImpl.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetPlatformFactoryImpl.java @@ -406,7 +406,13 @@ private LinkedHashSet gatherExternalInstallableUnits( Set loaded = new HashSet<>(); for (MavenRepositoryLocation location : completeRepositories) { artifactRepositories.add(location.getURL()); - loadMetadataRepository(location, metadataRepositories, loaded, artifactRepositories, includeReferences); + try { + loadMetadataRepository(location, metadataRepositories, loaded, artifactRepositories, includeReferences); + } catch (ProvisionException e) { + String idMessage = location.getId() == null ? "" : " with ID '" + location.getId() + "'"; + throw new RuntimeException( + "Failed to load p2 repository" + idMessage + " from location " + location.getURL(), e); + } } if (includeLocalMavenRepo) { metadataRepositories.add(localMetadataRepository); @@ -429,30 +435,29 @@ private LinkedHashSet gatherExternalInstallableUnits( private void loadMetadataRepository(MavenRepositoryLocation location, List metadataRepositories, Set loaded, Set artifactRepositories, - boolean includeReferences) { + boolean includeReferences) throws ProvisionException { if (loaded.add(location.getURL().normalize())) { - try { - IMetadataRepository repository = remoteMetadataRepositoryManager.loadRepository(location.getURL(), - monitor); - metadataRepositories.add(repository); - if (includeReferences) { - for (IRepositoryReference reference : repository.getReferences()) { - if ((reference.getOptions() | IRepository.ENABLED) != 0) { - if (reference.getType() == IRepository.TYPE_METADATA) { + IMetadataRepository repository = remoteMetadataRepositoryManager.loadRepository(location.getURL(), monitor); + metadataRepositories.add(repository); + if (includeReferences) { + for (IRepositoryReference reference : repository.getReferences()) { + if ((reference.getOptions() | IRepository.ENABLED) != 0) { + if (reference.getType() == IRepository.TYPE_METADATA) { + try { loadMetadataRepository( new MavenRepositoryLocation(reference.getNickname(), reference.getLocation()), metadataRepositories, loaded, artifactRepositories, includeReferences); - } else if (reference.getType() == IRepository.TYPE_ARTIFACT) { - artifactRepositories.add(reference.getLocation()); + } catch (ProvisionException e) { + logger.warn("Loading referenced repository failed: " + e.getMessage(), + logger.isDebugEnabled() ? e : null); } + } else if (reference.getType() == IRepository.TYPE_ARTIFACT) { + artifactRepositories.add(reference.getLocation()); } } } - } catch (ProvisionException e) { - String idMessage = location.getId() == null ? "" : " with ID '" + location.getId() + "'"; - throw new RuntimeException( - "Failed to load p2 repository" + idMessage + " from location " + location.getURL(), e); } + } }