Skip to content

Fallback to the default platform catalog if available registries do not provide any catalog #21339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -328,59 +328,56 @@ static ExtensionCatalog resolveExtensionsCatalog(AbstractMojo mojo, String group
ExtensionCatalogResolver catalogResolver, MavenArtifactResolver artifactResolver, MessageWriter log)
throws MojoExecutionException {

if (!catalogResolver.hasRegistries()) {
groupId = getPlatformGroupId(mojo, groupId);
artifactId = getPlatformArtifactId(artifactId);
version = getPlatformVersion(mojo, version);
final StringBuilder buf = new StringBuilder();
buf.append("The extension catalog will be narrowed to the ").append(groupId).append(":").append(artifactId)
.append(":").append(version).append(" platform release.");
buf.append(
" To enable the complete Quarkiverse extension catalog along with the latest recommended platform releases, please, make sure ");
if (QuarkusProjectHelper.isRegistryClientEnabled()) {
buf.append("the following registries are accessible from your environment: ");
final Iterator<RegistryConfig> iterator = RegistriesConfigLocator.resolveConfig().getRegistries().iterator();
int i = 0;
while (iterator.hasNext()) {
final RegistryConfig r = iterator.next();
if (r.isEnabled()) {
if (i++ > 0) {
buf.append(", ");
}
buf.append(r.getId());
}
if (catalogResolver.hasRegistries()) {
try {
return isBlank(groupId) && isBlank(artifactId) && isBlank(version)
? catalogResolver.resolveExtensionCatalog()
: catalogResolver.resolveExtensionCatalog(Collections.singletonList(
new ArtifactCoords(getPlatformGroupId(mojo, groupId), getPlatformArtifactId(artifactId), "pom",
getPlatformVersion(mojo, version))));
} catch (RegistryResolutionException e) {
final StringBuilder buf = new StringBuilder();
buf.append("Failed to resolve the extension catalog");
Throwable cause = e.getCause();
while (cause != null) {
buf.append(": ").append(cause.getLocalizedMessage());
cause = cause.getCause();
}

} else {
buf.append("the extension registry client is enabled.");
log.warn(buf.toString());
}
log.warn(buf.toString());
return ToolsUtils.resolvePlatformDescriptorDirectly(groupId, artifactId, version, artifactResolver, log);
}

final ExtensionCatalog catalog;
try {
catalog = isBlank(groupId) && isBlank(artifactId) && isBlank(version)
? catalogResolver.resolveExtensionCatalog()
: catalogResolver.resolveExtensionCatalog(Collections.singletonList(
new ArtifactCoords(getPlatformGroupId(mojo, groupId), getPlatformArtifactId(artifactId), "pom",
getPlatformVersion(mojo, version))));
} catch (RegistryResolutionException e) {
throw new MojoExecutionException("Failed to resolve the extension catalog", e);
}
return resolveExtensionCatalogDirectly(mojo, groupId, artifactId, version, catalogResolver, artifactResolver, log);
}

if (catalog == null) {
final StringBuilder buf = new StringBuilder();
buf.append(
"The Quarkus registry client failed to resolve the extension catalog. Please make sure the following registries are accessible from your environment: ");
final Iterator<RegistryConfig> r = catalogResolver.getConfig().getRegistries().iterator();
buf.append(r.next().getId());
while (r.hasNext()) {
buf.append(", ").append(r.next().getId());
private static ExtensionCatalog resolveExtensionCatalogDirectly(AbstractMojo mojo, String groupId, String artifactId,
String version,
ExtensionCatalogResolver catalogResolver, MavenArtifactResolver artifactResolver, MessageWriter log) {
groupId = getPlatformGroupId(mojo, groupId);
artifactId = getPlatformArtifactId(artifactId);
version = getPlatformVersion(mojo, version);
final StringBuilder buf = new StringBuilder();
buf.append("The extension catalog will be narrowed to the ").append(groupId).append(":").append(artifactId)
.append(":").append(version).append(" platform release.");
buf.append(
" To enable the complete Quarkiverse extension catalog along with the latest recommended platform releases, please, make sure ");
if (QuarkusProjectHelper.isRegistryClientEnabled()) {
buf.append("the following registries are accessible from your environment: ");
final Iterator<RegistryConfig> iterator = RegistriesConfigLocator.resolveConfig().getRegistries().iterator();
int i = 0;
while (iterator.hasNext()) {
final RegistryConfig r = iterator.next();
if (r.isEnabled()) {
if (i++ > 0) {
buf.append(", ");
}
buf.append(r.getId());
}
}
throw new MojoExecutionException(buf.toString());
} else {
buf.append("the extension registry client is enabled.");
}
return catalog;
log.warn(buf.toString());
return ToolsUtils.resolvePlatformDescriptorDirectly(groupId, artifactId, version, artifactResolver, log);
}

private void askTheUserForMissingValues() throws MojoExecutionException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,24 @@ void appendAllNonPlatformExtensions() throws RegistryResolutionException {

ExtensionCatalog build() throws RegistryResolutionException {
appendAllNonPlatformExtensions();
if (catalogs.isEmpty()) {
final List<RegistryExtensionResolver> registries = ExtensionCatalogResolver.this.registries;
if (registries.isEmpty()) {
throw new RegistryResolutionException("Quarkus extension registry is not available");
}
if (registries.size() == 1) {
throw new RegistryResolutionException("Quarkus extension registry " + registries.get(0).getId()
+ " did not provide any extension catalog");
}
final StringBuilder buf = new StringBuilder();
buf.append("Quarkus extension registries ");
buf.append(registries.get(0).getId());
for (int i = 1; i < registries.size(); ++i) {
buf.append(", ").append(registries.get(i).getId());
}
buf.append(" did not provide any extension catalog");
throw new RegistryResolutionException(buf.toString());
}
return JsonCatalogMerger.merge(catalogs);
}
}
Expand Down