I want to bind the mvn package command in eclipse. So I used the normal procedure to do this: Window->Preferences->General->Keys and then I filtered for Maven. The only commands that showed up were Run Maven Build, Run Maven Install, Run Maven Clean, etc. Run Maven package doesn't appear. It would really help to have a key binding for this command, thanks for your help.
The approach I use in this case is to create run configurations for the goals I want (mvn package
in your case) and then use key bindings to access those run configs:
- Bind Maven Build to your desired key
- Note: it defaults to shift-alt-X, M
- Create Maven Run configurations for your desired goals like
mvn package
- Select your project, choose run > Run Configurations...
- Select the current maven run configuration for your project (under Maven Build > yourProjectName)
- Click the copy button on the upper left to copy the run config
- in the name section, give a meaningful name such as "yourProject--package"
[optionally, rename your original config to something like "yourProject--install"]
- In the "Goals" section, type the goals you want such as "clean package"
- Choose "Apply" then "close"
- Use Maven Build key binding, then arrow keys to select appropriate goal
- Now, when you hit your "Maven Build" key binding, you will be prompted with a window to select your desired run configuration. This window only appears when you have more than one maven run configuration! From there press ENTER and you'll choose your package goal!
- pressing enter will select the first maven configuration
- use the arrow keys to select other configs
- name your configurations such that the one you use most is at the top
Now, to execute mvn package
on your project, press:
shift-alt-X, M
enter
To execute mvn clean install -DskipTests
on your project, press:
shift-alt-X, M
down
down
enter
I hope that helps someone...