Skip to content

Commit

Permalink
Check whether the platform catalog couldn't be resolved from a Maven …
Browse files Browse the repository at this point in the history
…mirror and indicate that it might not be up-to-date in the error message
  • Loading branch information
aloubyansky committed Aug 26, 2021
1 parent bc6acc3 commit 397e681
Showing 1 changed file with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
import io.quarkus.registry.util.PlatformArtifacts;
import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import java.util.Objects;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.transfer.ArtifactNotFoundException;

public class MavenPlatformExtensionsResolver implements RegistryPlatformExtensionsResolver {

Expand Down Expand Up @@ -44,13 +47,36 @@ public ExtensionCatalog resolvePlatformExtensions(ArtifactCoords platformCoords)
try {
jsonPath = artifactResolver.resolve(catalogArtifact);
} catch (Exception e) {
throw new RegistryResolutionException("Failed to resolve Quarkus extensions catalog " + catalogArtifact,
e);
RemoteRepository repo = null;
Throwable t = e;
while (t != null) {
if (t instanceof ArtifactNotFoundException) {
repo = ((ArtifactNotFoundException) t).getRepository();
break;
}
t = t.getCause();
}
final StringBuilder buf = new StringBuilder();
buf.append("Failed to resolve Quarkus extension catalog ").append(catalogArtifact);
if (repo != null) {
buf.append(" from ").append(repo.getId()).append(" (").append(repo.getUrl()).append(")");
final List<RemoteRepository> mirrored = repo.getMirroredRepositories();
if (!mirrored.isEmpty()) {
buf.append(" which is a mirror of ");
buf.append(mirrored.get(0).getId()).append(" (").append(mirrored.get(0).getUrl()).append(")");
for (int i = 1; i < mirrored.size(); ++i) {
buf.append(", ").append(mirrored.get(i).getId()).append(" (").append(mirrored.get(i).getUrl())
.append(")");
}
buf.append(" and is possibly not yet fully synched right now");
}
}
throw new RegistryResolutionException(buf.toString(), e);
}
try {
return JsonCatalogMapperHelper.deserialize(jsonPath, JsonExtensionCatalog.class);
} catch (IOException e) {
throw new RegistryResolutionException("Failed to parse Quarkus extensions catalog " + jsonPath, e);
throw new RegistryResolutionException("Failed to parse Quarkus extension catalog " + jsonPath, e);
}
}

Expand Down

0 comments on commit 397e681

Please sign in to comment.