Eclipse 中 Maven 包命令的键绑定
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6753475/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Key binding in Eclipse for Maven package command
提问by Bryan Glazer
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.
我想在eclipse中绑定mvn package命令。所以我使用正常程序来做到这一点:Window->Preferences->General->Keys 然后我过滤了 Maven。显示的唯一命令是运行 Maven 构建、运行 Maven 安装、运行 Maven 清洁等。运行 Maven 包没有出现。为这个命令设置一个键绑定真的很有帮助,谢谢你的帮助。
回答by gMale
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:
我在这种情况下使用的方法是为我想要的目标(mvn package
在你的情况下)创建运行配置,然后使用键绑定来访问这些运行配置:
- Bind Maven Build to your desired key
- Note: it defaults to shift-alt-X, M
- 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
- 将 Maven Build 绑定到您想要的密钥
- 注意:它默认为shift- alt- X,M
- 注意:它默认为shift- alt- X,M
- 为您想要的目标创建 Maven 运行配置,例如
mvn package
- 选择您的项目,选择运行 > 运行配置...
- 为您的项目选择当前的 Maven 运行配置(在 Maven Build > yourProjectName 下)
- 点击左上角的复制按钮复制运行配置
- 在名称部分,给出一个有意义的名称,例如“yourProject--package”
[可选地,将您的原始配置重命名为“yourProject--install”之类的名称] - 在“目标”部分,输入您想要的目标,例如“干净的包”
- 选择“应用”然后“关闭”
- 使用 Maven Build 键绑定,然后使用箭头键选择合适的目标
- 现在,当您点击“Maven Build”键绑定时,系统会提示您选择所需的运行配置。 此窗口仅在您有多个 maven 运行配置时出现!从那里按 ENTER,您将选择您的套餐目标!
- 按回车将选择第一个 maven 配置
- 使用箭头键选择其他配置
- 命名您的配置,以便您使用最多的配置位于顶部
Now, to execute mvn package
on your project, press:
现在,要mvn package
在您的项目上执行,请按:
shift-alt-X, M
enter
shift- alt- X,M
enter
To execute mvn clean install -DskipTests
on your project, press:
要mvn clean install -DskipTests
在您的项目上执行,请按:
shift-alt-X, M
down
down
enter
shift- alt- X,M
down
down
enter
我希望能帮助某人...