开发者

Key binding in Eclipse for Maven package command

开发者 https://www.devze.com 2023-03-21 05:32 出处:网络
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 sh

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:

  1. Bind Maven Build to your desired key
    • Note: it defaults to shift-alt-X, M
  2. Create Maven Run configurations for your desired goals like mvn package
    1. Select your project, choose run > Run Configurations...
    2. Select the current maven run configuration for your project (under Maven Build > yourProjectName)
    3. Click the copy button on the upper left to copy the run config
    4. in the name section, give a meaningful name such as "yourProject--package"
      [optionally, rename your original config to something like "yourProject--install"]
    5. In the "Goals" section, type the goals you want such as "clean package"
    6. Choose "Apply" then "close"
  3. 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...

0

精彩评论

暂无评论...
验证码 换一张
取 消