use of io.quarkus.devtools.commands.data.QuarkusCommandInvocation in project quarkus by quarkusio.
the class AddExtensionsCommandHandler method execute.
@Override
public QuarkusCommandOutcome execute(QuarkusCommandInvocation invocation) throws QuarkusCommandException {
final Set<String> extensionsQuery = invocation.getValue(AddExtensions.EXTENSIONS, Collections.emptySet());
if (extensionsQuery.isEmpty()) {
return QuarkusCommandOutcome.success().setValue(AddExtensions.OUTCOME_UPDATED, false);
}
final ExtensionManager extensionManager = invocation.getValue(EXTENSION_MANAGER, invocation.getQuarkusProject().getExtensionManager());
try {
ExtensionInstallPlan extensionInstallPlan = planInstallation(invocation, extensionsQuery);
if (extensionInstallPlan.isInstallable()) {
final InstallResult result = extensionManager.install(extensionInstallPlan);
result.getInstalledPlatforms().forEach(a -> invocation.log().info(MessageIcons.OK_ICON + " Platform " + a.getGroupId() + ":" + a.getArtifactId() + " has been installed"));
result.getInstalledManagedExtensions().forEach(a -> invocation.log().info(MessageIcons.OK_ICON + " Extension " + a.getGroupId() + ":" + a.getArtifactId() + " has been installed"));
result.getInstalledIndependentExtensions().forEach(a -> invocation.log().info(MessageIcons.OK_ICON + " Extension " + a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getVersion() + " has been installed"));
result.getAlreadyInstalled().forEach(a -> invocation.log().info(MessageIcons.NOOP_ICON + " Extension " + a.getGroupId() + ":" + a.getArtifactId() + " was already installed"));
return new QuarkusCommandOutcome(true).setValue(AddExtensions.OUTCOME_UPDATED, result.isSourceUpdated());
} else if (!extensionInstallPlan.getUnmatchedKeywords().isEmpty()) {
invocation.log().info(ERROR_ICON + " Nothing installed because keyword(s) '" + String.join("', '", extensionInstallPlan.getUnmatchedKeywords()) + "' were not matched in the catalog.");
} else {
invocation.log().info(NOK_ICON + " The provided keyword(s) did not match any extension from the catalog.");
}
} catch (MultipleExtensionsFoundException m) {
StringBuilder sb = new StringBuilder();
sb.append(ERROR_ICON + " Multiple extensions matching '").append(m.getKeyword()).append("'");
m.getExtensions().forEach(extension -> sb.append(System.lineSeparator()).append(" - ").append(extension.managementKey()));
sb.append(System.lineSeparator()).append(" Be more specific e.g using the exact name or the full GAV.");
invocation.log().info(sb.toString());
} catch (IOException e) {
throw new QuarkusCommandException("Failed to add extensions", e);
}
return new QuarkusCommandOutcome(false).setValue(AddExtensions.OUTCOME_UPDATED, false);
}
use of io.quarkus.devtools.commands.data.QuarkusCommandInvocation in project quarkus by quarkusio.
the class CreateApp method call.
@Override
public Integer call() throws Exception {
try {
output.debug("Creating a new project with initial parameters: %s", this);
output.throwIfUnmatchedArguments(spec.commandLine());
setSingleProjectGAV(gav);
setTestOutputDirectory(output.getTestDirectory());
if (checkProjectRootAlreadyExists(runMode.isDryRun())) {
return CommandLine.ExitCode.USAGE;
}
BuildTool buildTool = targetBuildTool.getBuildTool(BuildTool.MAVEN);
SourceType sourceType = targetLanguage.getSourceType(spec, buildTool, extensions, output);
setJavaVersion(targetLanguage.getJavaVersion());
setSourceTypeExtensions(extensions, sourceType);
setCodegenOptions(codeGeneration);
QuarkusCommandInvocation invocation = build(buildTool, targetQuarkusVersion, propertiesOptions.properties, extensions);
boolean success = true;
if (runMode.isDryRun()) {
dryRun(buildTool, invocation, output);
} else if (buildTool == BuildTool.JBANG) {
success = new CreateJBangProjectCommandHandler().execute(invocation).isSuccess();
} else {
// maven or gradle
success = new CreateProjectCommandHandler().execute(invocation).isSuccess();
}
if (success) {
if (!runMode.isDryRun()) {
output.info("Navigate into this directory and get started: " + spec.root().qualifiedName() + " dev");
}
return CommandLine.ExitCode.OK;
}
return CommandLine.ExitCode.SOFTWARE;
} catch (Exception e) {
return output.handleCommandException(e, "Unable to create project: " + e.getMessage());
}
}
use of io.quarkus.devtools.commands.data.QuarkusCommandInvocation in project quarkus by quarkusio.
the class InfoMojo method processProjectState.
@Override
protected void processProjectState(QuarkusProject quarkusProject) throws MojoExecutionException {
final Map<String, Object> params = new HashMap<>();
params.put(UpdateCommandHandler.APP_MODEL, resolveApplicationModel());
params.put(UpdateCommandHandler.LOG_STATE_PER_MODULE, perModule);
final QuarkusCommandInvocation invocation = new QuarkusCommandInvocation(quarkusProject, params);
QuarkusCommandOutcome outcome;
try {
outcome = new InfoCommandHandler().execute(invocation);
} catch (QuarkusCommandException e) {
throw new MojoExecutionException("Failed to resolve the available updates", e);
}
if (outcome.getValue(InfoCommandHandler.RECOMMENDATIONS_AVAILABLE, false)) {
getLog().warn("Non-recommended Quarkus platform BOM and/or extension versions were found. For more details, please, execute 'mvn quarkus:update -Drectify'");
}
}
use of io.quarkus.devtools.commands.data.QuarkusCommandInvocation in project quarkus by quarkusio.
the class UpdateMojo method processProjectState.
@Override
protected void processProjectState(QuarkusProject quarkusProject) throws MojoExecutionException {
final Map<String, Object> params = new HashMap<>();
try {
params.put(UpdateCommandHandler.LATEST_CATALOG, getExtensionCatalogResolver().resolveExtensionCatalog());
} catch (RegistryResolutionException e) {
throw new MojoExecutionException("Failed to resolve the latest Quarkus extension catalog from the configured extension registries", e);
}
params.put(UpdateCommandHandler.APP_MODEL, resolveApplicationModel());
params.put(UpdateCommandHandler.LOG_RECOMMENDED_STATE, recommendedState);
params.put(UpdateCommandHandler.LOG_STATE_PER_MODULE, perModule);
params.put(UpdateCommandHandler.RECTIFY, rectify);
final QuarkusCommandInvocation invocation = new QuarkusCommandInvocation(quarkusProject, params);
try {
new UpdateCommandHandler().execute(invocation);
} catch (QuarkusCommandException e) {
throw new MojoExecutionException("Failed to resolve the available updates", e);
}
}
use of io.quarkus.devtools.commands.data.QuarkusCommandInvocation in project quarkus-platform by quarkusio.
the class UpdateMojo method processProjectState.
@Override
protected void processProjectState(QuarkusProject quarkusProject) throws MojoExecutionException {
final Map<String, Object> params = new HashMap<>();
try {
params.put(UpdateCommandHandler.LATEST_CATALOG, getExtensionCatalogResolver().resolveExtensionCatalog());
} catch (RegistryResolutionException e) {
throw new MojoExecutionException("Failed to resolve the latest Quarkus extension catalog from the configured extension registries", e);
}
params.put(UpdateCommandHandler.APP_MODEL, resolveApplicationModel());
params.put(UpdateCommandHandler.LOG_RECOMMENDED_STATE, recommendedState);
params.put(UpdateCommandHandler.LOG_STATE_PER_MODULE, perModule);
params.put(UpdateCommandHandler.RECTIFY, rectify);
final QuarkusCommandInvocation invocation = new QuarkusCommandInvocation(quarkusProject, params);
try {
new UpdateCommandHandler().execute(invocation);
} catch (QuarkusCommandException e) {
throw new MojoExecutionException("Failed to resolve the available updates", e);
}
}
Aggregations