Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force the use of an alternate POM file in eclipse

Tags:

In my maven project I usually use the POM file named pom.xml. I have a second POM file though (call it pom_alt.xml), which I occasionally use to perform a very different build of the same project. To do so I specify the -f option in the command line

mvn clean package -fpom_alt.xml

as suggested by man mvn:

   -f,--file
          Force the use of an alternate POM file.

Now, when I am coding in eclipse I usually need maven to use pom.xml, but sometimes I should code or debug while the other file pom_alt.xml is used instead. Is there a way to tell the eclipse maven integration to use that file? Currently I am temporarily copy-pasting from pom_alt.xml to pom.xml since I seldom happen to need that, but you can see that's not optimal.

I am with Eclipse IDE for Java EE Developers, Mars Release 4.5.0.

UPDATE

I could build from the command line or use Run As Maven build as in Carlos Andres' solution, but ideally I would like to define a persistent setting, like a property or preference. This because I find nice if the POM file can be fixed while I am doing things like running as Java Application and test cases, or executing on a server. Processes that require a project clean or server restart are often triggering a maven build with the default POM.

like image 770
Mario Trucco Avatar asked May 17 '16 21:05

Mario Trucco


1 Answers

Check that M2E - Maven Integration for Eclipse is installed on Eclipse. Once that is installed go to the project and press right click enter image description here

Next, put the command that you want to execute

enter image description here

This option allow you to save the commands, and the next time all your commands will be saved.

To execute the command recorded go to enter image description here

like image 99
Carlos Andrés García Avatar answered Sep 28 '22 01:09

Carlos Andrés García