Skip to content

Commit

Permalink
Only warn if a referenced repository can not be loaded
Browse files Browse the repository at this point in the history
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.

(cherry picked from commit 1f7f266)
  • Loading branch information
laeubi committed Feb 15, 2024
1 parent 4a83152 commit 6beb741
Showing 1 changed file with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,13 @@ private LinkedHashSet<IInstallableUnit> gatherExternalInstallableUnits(
Set<URI> 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);
Expand All @@ -429,30 +435,29 @@ private LinkedHashSet<IInstallableUnit> gatherExternalInstallableUnits(

private void loadMetadataRepository(MavenRepositoryLocation location,
List<IMetadataRepository> metadataRepositories, Set<URI> loaded, Set<URI> 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);
}

}
}

Expand Down

0 comments on commit 6beb741

Please sign in to comment.