Skip to content

Commit

Permalink
register commands for test-compile (#801)
Browse files Browse the repository at this point in the history
Signed-off-by: Yan Zhang <[email protected]>
  • Loading branch information
Eskibear authored Mar 1, 2022
1 parent dc11afb commit 5b1f283
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"onCommand:maven.goal.validate",
"onCommand:maven.goal.compile",
"onCommand:maven.goal.test",
"onCommand:maven.goal.test-compile",
"onCommand:maven.goal.package",
"onCommand:maven.goal.verify",
"onCommand:maven.goal.install",
Expand Down Expand Up @@ -92,6 +93,11 @@
"title": "test",
"category": "Maven"
},
{
"command": "maven.goal.test-compile",
"title": "test-compile",
"category": "Maven"
},
{
"command": "maven.goal.package",
"title": "package",
Expand Down Expand Up @@ -262,6 +268,10 @@
"command": "maven.goal.test",
"when": "never"
},
{
"command": "maven.goal.test-compile",
"when": "never"
},
{
"command": "maven.goal.package",
"when": "never"
Expand Down Expand Up @@ -436,6 +446,11 @@
"when": "view == mavenProjects && viewItem == maven:project",
"group": "1-lifecycle@70"
},
{
"command": "maven.goal.test-compile",
"when": "view == mavenProjects && viewItem == maven:project",
"group": "1-lifecycle@75"
},
{
"command": "maven.goal.site",
"when": "view == mavenProjects && viewItem == maven:project",
Expand Down
3 changes: 3 additions & 0 deletions src/completion/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

export const COMMAND_COMPLETION_ITEM_SELECTED: string = "maven.completion.selected";
export const INFO_COMPLETION_ITEM_SELECTED: string = "completion-item-selected";

// each should have a corresponding command maven.goal.xxx
export const DEFAULT_MAVEN_LIFECYCLES: string[] = ["clean", "validate", "compile", "test", "test-compile", "package", "verify", "install", "site", "deploy"];
3 changes: 2 additions & 1 deletion src/explorer/model/LifecycleMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license.

import * as vscode from "vscode";
import { DEFAULT_MAVEN_LIFECYCLES } from "../../completion/constants";
import { ITreeItem } from "./ITreeItem";
import { LifecyclePhase } from "./LifecyclePhase";
import { MavenProject } from "./MavenProject";
Expand All @@ -14,7 +15,7 @@ export class LifecycleMenu extends Menu implements ITreeItem {
}

public async getChildren() : Promise<LifecyclePhase[]> {
return ["clean", "validate", "compile", "test", "test-compile", "package", "verify", "install", "site", "deploy"].map(goal => new LifecyclePhase(this.project, goal));
return DEFAULT_MAVEN_LIFECYCLES.map(goal => new LifecyclePhase(this.project, goal));
}

public getTreeItem(): vscode.TreeItem | Thenable<vscode.TreeItem> {
Expand Down
3 changes: 2 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { IProjectCreationMetadata } from "./archetype/createProject/types";
import { codeActionProvider } from "./codeAction/codeActionProvider";
import { ConflictResolver, conflictResolver } from "./codeAction/conflictResolver";
import { completionProvider } from "./completion/completionProvider";
import { DEFAULT_MAVEN_LIFECYCLES } from "./completion/constants";
import { contentProvider } from "./contentProvider";
import { definitionProvider } from "./definition/definitionProvider";
import { diagnosticProvider } from "./DiagnosticProvider";
Expand Down Expand Up @@ -73,7 +74,7 @@ async function doActivate(_operationId: string, context: vscode.ExtensionContext
// register output, terminal, taskExecutor
context.subscriptions.push(mavenOutputChannel, mavenTerminal, taskExecutor);
// register common goals
["clean", "validate", "compile", "test", "package", "verify", "install", "site", "deploy"].forEach((goal: string) => {
DEFAULT_MAVEN_LIFECYCLES.forEach((goal: string) => {
registerCommandRequiringTrust(context, `maven.goal.${goal}`, async (node: MavenProject) => executeInTerminal({ command: goal, pomfile: node.pomPath }));
});
registerCommand(context, "maven.explorer.refresh", refreshExplorerHandler);
Expand Down
3 changes: 2 additions & 1 deletion src/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as url from "url";
import { commands, Progress, ProgressLocation, RelativePattern, Uri, window, workspace, WorkspaceFolder } from "vscode";
import { createUuid, setUserError } from "vscode-extension-telemetry-wrapper";
import * as xml2js from "xml2js";
import { DEFAULT_MAVEN_LIFECYCLES } from "../completion/constants";
import { mavenExplorerProvider } from "../explorer/mavenExplorerProvider";
import { LifecyclePhase } from "../explorer/model/LifecyclePhase";
import { MavenProject } from "../explorer/model/MavenProject";
Expand Down Expand Up @@ -245,7 +246,7 @@ export namespace Utils {
const LABEL_CUSTOM: string = "Custom ...";
const LABEL_FAVORITES: string = "Favorites ...";
selectedCommand = await window.showQuickPick(
[LABEL_FAVORITES, LABEL_CUSTOM, "clean", "validate", "compile", "test", "package", "verify", "install", "site", "deploy"],
[LABEL_FAVORITES, LABEL_CUSTOM, ...DEFAULT_MAVEN_LIFECYCLES],
{ placeHolder: "Select the goal to execute ...", ignoreFocusOut: true }
);
if (!selectedCommand) {
Expand Down

0 comments on commit 5b1f283

Please sign in to comment.