java IntelliJ IDEA 中的自定义 Maven 目标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12184654/
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
Custom Maven goals in IntelliJ IDEA
提问by
I am trying to find the way to configure the custom maven goals in IntelliJ
. For e.g. I want the custom goal to be: clean install -U
and I want to name it: update
, but I can't find how to configure this in IntelliJ
. Is this even possible? If so how can I do this?
我正在尝试找到在IntelliJ
. 例如,我希望自定义目标为:clean install -U
并且我想将其命名为: update
,但我找不到如何在IntelliJ
. 这甚至可能吗?如果是这样,我该怎么做?
采纳答案by Chris
There are 2 things you can do:
你可以做两件事:
You can right-click your project root in the "Maven Projects" view and select the "Create XXX [install]..." option (where XXX is your project/module name. Then, in the subsequent dialog, specify clean install -U
as the command line option. This will create a run configuration that invokes maven (you can name it "update" if you want). While it won't show up in the Maven view, it will be accessible from the normal run/debug configuration.
您可以在“Maven Projects”视图中右键单击您的项目根目录并选择“Create XXX [install]...”选项(其中 XXX 是您的项目/模块名称。然后,在随后的对话框中,指定clean install -U
为命令line 选项。这将创建一个调用 maven 的运行配置(如果需要,您可以将其命名为“更新”)。虽然它不会出现在 Maven 视图中,但可以从正常的运行/调试配置访问。
Alternatively, you can define a new profile in your pom that rebinds "install" to "clean install -U". You won't be able to rename it to "update" in the intelliJ ui, but you can at least ensure that both clean and install are run whenever someone runs the install goal.
或者,您可以在 pom 中定义一个新的配置文件,将“安装”重新绑定到“全新安装 -U”。您将无法在 intelliJ ui 中将其重命名为“更新”,但您至少可以确保在有人运行安装目标时同时运行 clean 和 install 。
回答by Nahuel Barrios
Another way to do that is create a new run/debug Maven configuration. There you can specify the full command line arguments and a lot of other things.
另一种方法是创建一个新的运行/调试 Maven 配置。在那里您可以指定完整的命令行参数和许多其他内容。
Run\Edit configurations...
Select + (to create a new one)\Maven