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 onF5
. - 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 onF5
. - 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
.
- 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
1 Answer
Reset to default 0Turns 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