Skip to content
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
31 changes: 16 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"onCommand:maven.goal.deploy",
"onCommand:maven.goal.custom",
"onCommand:maven.goal.execute",
"onCommand:maven.goal.execute.fromProjectManager",
"onCommand:maven.project.effectivePom",
"onCommand:maven.project.openPom",
"onCommand:maven.archetype.generate",
Expand Down Expand Up @@ -142,6 +143,11 @@
"title": "%contributes.commands.maven.goal.execute%",
"category": "Maven"
},
{
"command": "maven.goal.execute.fromProjectManager",
"title": "Run Maven Commands...",
"category": "Maven"
},
{
"command": "maven.plugin.execute",
"title": "%contributes.commands.maven.plugin.execute%",
Expand Down Expand Up @@ -255,6 +261,10 @@
{
"command": "maven.project.showDependencies",
"when": "never"
},
{
"command": "maven.goal.execute.fromProjectManager",
"when": "never"
}
],
"explorer/context": [
Expand Down Expand Up @@ -400,6 +410,11 @@
"command": "maven.project.addDependency",
"when": "view == javaProjectExplorer && viewItem =~ /java:container(?=.*?\\b\\+maven\\b)/",
"group": "inline"
},
{
"command": "maven.goal.execute.fromProjectManager",
"when": "view == javaProjectExplorer && viewItem =~ /java:project(?=.*?\\b\\+maven\\b)(?=.*?\\b\\+uri\\b)/",
"group": "maven"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"contributes.commands.maven.archetype.update": "Update Maven Archetype Catalog",
"contributes.commands.maven.favorites": "Favorites...",
"contributes.commands.maven.history": "History...",
"contributes.commands.maven.goal.execute": "Execute commands",
"contributes.commands.maven.goal.execute": "Execute Commands...",
"contributes.commands.maven.plugin.execute": "Run",
"contributes.commands.maven.plugin.debug": "Debug",
"contributes.commands.maven.view.hierarchical": "Switch to hierarchical view",
Expand Down
2 changes: 1 addition & 1 deletion package.nls.zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"contributes.commands.maven.archetype.update": "更新 Maven 原型目录",
"contributes.commands.maven.favorites": "收藏夹…",
"contributes.commands.maven.history": "历史…",
"contributes.commands.maven.goal.execute": "执行命令",
"contributes.commands.maven.goal.execute": "执行命令...",
"contributes.commands.maven.plugin.execute": "执行",
"contributes.commands.maven.plugin.debug": "调试",
"contributes.commands.maven.view.hierarchical": "切换到分层视图",
Expand Down
3 changes: 2 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ async function doActivate(_operationId: string, context: vscode.ExtensionContext
registerCommand(context, "maven.archetype.update", updateArchetypeCatalogHandler);
registerCommand(context, "maven.history", mavenHistoryHandler);
registerCommand(context, "maven.favorites", runFavoriteCommandsHandler);
registerCommand(context, "maven.goal.execute", async () => await Utils.executeMavenCommand());
registerCommand(context, "maven.goal.execute", Utils.executeMavenCommand);
registerCommand(context, "maven.goal.execute.fromProjectManager", Utils.executeMavenCommand);
registerCommand(context, "maven.plugin.execute", async (pluginGoal: PluginGoal) => await executeInTerminal({ command: pluginGoal.name, pomfile: pluginGoal.plugin.project.pomPath }));
registerCommand(context, "maven.view.flat", () => Settings.changeToFlatView());
registerCommand(context, "maven.view.hierarchical", () => Settings.changeToHierarchicalView());
Expand Down
14 changes: 12 additions & 2 deletions src/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as fse from "fs-extra";
import * as http from "http";
import * as https from "https";
import * as md5 from "md5";
import * as path from "path";
import * as url from "url";
import { commands, Progress, ProgressLocation, RelativePattern, TextDocument, Uri, ViewColumn, window, workspace, WorkspaceFolder } from "vscode";
import { createUuid, setUserError } from "vscode-extension-telemetry-wrapper";
Expand Down Expand Up @@ -232,9 +233,18 @@ export namespace Utils {
}
}

export async function executeMavenCommand(): Promise<void> {
export async function executeMavenCommand(node?: any): Promise<void> {
// for nodes from Project Manager
let selectedProject: MavenProject | undefined;
if (node && node.uri) {
const pomPath: string = path.join(Uri.parse(node.uri).fsPath, "pom.xml");
selectedProject = mavenExplorerProvider.mavenProjectNodes.find(project => project.pomPath.toLowerCase() === pomPath.toLowerCase());
}
// select a project(pomfile)
const selectedProject: MavenProject | undefined = await selectProjectIfNecessary();
if (!selectedProject) {
selectedProject = await selectProjectIfNecessary();
}

if (!selectedProject) {
return;
}
Expand Down