最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Visual Studio Code Maven Run Configuration - Stack Overflow

programmeradmin2浏览0评论

I'm trying to figure out how to bind VSC's F5 / run key to a custom maven command, e.g. maven clean package

I know I can click on the lifecycle phases in the Maven explorer menu, but I want to bind it to F5, and keep the option for the full power of any maven command, not just a provided palette.

  • So far I understood that I can define a .vscode/launch.json, to define what happens on F5.
  • There seems to be no dedicated maven launcher, so I guess the only way is to define a bash configuration, that then runs my maven command.

Ideally someone could provide me with a sample that runs a maven command. On the long run I'm looking for a detailed technical documentation of the launch.json syntax, e.g. a schema, so I can define whatever I need.

I only found the high level Microsoft tutorial, but no technical details on how to write my own launch.json.

I'm trying to figure out how to bind VSC's F5 / run key to a custom maven command, e.g. maven clean package

I know I can click on the lifecycle phases in the Maven explorer menu, but I want to bind it to F5, and keep the option for the full power of any maven command, not just a provided palette.

  • So far I understood that I can define a .vscode/launch.json, to define what happens on F5.
  • There seems to be no dedicated maven launcher, so I guess the only way is to define a bash configuration, that then runs my maven command.

Ideally someone could provide me with a sample that runs a maven command. On the long run I'm looking for a detailed technical documentation of the launch.json syntax, e.g. a schema, so I can define whatever I need.

I only found the high level Microsoft tutorial, but no technical details on how to write my own launch.json.

Share Improve this question edited Mar 6 at 17:22 m5c asked Mar 6 at 16:50 m5cm5c 1181 silver badge10 bronze badges 1
  • Snap, just saw the syntax is explained on the next page in the official guide... although I still don't find a maven specific launch-configuration. – m5c Commented Mar 6 at 16:52
Add a comment  | 

1 Answer 1

Reset to default 0

Turns out the problem was just me not properly differentiating between:

  • Debug configurations: F5, defined in .vscode/launch.json
  • Build task configurations: Run Task, defined in .vscode/tasks.json

Running the maven command as shell command was straightforward with a file .vscode/tasks.json, as illustrated in this sample.

I only needed to swap the command for my maven command:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Maven Clean Package",
            "type": "shell",
            "command": "mvn clean package",
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

Finally to run: ⌘ Command + ⇧ Shift + B

发布评论

评论列表(0)

  1. 暂无评论