Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

the "build automatically" and maven in Eclipse

Tags:

eclipse

maven

m2e

in Eclipse, when Maven is enabled, there is a pom.xml file to build with Maven. And also, Eclipse has a "build automatically" option in it's project menu.

Is the "build automatically" automatically build with Maven, or we need uncheck it, because when Maven is enabled, we don't need the Eclipse build in build system anymore?

like image 709
lovespring Avatar asked Aug 16 '13 23:08

lovespring


2 Answers

Eclipse's m2e will run the plugin goals it has lifecycle bindings for. I don't know (and I'm unable to find) what specific phases are run, but from experience I know that:

  • for normal operation, at least compile gets executed.
  • for executing tests (e.g. JUnit test cases), at least test-compile gets executed.

Note that it doesn't have all possible bindings, and going around that problem is sometimes problematic. So, usually, having both should run fine, and in fact will avoid some incongruities due to the compiled state not updating while you code.

However if you have plugins that are ignored by m2e, you should actually shut down "Build Automatically" off when you need to be certain your build completes correctly.

For example, using the Maven Properties plugin, if you have not provided a binding and set m2e to ignore, you will have resources with out-of-whack property values. The problem can especially occur when you do a "Maven" build (from the right-click context menu for example), and then do a change in your code and save it.

like image 170
mikołak Avatar answered Oct 22 '22 15:10

mikołak


You need both. Here is why:

Eclipse built-in compiler is used for incremental compilation - when you save your code, for example. But full build of the project is done using maven and project configuration in pom.xml.

like image 27
Eugene Ryzhikov Avatar answered Oct 22 '22 13:10

Eugene Ryzhikov