从 Eclipse 为 Maven 资源目标提供参数
我正在使用 Maven2 和 Tomcat 插件来构建一个作为 Tomcat 应用程序部署的 java 项目。我有几个用于不同目标的运行配置,但我有一个特别是按顺序执行多个目标的运行配置:
clean resources:resources compile war:war tomcat:deploy
我希望我的资源 xml 文件之一具有特定于构建的配置值,例如开发构建与生产构建建造。 resources:resources
步骤应该允许我在 xml 中将值设置为 {tags},并且我可以通过命令行执行此操作,因为它是自己的步骤:
<test var="{foo}">
运行 mvn resources:resources -Dfoo='bar'
在目标目录中生成以下内容
<test var="bar">
在 eclipse 中的运行配置管理 gui 中,有参数和值的插槽,但我找不到参数的正确组合/咒语来获取同样的效果作为命令行调用。
有人知道怎么做吗? 当然,也会接受“你做错了”,(因为我可能就是)“这样做吧。”
谢谢!
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:
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:
<test var="{foo}">
Running mvn resources:resources -Dfoo='bar'
produces the following in the target directory
<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.
Anyone know how?
Of course, would also accept "You're doing it wrong," (because I probably am) " Do it like this."
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 a 的参数部分传入最终用作 Maven 属性 的参数。 Eclipse 中的 Maven Build 运行配置(我假设您使用的是 Eclipse M2E 插件)。
以下屏幕截图演示了如何从运行配置中指定我最终在 Maven POM 中使用的
{jacoco.agent.path}
属性: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).
The following screenshot demonstrates how the
{jacoco.agent.path}
property that I eventually used in my Maven POM, is specified from the run configuration:如果您转到“运行配置”> Apache Tomcat > [你的雄猫]>参数选项卡>虚拟机参数
并添加 -Dfoo="bar" ,它应该可以工作。
在它把它捡起来之前,我不得不停下来启动并清洁几次,但它最终对我有用。
If you go to Run Configurations > Apache Tomcat > [your tomcat] > Arguments Tab > VM Arguments
And add -Dfoo="bar", it should work.
I had to stop and start and clean a few times before it picked it up, but it worked for me eventually.