sim_79
sim_79

Reputation: 23

How do Maven and m2e-Eclipse-Plugin cooperate

I have some questions about the m2e-Eclipse-Plugin. Version of m2e is 1.6 and the version of Eclipse is 4.5 (Mars).

In my Eclipse-workspace I have a Maven-Project (Java web application) that is deployed on a local Tomcat server.

I really would like to know how m2e-Plugin and Maven work together. If I change a Java-file and save it, the corresponding Class-file in the mvn-target-directory is immediately updated.

Is this compilation done by the default Java-Builder in Eclipse or is it done by Maven ? (i.e. the mvn-compile-plugin does the compilation). If the latter case is true, how is the compile-goal executed ?

Can I configure which mvn-goals are executed if a Java-file is changed and saved? If the compilation is done by the Java Builder, how does the Builder know that it has to copy the compiled file to the mvn-target-directory ?

I found two posts:

How do Java and Maven builders work together in eclipse?

How do I start Maven "compile" goal on save in Eclipse?

that deal with similar issues. But most of the proposed configuration settings didn't work in my Eclipse.

Upvotes: 2

Views: 273

Answers (1)

khmarbaise
khmarbaise

Reputation: 97399

The compilation in your scenario is done by the Eclipse compiler and not by Maven nor the maven-compiler-plugin. M2E Maps all things to Eclipse internals to handle most of the things needed to work inside Eclipse.

During an initial import of a Maven project into Eclipse using M2E (creating .project/.classpath/.settings) the life cycle will be run till generate-resources and therefore some plugins are run and can create other stuff (things like ANTLR/JAXB generators etc.). Eclipse handles the correct target folders by reading the pom.xml files and by M2E it is translated into configuration for Eclipse etc. The things you are referencing about configuration is simply not working cause those posts are too old...

Upvotes: 2

Related Questions