Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Maven Exec Plugin Inside Eclipse

Using m2eclipse, what is the simplest way to use the Codehaus Mojo Exec Plugin to launch my project without leaving eclipse? So far on the pom plugins screen I have set up the org.codehuas.mojo plugin.

Specifically, I would like to execute the following from inside eclipse:

mvn exec:java -Dexec.mainClass=org.sonatype.mavenbook.weather.Main
like image 950
knpwrs Avatar asked May 21 '11 02:05

knpwrs


People also ask

How do I run a maven plugin goal in Eclipse?

Create a run configuration by click "Run → Run Configurations", select Maven Build and click "New launch configuration", type Name "OpenMRS", select working directory to be the root of webapp project, type goal "jetty:run" and save. Now you select "OpenMRS" and run or debug it.

Can we run maven commands in Eclipse?

You can run Maven goals from Eclipse. You can view the output of Maven commands inside the Eclipse, using its own console. You can update maven dependencies with IDE. You can Launch Maven builds from within Eclipse.

What is maven exec?

mvn exec:java is a goal from the exec plugin for maven. It lets you specify a main class to execute (see pom. xml). This lets you avoid having to figure out the proper java command to run and classpath arguments and the like.


1 Answers

  1. go to Run menu -> run configurations
  2. you should see a "Maven Build" item on the list of the left, double click it to create a new configuration of that type
  3. name it as you want
  4. browse workspace to select the base directory of your project
  5. set exec:java as the goal, and exec.mainClass / yourClass as parameters.

This is how it looks on my set-up:

enter image description here

PD: if you have set the mainClass argument on the pom.xml, then the parameter from the execution will be disregarded.

like image 90
ilcavero Avatar answered Oct 02 '22 02:10

ilcavero