从 Eclipse 中为 Maven 资源目标提供论据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7252431/
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
Giving arguments to maven resources goal from eclipse
提问by bibby
I'm using the Maven2 and Tomcat plugins for eclipse for a java project that gets deployed as a Tomcat app. I have several Run Configurations for a different goals, but I have one in particular that does multiple goals in sequence:
我正在将 Maven2 和 Tomcat 插件用于 Eclipse,用于部署为 Tomcat 应用程序的 Java 项目。我有几个针对不同目标的运行配置,但我特别有一个按顺序执行多个目标:
clean resources:resources compile war:war tomcat:deploy
I wanted one of my resource xml files to have config values specific to the build, for instance a dev-build versus a production-build. The resources:resources
step should allow me to set values to {tags} in the xml, and I am able to do this via the command line as it's own step:
我希望我的资源 xml 文件之一具有特定于构建的配置值,例如开发构建与生产构建。该resources:resources
步骤应该允许我在 xml 中将值设置为 {tags},并且我可以通过命令行执行此操作,因为它是自己的步骤:
<test var="{foo}">
Running mvn resources:resources -Dfoo='bar'
produces the following in the target directory
运行mvn resources:resources -Dfoo='bar'
在目标目录中产生以下内容
<test var="bar">
In the Run Configuration management gui in eclipse, there are slots for arguments and values, but I can't find the correct combination/incantation of parameters to get the same effect as the command line evocation.
在 eclipse 的运行配置管理 gui 中,有参数和值的插槽,但我找不到参数的正确组合/咒语来获得与命令行调用相同的效果。
Anyone know how? Of course, would also accept "You're doing it wrong," (because I probably am) " Do it like this."
有谁知道怎么做?当然,也会接受“你做错了”,(因为我可能是)“这样做。”
Thanks!
谢谢!
回答by Vineet Reynolds
You can pass in parameters that are eventually used as Maven properties, using the parameters section of a Maven Build run configuration in Eclipse (I'll assume that you're using the Eclipse M2E plugin).
您可以传入最终用作Maven 属性的参数,使用 Eclipse 中 Maven 构建运行配置的参数部分(我假设您使用的是 Eclipse M2E 插件)。
The following screenshot demonstrates how the {jacoco.agent.path}
property that I eventually used in my Maven POM, is specified from the run configuration:
以下屏幕截图演示了{jacoco.agent.path}
我最终在 Maven POM 中使用的属性是如何从运行配置中指定的:
回答by SimplGy
If you go to Run Configurations > Apache Tomcat > [your tomcat] > Arguments Tab > VM Arguments And add -Dfoo="bar", it should work.
如果您转到运行配置 > Apache Tomcat > [your tomcat] > Arguments Tab > VM Arguments 并添加 -Dfoo="bar",它应该可以工作。
I had to stop and start and clean a few times before it picked it up, but it worked for me eventually.
在它捡起来之前,我不得不停下来开始清理几次,但它最终对我有用。