Skip to content

Commit

Permalink
register new command for gradle with kotlin dsl
Browse files Browse the repository at this point in the history
  • Loading branch information
brunovieira97 committed Mar 9, 2024
1 parent 0928e29 commit 980de60
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
"title": "Create a Gradle Project...",
"category": "Spring Initializr"
},
{
"command": "spring.initializr.gradle-project-kotlin",
"title": "Create a Gradle Project with Kotlin DSL...",
"category": "Spring Initializr"
},
{
"command": "spring.initializr.addStarters",
"title": "Add Starters...",
Expand Down
9 changes: 6 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from "vscode-extension-telemetry-wrapper";
import { AddStartersHandler, GenerateProjectHandler } from "./handler";
import { getTargetPomXml, loadPackageInfo } from "./Utils";
import { ProjectType } from "./model";

export async function activate(context: vscode.ExtensionContext): Promise<void> {
await initializeFromJsonFile(context.asAbsolutePath("./package.json"), { firstParty: true });
Expand All @@ -26,14 +27,16 @@ async function initializeExtension(_operationId: string, context: vscode.Extensi
await loadPackageInfo(context);

context.subscriptions.push(
instrumentAndRegisterCommand("spring.initializr.maven-project", async (operationId, defaults) => await new GenerateProjectHandler("maven-project", defaults).run(operationId), true),
instrumentAndRegisterCommand("spring.initializr.gradle-project", async (operationId, defaults) => await new GenerateProjectHandler("gradle-project", defaults).run(operationId), true),
instrumentAndRegisterCommand("spring.initializr.maven-project", async (operationId, defaults) => await new GenerateProjectHandler(ProjectType.MAVEN, defaults).run(operationId), true),
instrumentAndRegisterCommand("spring.initializr.gradle-project", async (operationId, defaults) => await new GenerateProjectHandler(ProjectType.GRADLE, defaults).run(operationId), true),
instrumentAndRegisterCommand("spring.initializr.gradle-project-kotlin", async (operationId, defaults) => await new GenerateProjectHandler(ProjectType.GRADLE_KOTLIN, defaults).run(operationId), true)
);

context.subscriptions.push(instrumentAndRegisterCommand("spring.initializr.createProject", async () => {
const projectType: { value: string, label: string } = await vscode.window.showQuickPick([
{ value: "maven-project", label: "Maven Project" },
{ value: "gradle-project", label: "Gradle Project" }
{ value: "gradle-project", label: "Gradle Project" },
{ value: "gradle-project-kotlin", label: "Gradle Project - Kotlin DSL" }
], { placeHolder: "Select project type." });
if (projectType) {
await vscode.commands.executeCommand(`spring.initializr.${projectType.value}`);
Expand Down

0 comments on commit 980de60

Please sign in to comment.