开发者

Giving arguments to maven resources goal from eclipse

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:resourcesstep 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 开发者_JAVA技巧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!


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:

Giving arguments to maven resources goal from eclipse


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜