Skip to content

Commit

Permalink
fix #910: run plugin goals with prefix in full command (#911)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eskibear committed Nov 30, 2022
1 parent 55faed6 commit d62011e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/explorer/model/PluginGoal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,13 @@ export class PluginGoal implements ITreeItem {
public getTreeItem(): vscode.TreeItem {
return new vscode.TreeItem(this.name, vscode.TreeItemCollapsibleState.None);
}

public get command() : string {
if (this.name.includes(":")) {
// workaround for compatibility in case the name already contains prefix
return this.name;
}
return `${this.plugin.prefix}:${this.name}`;
}

}
3 changes: 2 additions & 1 deletion src/explorer/pluginInfoProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ class PluginInfoProvider {
const goalRegExp: RegExp = new RegExp(`^${prefix}:(.*)`, "gm");
const goalsMatch: string[] | null = textOutput.match(goalRegExp);
if (goalsMatch !== null) {
goals.push(...goalsMatch);
// prefix:goal matched, remove "prefix:" part
goals.push(...goalsMatch.map(fullGoal => fullGoal.slice(prefix!.length + 1)));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ async function doActivate(_operationId: string, context: vscode.ExtensionContext
registerCommandRequiringTrust(context, "maven.goal.execute.fromProjectManager", Utils.executeMavenCommand);
registerCommandRequiringTrust(context, "maven.goal.execute.fromLifecycleMenu", Utils.executeMavenCommand);
registerCommandRequiringTrust(context, "maven.goal.execute.fromFavoritesMenu", Utils.executeMavenCommand);
registerCommandRequiringTrust(context, "maven.plugin.execute", async (pluginGoal: PluginGoal) => await executeInTerminal({ command: pluginGoal.name, pomfile: pluginGoal.plugin.project.pomPath }));
registerCommandRequiringTrust(context, "maven.plugin.execute", async (pluginGoal: PluginGoal) => await executeInTerminal({ command: pluginGoal.command, pomfile: pluginGoal.plugin.project.pomPath }));
registerCommand(context, "maven.view.flat", () => Settings.changeToFlatView());
registerCommand(context, "maven.view.hierarchical", () => Settings.changeToHierarchicalView());

Expand Down

0 comments on commit d62011e

Please sign in to comment.