Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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!

like image 879
bibby Avatar asked Aug 31 '11 04:08

bibby


2 Answers

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:

Eclipse Maven parameters

like image 71
Vineet Reynolds Avatar answered Oct 26 '22 04:10

Vineet Reynolds


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.

like image 25
SimplGy Avatar answered Oct 26 '22 03:10

SimplGy