Search in sources :

Example 1 with OriginCombination

use of io.quarkus.registry.catalog.selection.OriginCombination in project quarkus by quarkusio.

the class UpdateCommandHandler method getRecommendedOrigins.

private static List<ExtensionCatalog> getRecommendedOrigins(ExtensionCatalog extensionCatalog, List<Extension> extensions) throws QuarkusCommandException {
    final List<ExtensionOrigins> extOrigins = new ArrayList<>(extensions.size());
    for (Extension e : extensions) {
        addOrigins(extOrigins, e);
    }
    final OriginCombination recommendedCombination = OriginSelector.of(extOrigins).calculateRecommendedCombination();
    if (recommendedCombination == null) {
        final StringBuilder buf = new StringBuilder();
        buf.append("Failed to determine a compatible Quarkus version for the requested extensions: ");
        buf.append(extensions.get(0).getArtifact().getKey().toGacString());
        for (int i = 1; i < extensions.size(); ++i) {
            buf.append(", ").append(extensions.get(i).getArtifact().getKey().toGacString());
        }
        throw new QuarkusCommandException(buf.toString());
    }
    return recommendedCombination.getUniqueSortedOrigins().stream().map(o -> o.getCatalog()).collect(Collectors.toList());
}
Also used : Extension(io.quarkus.registry.catalog.Extension) OriginPreference(io.quarkus.registry.catalog.selection.OriginPreference) ExtensionOrigins(io.quarkus.registry.catalog.selection.ExtensionOrigins) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) QuarkusCommandInvocation(io.quarkus.devtools.commands.data.QuarkusCommandInvocation) ArtifactKey(io.quarkus.maven.dependency.ArtifactKey) ArtifactCoords(io.quarkus.maven.dependency.ArtifactCoords) Map(java.util.Map) QuarkusCommandOutcome(io.quarkus.devtools.commands.data.QuarkusCommandOutcome) ExtensionCatalog(io.quarkus.registry.catalog.ExtensionCatalog) ModuleState(io.quarkus.devtools.project.state.ModuleState) PlatformInfo(io.quarkus.devtools.commands.handlers.InfoCommandHandler.PlatformInfo) ExtensionProvider(io.quarkus.devtools.project.state.ExtensionProvider) Collection(java.util.Collection) Collectors(java.util.stream.Collectors) OriginSelector(io.quarkus.registry.catalog.selection.OriginSelector) ExtensionOrigin(io.quarkus.registry.catalog.ExtensionOrigin) List(java.util.List) ApplicationModel(io.quarkus.bootstrap.model.ApplicationModel) TopExtensionDependency(io.quarkus.devtools.project.state.TopExtensionDependency) QuarkusCommandException(io.quarkus.devtools.commands.data.QuarkusCommandException) MessageWriter(io.quarkus.devtools.messagewriter.MessageWriter) Extension(io.quarkus.registry.catalog.Extension) OriginCombination(io.quarkus.registry.catalog.selection.OriginCombination) Collections(java.util.Collections) ProjectState(io.quarkus.devtools.project.state.ProjectState) ExtensionOrigins(io.quarkus.registry.catalog.selection.ExtensionOrigins) ArrayList(java.util.ArrayList) OriginCombination(io.quarkus.registry.catalog.selection.OriginCombination) QuarkusCommandException(io.quarkus.devtools.commands.data.QuarkusCommandException)

Example 2 with OriginCombination

use of io.quarkus.registry.catalog.selection.OriginCombination in project quarkus by quarkusio.

the class CreateProjectCommandHandler method getExtensionOrigins.

private static List<ExtensionCatalog> getExtensionOrigins(ExtensionCatalog extensionCatalog, List<Extension> extensionsToAdd) throws QuarkusCommandException {
    final List<ExtensionOrigins> extOrigins = new ArrayList<>(extensionsToAdd.size());
    for (Extension e : extensionsToAdd) {
        addOrigins(extOrigins, e);
    }
    if (extOrigins.isEmpty()) {
        // legacy 1.x or universe platform
        return Collections.emptyList();
    }
    // we add quarkus-core as a selected extension here only to include the quarkus-bom
    // in the list of platforms. quarkus-core won't be added to the generated POM though.
    final Optional<Extension> quarkusCore = extensionCatalog.getExtensions().stream().filter(e -> e.getArtifact().getArtifactId().equals("quarkus-core")).findFirst();
    if (!quarkusCore.isPresent()) {
        throw new QuarkusCommandException("Failed to locate quarkus-core in the extension catalog");
    }
    addOrigins(extOrigins, quarkusCore.get());
    final OriginCombination recommendedCombination = OriginSelector.of(extOrigins).calculateRecommendedCombination();
    if (recommendedCombination == null) {
        final StringBuilder buf = new StringBuilder();
        buf.append("Failed to determine a compatible Quarkus version for the requested extensions: ");
        buf.append(extensionsToAdd.get(0).getArtifact().getKey().toGacString());
        for (int i = 1; i < extensionsToAdd.size(); ++i) {
            buf.append(", ").append(extensionsToAdd.get(i).getArtifact().getKey().toGacString());
        }
        throw new QuarkusCommandException(buf.toString());
    }
    return recommendedCombination.getUniqueSortedOrigins().stream().map(o -> o.getCatalog()).collect(Collectors.toList());
}
Also used : Extension(io.quarkus.registry.catalog.Extension) BOM_GROUP_ID(io.quarkus.devtools.project.codegen.ProjectGenerator.BOM_GROUP_ID) Extensions(io.quarkus.devtools.project.extensions.Extensions) PACKAGE_NAME(io.quarkus.devtools.project.codegen.ProjectGenerator.PACKAGE_NAME) OriginPreference(io.quarkus.registry.catalog.selection.OriginPreference) ExtensionOrigins(io.quarkus.registry.catalog.selection.ExtensionOrigins) HashMap(java.util.HashMap) CodestartType(io.quarkus.devtools.codestarts.CodestartType) ToolsUtils(io.quarkus.platform.tools.ToolsUtils) ArrayList(java.util.ArrayList) QuarkusCodestartCatalog(io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartCatalog) QuarkusCommandInvocation(io.quarkus.devtools.commands.data.QuarkusCommandInvocation) ERROR_ICON(io.quarkus.devtools.messagewriter.MessageIcons.ERROR_ICON) ArtifactCoords(io.quarkus.maven.ArtifactCoords) MessageIcons(io.quarkus.devtools.messagewriter.MessageIcons) Map(java.util.Map) NO_CODE(io.quarkus.devtools.commands.CreateProject.NO_CODE) QuarkusCommandOutcome(io.quarkus.devtools.commands.data.QuarkusCommandOutcome) EXAMPLE(io.quarkus.devtools.commands.CreateProject.EXAMPLE) NO_BUILDTOOL_WRAPPER(io.quarkus.devtools.commands.CreateProject.NO_BUILDTOOL_WRAPPER) APP_CONFIG(io.quarkus.devtools.project.codegen.ProjectGenerator.APP_CONFIG) ExtensionCatalog(io.quarkus.registry.catalog.ExtensionCatalog) CatalogMergeUtility(io.quarkus.registry.CatalogMergeUtility) QuarkusCommandHandlers.computeExtensionsFromQuery(io.quarkus.devtools.commands.handlers.QuarkusCommandHandlers.computeExtensionsFromQuery) BOM_ARTIFACT_ID(io.quarkus.devtools.project.codegen.ProjectGenerator.BOM_ARTIFACT_ID) Properties(java.util.Properties) QuarkusCodestartProjectInput(io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartProjectInput) CLASS_NAME(io.quarkus.devtools.project.codegen.ProjectGenerator.CLASS_NAME) CodestartProjectDefinition(io.quarkus.devtools.codestarts.CodestartProjectDefinition) Set(java.util.Set) IOException(java.io.IOException) LegacySupport(io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartData.LegacySupport) EXTRA_CODESTARTS(io.quarkus.devtools.commands.CreateProject.EXTRA_CODESTARTS) PROJECT_GROUP_ID(io.quarkus.devtools.project.codegen.ProjectGenerator.PROJECT_GROUP_ID) Collectors(java.util.stream.Collectors) OriginSelector(io.quarkus.registry.catalog.selection.OriginSelector) ExtensionOrigin(io.quarkus.registry.catalog.ExtensionOrigin) List(java.util.List) QuarkusCommandException(io.quarkus.devtools.commands.data.QuarkusCommandException) QUARKUS_VERSION(io.quarkus.devtools.project.codegen.ProjectGenerator.QUARKUS_VERSION) Optional(java.util.Optional) MessageWriter(io.quarkus.devtools.messagewriter.MessageWriter) ProjectGenerator(io.quarkus.devtools.project.codegen.ProjectGenerator) Extension(io.quarkus.registry.catalog.Extension) OriginCombination(io.quarkus.registry.catalog.selection.OriginCombination) Collections(java.util.Collections) NO_DOCKERFILES(io.quarkus.devtools.commands.CreateProject.NO_DOCKERFILES) BOM_VERSION(io.quarkus.devtools.project.codegen.ProjectGenerator.BOM_VERSION) ExtensionOrigins(io.quarkus.registry.catalog.selection.ExtensionOrigins) ArrayList(java.util.ArrayList) OriginCombination(io.quarkus.registry.catalog.selection.OriginCombination) QuarkusCommandException(io.quarkus.devtools.commands.data.QuarkusCommandException)

Aggregations

QuarkusCommandException (io.quarkus.devtools.commands.data.QuarkusCommandException)2 QuarkusCommandInvocation (io.quarkus.devtools.commands.data.QuarkusCommandInvocation)2 QuarkusCommandOutcome (io.quarkus.devtools.commands.data.QuarkusCommandOutcome)2 MessageWriter (io.quarkus.devtools.messagewriter.MessageWriter)2 Extension (io.quarkus.registry.catalog.Extension)2 ExtensionCatalog (io.quarkus.registry.catalog.ExtensionCatalog)2 ExtensionOrigin (io.quarkus.registry.catalog.ExtensionOrigin)2 ExtensionOrigins (io.quarkus.registry.catalog.selection.ExtensionOrigins)2 OriginCombination (io.quarkus.registry.catalog.selection.OriginCombination)2 OriginPreference (io.quarkus.registry.catalog.selection.OriginPreference)2 OriginSelector (io.quarkus.registry.catalog.selection.OriginSelector)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 ApplicationModel (io.quarkus.bootstrap.model.ApplicationModel)1 CodestartProjectDefinition (io.quarkus.devtools.codestarts.CodestartProjectDefinition)1 CodestartType (io.quarkus.devtools.codestarts.CodestartType)1