You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ma...@apache.org on 2022/12/01 23:52:36 UTC
[camel-karavan] 02/04: Run with Maven
This is an automated email from the ASF dual-hosted git repository.
marat pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
commit 8a94b3e175b85063ae593573b0363e006b64f1d6
Author: Marat Gubaidullin <ma...@gmail.com>
AuthorDate: Thu Dec 1 18:47:52 2022 -0500
Run with Maven
---
karavan-vscode/package.json | 10 +++++-----
karavan-vscode/src/extension.ts | 9 +++++----
karavan-vscode/src/jbang.ts | 13 +++++++++----
3 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/karavan-vscode/package.json b/karavan-vscode/package.json
index 9f961cd..3790296 100644
--- a/karavan-vscode/package.json
+++ b/karavan-vscode/package.json
@@ -392,12 +392,12 @@
},
{
"command": "karavan.open",
- "when": "resourceExtname == .yaml",
+ "when": "resourceFilename =~ /.camel.yaml$/",
"group": "karavan@4"
},
{
"command": "karavan.jbang-run-file",
- "when": "resourceExtname == .yaml",
+ "when": "resourceFilename =~ /.camel.yaml$/",
"group": "karavan@5"
},
{
@@ -424,12 +424,12 @@
"editor/title": [
{
"command": "karavan.open",
- "when": "resourceExtname == .yaml",
+ "when": "resourceFilename =~ /.camel.yaml$/",
"group": "navigation@1"
},
{
- "command": "karavan.jbang-run-file",
- "when": "resourceExtname == .yaml || karavan:loaded",
+ "command": "karavan.jbang-run-project",
+ "when": "resourceFilename =~ /.camel.yaml$/ || karavan:loaded",
"group": "navigation@2"
},
{
diff --git a/karavan-vscode/src/extension.ts b/karavan-vscode/src/extension.ts
index 99087b9..3eb4c11 100644
--- a/karavan-vscode/src/extension.ts
+++ b/karavan-vscode/src/extension.ts
@@ -115,7 +115,7 @@ export function activate(context: ExtensionContext) {
// Run project
const runProjectCommand = commands.registerCommand("karavan.jbang-run-project", (...args: any[]) => {
- jbang.camelJbangRun();
+ exportProject(rootPath, true);
});
context.subscriptions.push(runProjectCommand);
@@ -148,11 +148,12 @@ export function activate(context: ExtensionContext) {
/**
* export into folder
*/
-export async function exportProject(rootPath?: string) {
+export async function exportProject(rootPath?: string, run?: boolean) {
utils.getExportFolder()
.then(folder => {
if (folder){
- jbang.camelJbangExport();
+ const fullPath = rootPath + path.sep + folder;
+ jbang.camelJbangExport(fullPath, run);
} else {
window.showInputBox({
title: "Export project",
@@ -169,7 +170,7 @@ export async function exportProject(rootPath?: string) {
}).then(folder => {
if (folder && rootPath) {
const fullPath = rootPath + path.sep + folder;
- jbang.camelJbangExport(fullPath);
+ jbang.camelJbangExport(fullPath, run);
}
});
}
diff --git a/karavan-vscode/src/jbang.ts b/karavan-vscode/src/jbang.ts
index 456d46b..d90bbab 100644
--- a/karavan-vscode/src/jbang.ts
+++ b/karavan-vscode/src/jbang.ts
@@ -94,8 +94,13 @@ export function camelJbangRun(filename?: string) {
terminal.sendText(command);
}
-export function camelJbangExport(fullPath?: string) {
- const command = createExportCommand(fullPath);
+export async function camelJbangExport(fullPath: string, run?: boolean) {
+ let command = createExportCommand(fullPath);
+ if (run) {
+ const runtime = await utils.getRuntime();
+ const mvn = runtime === 'quarkus' ? "quarkus:dev" : "spring-boot:run";
+ command = command.concat(" && mvn clean ").concat(mvn).concat(" -f ").concat(fullPath);
+ }
const terminalId = "export";
const existTerminal = TERMINALS.get(terminalId);
if (existTerminal) existTerminal.dispose();
@@ -105,7 +110,7 @@ export function camelJbangExport(fullPath?: string) {
terminal.sendText(command);
}
-export function createExportCommand(fullPath?: string) {
+export function createExportCommand(fullPath: string) {
const kameletsPath: string | undefined = workspace.getConfiguration().get("Karavan.kameletsPath");
const cmd = "export --fresh "
+ (fullPath ? " --directory=" + fullPath : '')
@@ -130,7 +135,7 @@ export function camelDeploy(directory: string) {
window.showErrorMessage("Namespace not set \n" + val[3].error);
}
const deployCommand: string = workspace.getConfiguration().get("Karavan.".concat(runtime.replaceAll("-", "")).concat(utils.capitalize(target)).concat("Deploy")) || '';
- const command = createExportCommand().concat(" && ").concat(deployCommand).concat(" -f ").concat(exportFolder);
+ const command = createExportCommand(directory).concat(" && ").concat(deployCommand).concat(" -f ").concat(exportFolder);
camelRunDeploy(command, env);
}).catch((reason: any) => {
window.showErrorMessage("Error: \n" + reason.message);