kontorrr testor
kontorrr testor

Reputation: 51

How to create shortcut for a maven command in VS Code?

For some reason I must execute the following command to build my project:

mvn clean install -U -Dmaven.javadoc.skip=true -Dmaven.test.skip=true

Is there a way in VS Code that I can create a shortcut for this command instead of entering it in the terminal?

Upvotes: 3

Views: 3776

Answers (1)

6pi
6pi

Reputation: 417

Use the following command : tasks: Configure Default Build Task

See https://code.visualstudio.com/docs/editor/tasks for more details.

It allows to configure the .vscode/tasks.json file like following:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "mvn clean install -U -Dmaven.javadoc.skip=true -Dmaven.test.skip=true",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

Then, you will can exec the command tasks: run build task to run mvn clean install -U -Dmaven.javadoc.skip=true -Dmaven.test.skip=true.

Upvotes: 2

Related Questions