in src/extension.ts [60:155]
async function doActivate(_operationId: string, context: vscode.ExtensionContext): Promise<void> {
pluginInfoProvider.initialize(context);
await vscode.commands.executeCommand("setContext", "vscode-maven:activated", true);
// register tree view
await mavenExplorerProvider.loadProjects();
const view = vscode.window.createTreeView("mavenProjects", { treeDataProvider: mavenExplorerProvider, showCollapseAll: true });
context.subscriptions.push(view);
registerCommand(context, "maven.dependency.goToEffective", (node?: Dependency) => goToEffectiveHandler(view, node));
context.subscriptions.push(vscode.workspace.onDidGrantWorkspaceTrust(_e => {
mavenExplorerProvider.refresh();
}));
// pom.xml listener to refresh tree view
registerPomFileWatcher(context);
// 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) => {
registerCommandRequiringTrust(context, `maven.goal.${goal}`, async (node: MavenProject) => executeInTerminal({ command: goal, pomfile: node.pomPath }));
});
registerCommand(context, "maven.explorer.refresh", refreshExplorerHandler);
registerCommandRequiringTrust(context, "maven.project.effectivePom", async (projectOrUri: Uri | MavenProject) => await Utils.showEffectivePom(projectOrUri));
registerCommandRequiringTrust(context, "maven.goal.custom", async (node: MavenProject) => await Utils.executeCustomGoal(node.pomPath));
registerCommand(context, "maven.project.openPom", openPomHandler);
// create project from archetype
registerCommand(context, "maven.archetype.generate", async (operationId: string, entry: Uri | IProjectCreationMetadata | undefined) => {
await ArchetypeModule.createMavenProject(entry, operationId);
}, true);
registerCommand(context, "maven.archetype.update", updateArchetypeCatalogHandler);
registerProjectCreationEndListener(context);
registerCommandRequiringTrust(context, "maven.history", mavenHistoryHandler);
registerCommandRequiringTrust(context, "maven.favorites", runFavoriteCommandsHandler);
registerCommandRequiringTrust(context, "maven.goal.execute", Utils.executeMavenCommand);
registerCommandRequiringTrust(context, "maven.goal.execute.fromProjectManager", Utils.executeMavenCommand);
registerCommandRequiringTrust(context, "maven.goal.execute.fromLifecycleMenu", Utils.executeMavenCommand);
registerCommandRequiringTrust(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());
registerConfigChangeListener(context);
// Free resources when a terminal is manually closed
context.subscriptions.push(
vscode.window.onDidCloseTerminal((closedTerminal: vscode.Terminal) => {
const name: string | undefined = mavenTerminal.find(closedTerminal);
if (name !== undefined) {
mavenTerminal.dispose(name);
}
})
);
// Reload projects when workspace folders added/removed
context.subscriptions.push(
vscode.workspace.onDidChangeWorkspaceFolders(async (e: vscode.WorkspaceFoldersChangeEvent) => {
for (const removedWorkspaceFolder of e.removed) {
await mavenExplorerProvider.removeWorkspaceFolder(removedWorkspaceFolder);
}
for (const addedWorkspaceFolder of e.added) {
await mavenExplorerProvider.addWorkspaceFolder(addedWorkspaceFolder);
}
})
);
registerPomFileAuthoringHelpers(context);
// dependency
registerCommand(context, "maven.project.addDependency", addDependencyHandler);
registerCommand(context, "maven.project.showDependencies", showDependenciesHandler);
registerCommand(context, "maven.project.excludeDependency", excludeDependencyHandler);
registerCommand(context, "maven.project.setDependencyVersion", setDependencyVersionHandler);
registerCommand(context, "maven.project.goToDefinition", jumpToDefinitionHandler);
// debug
registerCommand(context, "maven.plugin.debug", debugHandler);
vscode.debug.onDidTerminateDebugSession((session) => {
if (session.type === "java") {
const terminalName: string = session.configuration.terminalName;
if (terminalName) {
// After terminating debug session, output is no longer visible.
// Solution: via future API waitOnExit
// See: https://github.com/Microsoft/vscode/issues/70444
mavenTerminal.dispose(terminalName);
}
}
});
// register artifact searcher if Java language server is activated
if (isJavaExtEnabled()) {
registerArtifactSearcher(context);
}
// diagnostic
diagnosticProvider.initialize(context);
// fileDecoration
context.subscriptions.push(decorationProvider);
// textDocument based output (e.g. effective-pom, dependencies)
context.subscriptions.push(vscode.workspace.registerTextDocumentContentProvider("vscode-maven", contentProvider));
}