1

This is not currently an error, i just want to know how it works that m2e executes the maven-compiler-plugin.

I cannot find any lifecycleMappingMetadata in the pom.xml of the plugin.

Is it possible that the magic takes place in workspace\.metadata\.plugins\org.eclipse.m2e.core\>projectname>.lifecyclemapping?

I cannot really read the file, it seems to be binary.

wutzebaer
  • 14,365
  • 19
  • 99
  • 170

1 Answers1

1

It depends what you do in Eclipse:

  • If you run a Maven target via a Maven launch configuration from Eclipse, then maven-compiler-plugin gets executed as if you'd run Maven from cmd line (well, mostly).
  • Otherwise, no maven-compiler-plugin is executed; Eclipse runs its own compiler, and ignores the plugin. Please note however that if you configure parameters for the JVM, in pom.xml (in the config section of the plugin), those parameters might be taken in consideration by certain Eclipse plugins (m2e-apt comes to mind, but there might be others)

I don't understand your statement about lifecycleMappingMetadata; did you expect to find it in pom.xml? If so, then in my experience, maven-compiler-plugin is excepted from it (i.e. you don't need to add explicit lifecycle mapping).

Andrei
  • 1,613
  • 3
  • 16
  • 36
  • I run my project via run on server.. when the plugin is not executed who compiles my classes into to target/classes folder? This folder is only defined via the pom.xml – wutzebaer Jun 07 '17 at 20:57
  • Eclipse uses its own compiler (Eclipse JDT) - that's the one that does it. – Andrei Jun 07 '17 at 20:58
  • I should add that most of the time works surprisingly well. I was only able to find differences (between Eclipse compilation and compilation via standard maven/java) in some very particular cases such as annotation processors, and certain types of generics abuse. – Andrei Jun 07 '17 at 21:05
  • That means m2e configures the eclipse compiler to output to target/classes? – wutzebaer Jun 07 '17 at 21:10
  • Yes, I think so. When Maven nature is present in an eclipse project, certain variables are picked up automagically - such as target/classes. But unlike IntelliJ, no plugin actually runs. This is more visible in a more advanced setup; for example no `maven-war-plugin` runs either, but Eclipse knows to pick up automagically part of config from war plugin (but not all). Also, not sure if you know about right clicking your project, then Maven section, then `Update project` - this takes what's in your pom.xml and updates Eclipse config files. – Andrei Jun 07 '17 at 21:14
  • Look for example here: https://stackoverflow.com/questions/3061654/what-is-the-difference-between-javac-and-the-eclipse-compiler I was wrong about JDT apparently; it is called ECJ (I think JDT is either a core of ECJ, or some commercially available package; not sure). – Andrei Jun 07 '17 at 21:18